Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hello PluginCafe!
I'm trying to display object points via the tag plugin. The code worked fine in older versions of C4D but it has no effect in the latest versions. Am I doing anything wrong?
def Draw(self, tag, op, bd, bh): bd.SetPen( c4d.Vector(1)) bd.SetPointSize( 3 ) bd.SetMatrix_Screen() bd.SetDepth(True) objMg = op.GetMg() #Get the world (global) matrix ptList = op.GetCache().GetAllPoints() points = [objMg * p for p in ptList] # Retrieves Global Coordinates screenPoints = [ bd.WS(p) for p in points ] # From world to screen Coordinates (in another array) bd.DrawPoints(screenPoints, vc = None, colcnt=1, vn=None) return c4d.DRAWRESULT_OK
Hello @merkvilson,
thank you for reaching out to us. It would have been helpful to indicate what you would consider older and the latest version of Cinema 4D in this context, but I assume your problem is caused by you using a pre-S22 TagData plugin which implements TagData.Draw in a S22+ version.
TagData
TagData.Draw
S22+
With S22, the flag TAG_IMPLEMENTS_DRAW_FUNCTION has been added to c4d.plugins.RegisterTagPlugin. You must pass it, when you want the method to be called.
S22
TAG_IMPLEMENTS_DRAW_FUNCTION
I would also point out that ptList = op.GetCache().GetAllPoints() is rather risky, as is assumes op to always have a cache which is a point object. Objects can have no caches and caches can contain other things than point objects. You should be a bit more defensive here, even if you intend to only use the plugin 'in this one scenario where this will work'.
ptList = op.GetCache().GetAllPoints()
op
Cheers, Ferdinand