Create a Take
-
I want to create Takes using Python
I have a Null with an object as a child under it.Below code creates the Take, but it does not fill the Category ok.
What am I doing wrong?
import c4d def main(): # Gets the TakeData from the active document (holds all information about Takes) takeData = doc.GetTakeData() if takeData is None: raise RuntimeError("Failed to retrieve the take data.") obj = doc.GetFirstObject() print ("First: ", obj.GetName()) # Adds a new Take newTake = takeData.AddTake(obj.GetName(), None, None) if newTake is None: raise RuntimeError("Failed to add a new take.") # Defines the created Take as the active one takeData.SetCurrentTake(newTake) c4d.CallCommand(431000081) # Auto Take toggle On # Unhide object, initially object is hidden. obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = c4d.OBJECT_ON obj[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = c4d.OBJECT_ON c4d.CallCommand(431000081) # Auto Take toggle Off # Hide object again obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = c4d.OBJECT_OFF obj[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = c4d.OBJECT_OFF # Pushes an update event to Cinema 4D c4d.EventAdd() if __name__ == '__main__': main()
-
hi,
regarding your question, this thread will help
We also have our documentationYou can also use GetTakeMode and enable the auto mode accordingly.
import c4d def main(): opClone = op.GetClone(c4d.COPYFLAGS_0) op[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = c4d.OBJECT_OFF op[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = c4d.OBJECT_OFF # Gets the TakeData from the active document (holds all information about Takes) takeData = doc.GetTakeData() if takeData is None: raise RuntimeError("Failed to retrieve the take data.") # Adds a new Take newTake = takeData.AddTake(op.GetName(), None, None) if newTake is None: raise RuntimeError("Failed to add a new take.") # Defines the created Take as the active one takeData.SetCurrentTake(newTake) # Checks if there is some TakeData and the current mode is set to auto Take if takeData and takeData.GetTakeMode() == c4d.TAKE_MODE_AUTO: newTake.AutoTake(takeData, op, opClone) # Pushes an update event to Cinema 4D c4d.EventAdd() if __name__ == '__main__': main()
Cheers,
Manuel -
Great, that works!
One other question.
I have now a script that removes old takes and adds takes based on selected objectsNow I see that the main take still has 'old' previous deleted takes.
I do not think that is an issue, but I am not sure. -
The main should contain all the objects that all the takes are changing. Are you sure none of the take change a value of the "Null" object ?
-
Hello @pim,
without any further feedback or questions, we will consider this topic as solved by Wednesday and flag it accordingly.
Thank you for your understanding,
Ferdinand