Hi,
The Python code below creates a new take, then finds the object of interest in order to add a new material tag for the newly created take (only). The code adds the material tag, however it does not record the changes within the Take Manager under take named "TEST". Any idea what the issue might be ?
import c4d
# Main function
def main():
doc.StartUndo()
c4d.CallCommand(431000081) # Auto Take toggle on
# Create needed take system variables
take_data = doc.GetTakeData()
main_take = take_data.GetMainTake()
child_take = main_take.GetDown()
if child_take is None:
msg = "Create first child take to clone. Only one take should be present in the take manager at this time"
raise RuntimeError(msg)
# Create a new take & set it as active
new_take = take_data.AddTake("", main_take, child_take)
new_take.SetName("TEST")
take_data.SetCurrentTake(new_take)
c4d.EventAdd()
# Find object of interest and create an empty material tag
obj = doc.SearchObject('Body') # Find object
tag = obj.MakeTag(c4d.Ttexture) # Create an empty Materials Tag within object
# Find material and assign it to the tag
mat = doc.SearchMaterial('Fine') # Find material within Material Manager
tag.SetMaterial(mat) # Assign material to tag associated with object
#tag[c4d.TEXTURETAG_MATERIAL]=mat #alternate code, not needed
# Take Manager is not reflecting changes from above to the currently active take "TEST".
#tag.AddTag(take_data,c4d.Ttexture,mat) # something I tried to solve this issue, however didn't work
doc.AddUndo(c4d.UNDOTYPE_NEW,tag)
doc.EndUndo()
c4d.EventAdd()
# Execute main()
if __name__=='__main__':
main()