Creating Xpresso Python Node Inputs
-
Hello,
I'm having a hard time finding documentation about accessing the input ports for the Python Xpresso node, specifically the 'On' port. I know aboutop.GetInPorts()
, but it isn't returning anything. How could I add any of these data types for that matter? Where would I find the IDs for them?pythonNode = gv.CreateNode(gv.GetRoot(), 1022471, insert=None, x=200, y=0) #Create python node onId = c4d.DescID(c4d.DescLevel(?????)) pythonNode.AddPort(c4d.GV_PORT_INPUT, onId)
Thank you!
-
Hello
onId = c4d.DescID(c4d.DescLevel(3999,400006001,1022471))
-
@iluxa7k said in Creating 'On' Python Xpresso Node Input:
onId = c4d.DescID(c4d.DescLevel(3999,400006001,1022471))
Hi @iluxa7k , thank you for the reply! May I please ask, how did you find this DescID? How can I find the other ports'?
-
For future people reading this post, I found answers in the C++ documentation for the GV_PYTHON_OPENEDITOR file reference.
''' In this DescID: c4d.DescID(c4d.DescLevel(3999,400006001,1022471)) 3999 is the ID for the parameter (GV_PYTHON_ON) 400006001 is the ID for the Data type (ID_GV_DATA_TYPE_BOOL) 1022471 is the Python Tag Id ''' onId = c4d.DescID(c4d.DescLevel(c4d.GV_PYTHON_ON,c4d.ID_GV_DATA_TYPE_BOOL,1022471)) longId = c4d.DescID(c4d.DescLevel(c4d.IN_LONG,c4d.ID_GV_DATA_TYPE_INTEGER,1022471)) linkId = c4d.DescID(c4d.DescLevel(c4d.IN_LINK,c4d.DTYPE_BASELISTLINK,1022471)) xnode_python.AddPort(c4d.GV_PORT_INPUT, onId) xnode_python.AddPort(c4d.GV_PORT_INPUT, longId) xnode_python.AddPort(c4d.GV_PORT_INPUT, linkId)
I do still have questions about how I'd find the DescIDs of this node's parameters through Python if anyone wants to chime in. Thank you.
-
Hi unfortunately I didn't found a precise way (except looking into the C++ header file as you did) to find possible IDs.
Another way could be to add ports you want to add to a node and then from this GvNode you can retrieve all GvPort and their ID. Find an example that iterates all input ports remove them and re-add themimport c4d def main(): if not op: return xpressoTag = op.GetTag(c4d.Texpresso) if not xpressoTag: return gvMaster = xpressoTag.GetNodeMaster() gvRoot = gvMaster.GetRoot() gvNode = gvRoot.GetDown() ports = gvNode.GetInPorts() portDescIds = [] for port in ports: print port.GetName(gvNode), port.GetMainID(), port.GetValueType() portDescIds.append(c4d.DescID(c4d.DescLevel(port.GetMainID(), port.GetValueType(), port.GetNode().GetOperatorID()))) port.GetNode().RemovePort(port, True) print portDescIds for portDescId in portDescIds: gvNode.AddPort(c4d.GV_PORT_INPUT, portDescId) c4d.EventAdd() # Execute main() if __name__=='__main__': main()
Cheers,
Maxime. -
@m_adam That's a great solution, thank you!