Hi, I am having difficulty generating take overrides with ‘FindOrAddOverrideParam()’. When I run my script it creates a set of takes with an override but no value.
My script does ‘work’ if I use ‘OverrideNode()’ instead, but this overrides all of the parameters for the given object, which is much more than I want or need.
My code runs from a Python tag and is activated by a user data button. The intention is to increment the user data by one for each child object.
Any assistance would be greatly appreciated.
import c4d
def createTake():
# Get existing take structure
take_data = doc.GetTakeData()
main_take = take_data.GetMainTake()
# Get Selector child objects
obj = op.GetObject()
# Create header take
select_take = take_data.AddTake("Selector", main_take, None)
select_take.SetName(obj.GetName())
child = obj.GetDown()
#records original user value, used with OverrideNode()
originalSelection = obj[c4d.ID_USERDATA,2]
n = 1
while child:
print (f"n{n} obj {child.GetName()}")
childTake = take_data.AddTake("Selection", select_take, None)
childTake.SetName(child.GetName())
obj[c4d.ID_USERDATA,2] = n #increment userdata, used with OverrideNode()
descId = c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA), c4d.DescLevel(2))
#childTake.OverrideNode(take_data, obj, False)
overrideNode = childTake.FindOrAddOverrideParam(take_data, obj, descId, n)
n = n + 1
child = child.GetNext()
obj[c4d.ID_USERDATA,2] = originalSelection #restores original user value, used with OverrideNode()
c4d.EventAdd()
def message(msg_type, data):
if msg_type == c4d.MSG_NOTIFY_EVENT:
event_data = data['event_data']
if event_data['msg_id'] == c4d.MSG_DESCRIPTION_COMMAND:
desc_id = event_data['msg_data']['id']
if desc_id[1].id == 5: # The ID of the User Data
print ("Button Pressed")
createTake()
def main():
obj = op.GetObject()
# Check if we already listen for message
if not obj.FindEventNotification(doc, op, c4d.NOTIFY_EVENT_MESSAGE):
obj.AddEventNotification(op, c4d.NOTIFY_EVENT_MESSAGE, 0, c4d.BaseContainer())