I have a simple task but unfortunately, I can't find the solution in docs.
I have an object generator plugin which generates a cube object with a rigid body tag onto it.
When I'm playing the animation, no dynamics takes place.
def GetVirtualObjects(self, op, hh):
cube = c4d.BaseObject(c4d.Ocube) #Cube
tag = cube.MakeTag(180000102) #Rigid body tag
#This Crashes C4D.
#op.GetDocument().ExecutePasses(c4d.threading.GeGetCurrentThread(), True, True, True, c4d.BUILDFLAGS_INTERNALRENDERER)
I also tried to create a virtual document and then return the clone but the result is the same. no animation takes place.
I guess I'm using ExecutePasses() in a wrong way.
Would like to get more info about this.
it is worth mentioning that it would be better if this code will return an error message instead of crashing c4d.
op.GetDocument().ExecutePasses(c4d.threading.GeGetCurrentThread(), True, True, True, c4d.BUILDFLAGS_INTERNALRENDERER)
GetVirtualObjects() is called when the scene is updated. ExecutePasses() updates the scene. So you want to update the scene while the scene is updated. That's bad.
Also, you create a virtual cube and add a tag to that cube. But you do not add the cube to any document. So updating any document would have no effect on that cube.
Typically, one does not add a simulation tag to a virtual object. Such a tag is typically added to the generator that create the virtual objects e.g. you add a simulation tag to a MoGraph cloner to animate it virtual child objects.