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
c4d.SendCoreMessage(c4d.COREMSG_CINEMA,
c4d.BaseContainer(c4d.COREMSG_CINEMA_FORCE_AM_UPDATE))
obj.AddUserData(bc) #add again (but now at the end?
obj[c4d.ID_USERDATA,rid] = 1 #set default