OperatorSetData for "Lists"?

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

    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)

  • 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:
        # assume the cube has an Xpresso Tag
        xpresso = cube.GetTag(c4d.Texpresso)
        if xpresso is None:
        nm = xpresso.GetNodeMaster()
        if nm is None:
        # assume the graphview contains a LinkList node
        linklist = nm.GetRoot().GetDown()
        if linklist is None or linklist.GetType() != 1001101:
        # allocate the iInExcludeData
        inexdata = c4d.InExcludeData()
        # add the object
        inexdata.InsertObject(sphere, 1)
        linklist[c4d.GV_LINK_LIST] = inexdata

    Best, Riccardo

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

  • @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!


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

Log in to reply