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

    Creating Xpresso Python Node Inputs

    Cinema 4D SDK
    s22 sdk python
    3
    6
    1.4k
    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.
    • ?
      A Former User
      last edited by A Former User

      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 about op.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?

      PythonXpressoNode.png

      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!

      1 Reply Last reply Reply Quote 0
      • I
        iluxa7k
        last edited by

        Hello

        onId = c4d.DescID(c4d.DescLevel(3999,400006001,1022471))
        
        ? 1 Reply Last reply Reply Quote 1
        • ?
          A Former User @iluxa7k
          last edited by

          @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'?

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User
            last edited by A Former User

            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.

            1 Reply Last reply Reply Quote 0
            • M
              m_adam
              last edited by

              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 them

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

              MAXON SDK Specialist

              Development Blog, MAXON Registered Developer

              ? 1 Reply Last reply Reply Quote 1
              • ?
                A Former User @m_adam
                last edited by

                @m_adam That's a great solution, thank you!

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