Hi @orestiskon SendModelingCommand and especially CurrentStateToObject need the object to be actually in the passed document.
So you need to create a temporary doc and use it to operates.
As bellow:
import c4d
def currentState(obj) :
return c4d.utils.SendModelingCommand(c4d.MCOMMAND_CURRENTSTATETOOBJECT,[obj],c4d.MODELINGCOMMANDMODE_ALL,c4d.BaseContainer(),obj.GetDocument())[0]
def main():
# Retrieve the python generator
obj = op.GetDown()
if obj is None:
return
objClone = obj.GetClone()
if objClone is None:
raise RuntimeError("Failed to clone the object")
# Make the children Python Generator disapear
obj.Touch()
# Creates a temporary document that will be used to evaluate the cache of the object
tempDoc = c4d.documents.BaseDocument()
if tempDoc is None:
raise RuntimeError("Failed to create a temporary doc")
# Inserts the child python generator that exists only in memory into our tempo doc
tempDoc.InsertObject(objClone)
returnedObj = currentState(objClone)
return currentState(objClone)
Cheers,
Maxime.