GetMg() doesn't update on objects affected with Align to Spline Tag?
-
Hi,
I have an object that is constrainted to a spline through align to spline tag.
The problem is when I run a
GetMg().off
on before and after I revise the tag, I get the same result instead of having different values.What am I missing?
import c4d def main(): doc = c4d.documents.GetActiveDocument() joint = c4d.BaseObject(1019362) doc.InsertObject(joint) spline = c4d.BaseObject(5181) doc.InsertObject(spline) spline_tag = c4d.BaseTag(5699) joint.InsertTag(spline_tag) spline_tag[c4d.ALIGNTOSPLINETAG_LINK] = spline spline_tag[c4d.ALIGNTOSPLINETAG_POSITION] = 0 c4d.EventAdd() print (joint.GetMg().off) # Vector(0, 0, 0) spline_tag[c4d.ALIGNTOSPLINETAG_POSITION] = 0.2 c4d.EventAdd() print (joint.GetMg().off) # still Vector(0, 0, 0) c4d.EventAdd() if __name__ == '__main__': main()
-
Hi @bentraje,
you're doing everything right. The only step you're missing is to reevaluate the scene using ExecutePasses after changing the Align to Spline tag position. You can call it the following way:
doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_NONE)
Note, you should use
c4d.BUILDFLAGS_0
instead, if you run c4d earlier than R20. This is how you can use it in a generic way:buildFlag = c4d.BUILDFLAGS_NONE if c4d.GetC4DVersion() > 20000 else c4d.BUILDFLAGS_0 doc.ExecutePasses(None, True, True, True, buildFlag)
Cheers,
Ilia -
Gotcha. Thanks. Works as expected.