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

    Unable to Add Objects for User Data with In/Exclusion Data Type

    Cinema 4D SDK
    r21 python
    2
    3
    355
    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.
    • B
      bentraje
      last edited by

      Hi,

      Hi I'm trying to Add Objects for User Data with In/Exclusion Data Type but it doesn't seem to work.
      It doesn't also error out. It's the same code I used for the In/Exclusion Data Type for the Selection Object, which works.

      You can see the illustration here for Selection Object which works:
      https://www.dropbox.com/s/e0zi466697btn8r/c4d213_unable_to_add_object_to_user_data_inexclusion_list01.mp4?dl=0

      You can see the illustration here for User Data which doesn't work:
      https://www.dropbox.com/s/2kur2ndwjcdq35k/c4d213_unable_to_add_object_to_user_data_inexclusion_list02.mp4?dl=0

      Here is the code so far:

      import c4d
      from c4d import gui
      
      def main():
      
          tag = op.GetTag(1022749)
          bc = c4d.GetCustomDataTypeDefault(c4d.CUSTOMDATATYPE_INEXCLUDE_LIST)
          bc[c4d.DESC_NAME] = 'obj_list'
          bc.SetLong(c4d.IN_EXCLUDE_FLAG_NUM_FLAGS, 1)
          bc.SetLong(c4d.IN_EXCLUDE_FLAG_INIT_STATE, 1)
          bc.SetLong(c4d.IN_EXCLUDE_FLAG_IMAGE_01_ON, 1018640)
          bc.SetLong(c4d.IN_EXCLUDE_FLAG_IMAGE_01_OFF, 1018641)
      
          desc_ID = tag.AddUserData(bc)  # Add userdata container
      
          obj_list_content = c4d.InExcludeData()
      
          obj_list_content.InsertObject(doc.SearchObject('Sphere'), 1)
          obj_list_content.InsertObject(doc.SearchObject('Cube'), 1)
      
      
          obj_list = tag[c4d.ID_USERDATA,desc_ID[1].id]
      
          obj_list = obj_list_content
      
      # Execute main()
      if __name__=='__main__':
          main()
      
      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by Manuel

        Hello,
        you are assigning a copy of your in/exclude list to obj_list and override the copy only.

        # you are assigning a copy of your in/exclude list to obj_list.
            obj_list = tag[c4d.ID_USERDATA,desc_ID[1].id]
        # you override the copy
            obj_list = obj_list_content
        

        you can instead override the userdata itself. And if you look, that's what you are doing in the first example.

        
            tag[c4d.ID_USERDATA,desc_ID[1].id] = obj_list_content
            
            c4d.EventAdd()
        

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • B
          bentraje
          last edited by

          Thanks for the explanation. Works as expected.

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