Hello,
I'm creating a generator and adding a modifier from a python script, but before the script ends, I need to access some data from the modifier that is calculated in ModifyObject(), when the generator deform cache is built. But I can't make it actually generate the cache before the end of the script. From the logs, I can see the cache is generated only after the script ends.
Here's some snippets of what I'm trying...
gen = c4d.BaseObject(GENERATOR_ID)
doc.InsertObject(gen)
mod = c4d.BaseObject(MODIFIER_ID)
doc.InsertObject(mod, gen)
# This parameter is 50.0 by default
len = mod.GetParameter(mod_LengthAttribute, c4d.DESCFLAGS_GET_0)
print "mod_LengthAttribute 1 = "+str(len)
# flag an update? no effect
gen.Message(c4d.MSG_UPDATE);
# Animate the object? no effect
time = c4d.BaseTime(0)
doc.AnimateObject(gen,time,0)
# I understand this should rebuild the cache, but no effect
doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_0)
c4d.EventAdd()
#c4d.EventAdd(c4d.EVENT_ANIMATE) # does not build too
# Tried this too, no effect
#modelingSettings = c4d.BaseContainer()
#modelingSettings[c4d.MDATA_CURRENTSTATETOOBJECT_NOGENERATE] = True
#res = c4d.utils.SendModelingCommand(c4d.MCOMMAND_CURRENTSTATETOOBJECT, [gen], c4d.MODELINGCOMMANDMODE_ALL, modelingSettings, doc)
# Should be seeing something here, but it prints None
print "GetDeformCache = " + str(gen.GetDeformCache())
# ModifyObject() changes this to 100.0, but console still displays 50.0
len = mod.GetParameter(mod_LengthAttribute, c4d.DESCFLAGS_GET_0)
print "mod_LengthAttribute 2 = "+str(len)
After the script ends, I can see some debug messages from the modifier, and I can see the parameter I'm testing mod_LengthAttribute
have changed.
Is it possible to force my generator to rebuild before the script ends?
Or is there a python command to "wait until next cycle" so the document can update and before it continues?