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 object to In/Exclusion List

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 681 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 05/10/2017 at 11:58, xxxxxxxx wrote:

      I'm trying to create a null and add it to an in/exclusion list. The list is in the user data of an xpresso tag. This will be run off of a script. I have this code so far:

      import c4d
      from c4d import gui, utils

      def main() :
          document = doc
          tagowner = doc.SearchObject('StageLightMaster')
          xtag = tagowner.GetFirstTag()
          LinkList = xtag[c4d.ID_USERDATA,1]
          NullMaster = c4d.BaseObject(5140)
          document.InsertObject(NullMaster)
          LinkList.InsertObject(NullMaster,1)
          c4d.EventAdd()
      if __name__=='__main__':
          main()

      I can run a count before and after the object is added and it seems to be running properly, but when I go to the list in the tag it is not updated to include the null. I read somewhere that I need to update the gui object for the changes to take place, but I'm not sure how to call it. Any help is greatly appreciated! Thanks!

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 06/10/2017 at 02:05, xxxxxxxx wrote:

        Add

        xtag[c4d.ID_USERDATA,1] = LinkList
        

        Before your EventaAdd().

        If we go step by step in your program here is what happend.

        mport c4d
        from c4d import gui, utils
          
        def main() :
            #Get the obj
            document = doc
            tagowner = doc.SearchObject('StageLightMaster')
            
            #Get the tag
            xtag = tagowner.GetFirstTag()
            
            #Get a copy in memory of xtag[c4d.ID_USERDATA,1]
            LinkList = xtag[c4d.ID_USERDATA,1]
            
            #Create in memory a new object an copy it to NullMaster
            NullMaster = c4d.BaseObject(5140)
            
            #Insert The the object into the document
            document.InsertObject(NullMaster)
            
            #Insert the object into your linklist variable which is a copy in memory of the userdata
            LinkList.InsertObject(NullMaster,1)
            
            #Trigger an event
            c4d.EventAdd()
        if __name__=='__main__':
            main()
        

        So as you see you only change value on memory so you need to push back into the object 😉

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 06/10/2017 at 02:05, xxxxxxxx wrote:

          Hi and Welcome to the Plugin Cafe forums!

          LinkList in your script (retrieved with xtag[c4d.ID_USERDATA,1]) is a copy of the actual in/exclusion user data.
          So it has to be assigned to xtag[c4d.ID_USERDATA,1], after inserting the null object, for the in/exclusion user data to be updated in the GUI.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 06/10/2017 at 05:40, xxxxxxxx wrote:

            Well you guys are just awesome! Thanks for explaining the logic behind the solution this helps me out tremendously.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post