Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Adding cycles to UserData Field

    Scheduled Pinned Locked Moved PYTHON Development
    2 Posts 0 Posters 365 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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.

                        obj.SetUserDataContainer(id_, bc)
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post