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
    • Login

    OperatorSetData for "Lists"?

    Cinema 4D SDK
    python r20
    2
    5
    815
    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.
    • esanE
      esan
      last edited by esan

      Am i understanding this correctly? Im trying to populate an Xpresso Link List nodes (node[1])
      "Link List" field with the children of Tiles. Just a partial snippet of code here, i dont get any errors, the objects just dont populate.
      R20

      Ive tried many permutations, tried GeListNode as type, tried enumerating children, putting that in a list()...im guessing my "Children" arent an actual "List" type, and im blindly dancing around the right answer, just cant quite get it? Do i need to first make these children a "list" (and how would i go about that?), or do i need to "insert" into document at any point? Based on the documentation it sounds like OperatorSetData should take care of the insertion. Or maybe im assuming incorrectly that "simulates user dragging onto the node" means it can simulate dragging into attribute manager of the node? Just learning Python for C4D so just trying to wrap my head around it all. Thanks!

      Edit: Have given up on OperatorSetData and trying to follow some examples set by "Inserting" objects to IN/Exclude, though it has its own class to call on so working out those discrepancies, I tried a doc.InsertObject on a single child from the children list and console told me to "add them separately", so also trying to decipher that message since c4d.BaseObjects apparently don't like to be iterated, says console. Maybe a makeshift Python node acting as a Link List node is the way to go?

      obj = doc.SearchObject("Tiles")
          children = obj.GetChildren()
      
      node[1].OperatorSetData(c4d.GV_LINK_LIST, children ,c4d.GV_OP_DROP_IN_BODY)
      
      1 Reply Last reply Reply Quote 0
      • r_giganteR
        r_gigante
        last edited by

        Hi esan, thanks for reaching out us.

        With regard to your issue, being the Link List parameter containing a InExcludeData, you need to use the InsertObject method to get objects added to the list or DeleteObject to get object out of the list.

        def main():
            # retrieve the objects in the scene
            cube = doc.SearchObject("Cube")
            sphere = doc.SearchObject("Sphere")
            if cube is None or sphere is None:
                return
            
            # assume the cube has an Xpresso Tag
            xpresso = cube.GetTag(c4d.Texpresso)
            if xpresso is None:
                return
            nm = xpresso.GetNodeMaster()
            if nm is None:
                return
            # assume the graphview contains a LinkList node
            linklist = nm.GetRoot().GetDown()
            if linklist is None or linklist.GetType() != 1001101:
                return
            
            # allocate the iInExcludeData
            inexdata = c4d.InExcludeData()
            # add the object
            inexdata.InsertObject(sphere, 1)
            
            linklist[c4d.GV_LINK_LIST] = inexdata
            
            c4d.EventAdd()
        

        Best, Riccardo

        esanE 1 Reply Last reply Reply Quote 0
        • esanE
          esan
          last edited by

          @r_gigante said in OperatorSetData for "Lists"?:

          inexdata.InsertObject(sphere, 1)

          Thanks so much for your reply, I started getting way off track trying other methods lol! I got it working with:

          inexdata = c4d.InExcludeData()
              
              for i, obj in enumerate(children):
                  inexdata.InsertObject(children[i], 1)
                  
              node[1][c4d.GV_LINK_LIST] = inexdata
          
          1 Reply Last reply Reply Quote 0
          • esanE
            esan @r_gigante
            last edited by esan

            @r_gigante Another quick question. is there still a bug on c4d.GV_OBJECT_OPERATOR_OBJECT_OUT? I dont get object ports on my nodes when trying to add this and I saw it was a long standing bug.

            ...just saw notes that the bug was fixed in R21. But I (and the people ill be distributing this script to) are all on R20, is there any patch or easy workaround to getting Object ports showing up? This is the last step needed to finish my script!

            thanks

            1 Reply Last reply Reply Quote 0
            • r_giganteR
              r_gigante
              last edited by

              @esan said in OperatorSetData for "Lists"?:

              Another quick question. is there still a bug on c4d.GV_OBJECT_OPERATOR_OBJECT_OUT?

              Yes it's still there and being R20 maintenance ended it's likely to remain.

              Best, R

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