I have a tag plugin that is attached to an object with several children.
In the tag I test if one of the childrens matrix is changed.
class AFONTTAG(plugins.TagData):
def Execute(self, tag, doc, op, bt, priority, flags):
child = op.GetDown().GetDown()
if (child.IsDirty(c4d.DIRTYFLAGS_MATRIX)):
....
My issue is that, if one of the children is dirty (in this case due to scaling), I get the scale of the child using child[c4d.ID_BASEOBJECT_REL_SCALE], to calculate the new size of the object.
Note: This is done is Object Mode, because one of the grandchildren has a Pose Morph tag.
To calculate the size I use GetRad() and multiple it with the scale.
However, sometimes GetRad() returns (0,0,0)?
I know the tag is threaded, so that might have something to do with it?
I do not insert objects, just change the position of the children.
What am I doing wrong?
class AFONTTAG(plugins.TagData):
def Execute(self, tag, doc, op, bt, priority, flags):
child = op.GetDown().GetDown()
if (child.IsDirty(c4d.DIRTYFLAGS_MATRIX)):
bbRadiusA = child.GetRad()
if (bbRadiusA[0] == 0): #Sometime zero!!!
print "error: ", bbRadiusA
return True
if (doc.GetAction() == c4d.ID_MODELING_SCALE):
a = child.GetRad()
b = child[c4d.ID_BASEOBJECT_REL_SCALE]
bbRadiusA = a * c4d.Matrix(v1=c4d.Vector(b[0],0,0), v2=c4d.Vector(0,b[1],0), v3=c4d.Vector(0,0,b[2]))
.....
return c4d.EXECUTIONRESULT_OK
if __name__ == "__main__":
bmp = bitmaps.BaseBitmap()
dir, file = os.path.split(__file__)
bitmapfile = os.path.join(dir, "res", "AFont.png")
result = bmp.InitWith(bitmapfile)
PLUGINSTRINGTAG = "AFont TEST"
okyn = plugins.RegisterTagPlugin(id=PLUGIN_ID_AFONTTAG, str=PLUGINSTRINGTAG, info=c4d.TAG_VISIBLE|c4d.TAG_EXPRESSION|c4d.TAG_MULTIPLE, g=AFONTTAG, description="afonttag", icon=bmp)
if (not okyn):
print "Error initializing " + PLUGINSTRINGTAG
Here the hierarchy.