On 23/09/2013 at 01:00, xxxxxxxx wrote:
I have this userdata cycle field with several options (cycles).
But I want to change those options depending on other functionality.
Reading posts here on the forum, I think I must remove the ud field and then insert it again.
However, when inserting, the ud field is always placed at the end of my ud.
How can I update the cycle field, but do not change the position of the field.
Here the working code, which updates the cycles, but places the field at the end.
for id_, bc in obj.GetUserDataContainer() :
rid = id_[id_.GetDepth() - 1].id
if (bc[c4d.DESC_NAME] == "Render Preset") : #get cycle options
cycle = bc[c4d.DESC_CYCLE] #basecontainer with cycle options.
for i in cycle: print i #show options for debug information
cycle.SetData(4,'Lowlow') #overwrite option 4
bc[c4d.DESC_CYCLE] = cycle #write back to container
obj.RemoveUserData(rid) #remove ud
obj.AddUserData(bc) #add again (but now at the end?
obj[c4d.ID_USERDATA,rid] = 1 #set default
On 23/09/2013 at 06:20, xxxxxxxx wrote:
I messed some indexes. Thanks to one of Scott's posts it is now working.
No need to remove and re-insert.