Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Register
    • Login

    Linking python tag userdata to null (ie compositing tag)

    Cinema 4D SDK
    3
    6
    1.5k
    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
      bencaires
      last edited by

      Hi, I'm transferring an expresso setup I have into a python tag object. I have my python tag attached to a null in the scene and I'd like to be able to see the userdata of the python tag attached to the null like I can if I add a Compositing tag. I tried this code below but that only copies the userdata instead of linking it. Any ideas would be super helpful!

      import c4d
      from c4d import gui
      
      
      def main():
          
          target = op[c4d.ID_USERDATA,5]          #The null I want to transfer the userdata to
          obj = op                                #The userdata I want to transfer
              
          for id, bc in obj.GetUserDataContainer():
            
            target.SetUserDataContainer(id, bc)
          
          block = op [c4d.ID_USERDATA,4]
          color = op [c4d.ID_USERDATA,2]
          
          block[c4d.ID_BASEOBJECT_COLOR] = c4d.Vector(color)
      
      1 Reply Last reply Reply Quote 0
      • Y
        y_puech
        last edited by

        Hi,

        A compositing tag is a hierarchical tag so its parameter group (and user data) is attached to the object it's applied to.
        The Python tag isn't a hierarchical tag so it's not possible to have the same behavior.

        Note a hierarchical tag doesn't set any kind of link mechanism with the object it's attached to. Its parameters are just shown in the attribute manager with the associated object and it still owns its user data.

        Former MAXON SDK Engineer

        1 Reply Last reply Reply Quote 0
        • B
          bencaires
          last edited by

          Thanks y_puech, so is there no way to give a python tag the same functionality that comes when you add a plugin tag to an object? That seems to share userdata with the object it's attached to.

          1 Reply Last reply Reply Quote 0
          • indexofrefractionI
            indexofrefraction
            last edited by indexofrefraction

            hm... to me it is not clear what you want to do..
            " I'd like to be able to see the userdata of the python tag attached to the null like I can if I add a Compositing tag "
            ahmm?
            the script runs in the tag, so op is the tag. to get the tagged object you use obj = op.GetObject()
            so if you have a py tag with userdata you normally do something like
            obj = op.GetObject()
            obj[someId] = op[c4d.ID_USERDATA,someId]

            or if you have the userdata in the object you can do
            obj = op.GetObject()
            print obj[c4d.ID_USERDATA,someId] # do smth with userdata

            1 Reply Last reply Reply Quote 0
            • B
              bencaires
              last edited by

              Yeah I have control of all my userdata and objects already. Maybe this linked file will help? Both objects have the same userdata on the attached tag but the plugin version attaches it's userdata to the parent object like the phong tag does.

              https://www.dropbox.com/s/11hrs39qhhayqpk/PythonTag_Test_v1.c4d?dl=0

              1 Reply Last reply Reply Quote 0
              • Y
                y_puech
                last edited by

                Hi,

                The Test tag plugin is missing in the linked c4d file but I see the behavior with another tag plugin (Py-LookAtCamera SDK example).

                I was wrong in my previous post. This behavior of the Attribute Manager is applied to tags that can be added only once to an object. This can't be done for tags that can be added multiple times.
                Unfortunately the Python tag is registered with TAG_MULTIPLE flag so it can be added multiple times to an object but the parameter tab isn't attached to its parent object.

                Former MAXON SDK Engineer

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