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

    Port Creation

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 600 Views
    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.
    • H Offline
      Helper
      last edited by

      On 03/10/2013 at 08:59, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   14.038 
      Platform:   Windows  ;   
      Language(s) :       PYTHON  ;

      ---------
      I'm working on a script that creates nodes in XPresso and ran into a snag. I cant seam to get the GV_OBJECT_OPERATOR_OBJECT_OUT to work. So far all the other nodes create just fine.

      What I want is the object node Object Out port to connect to a point node Object In port.

      Ive tried using the .SetPortType to change a port that will create into the object port. However I'm not sure im setting it up correctly.

      node_obj1.SetPortType(c4d.GV_PORT_OUTPUT, c4d.GV_OBJECT_OPERATOR_OBJECT_OUT)

      Any help would be great!

      Let me know if I'm not explaining myself well enough.

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 07/10/2013 at 08:53, xxxxxxxx wrote:

        Ok so here is an example I am able to show. using a null as a selection run this script:

        import c4d
        from c4d import gui
        #Welcome to the world of Python
          
          
        def main() :
            
            # Create Tag
            tag = c4d.BaseTag(c4d.Texpresso)
            # Add Tag
            op.InsertTag(tag)
            #Get the node master of selected xpresso tag
            nm = op.GetFirstTag().GetNodeMaster()
            #Create the object's node
            node1 = nm.CreateNode(nm.GetRoot(),c4d.ID_OPERATOR_OBJECT,insert=None, x=20, y=20)
            node2 = nm.CreateNode(nm.GetRoot(),c4d.ID_OPERATOR_POINT,insert=None, x=20, y=70)
            # Create Ports
            pObjOut = node1.AddPort(c4d.GV_PORT_OUTPUT, c4d.GV_OBJECT_OPERATOR_OBJECT_OUT)
            pNorOut = node2.AddPort(c4d.GV_PORT_OUTPUT, c4d.GV_POINT_OUTPUT_NORMAL)
            
            # Test Ports
            print pObjOut
            print pNorOut
            return None
            
            
        if __name__=='__main__':
            main()
        

        You will see that It will print none for the object port but for the output of the point node normal a port is created.

        How can I get this Object Out port to work?

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 08/10/2013 at 07:24, xxxxxxxx wrote:

          So I found a way to bypass the Object Out port not working by adding a userdata Link. THis is what it looks like after the script is run:

          _<_img src="http://shawnfrueh.com/references/c4d/nodebroken.png" height="371" width="509" border="0" /_>_

          As you can see something is not right. So I did a little R&D and found that creating the port itself through python breaks the object node. I can drag and drop the Spline object into XPresso and add the user data manually like this:

          <_<_img src="http://shawnfrueh.com/references/c4d/nodeworking.png" height="371" width="509" border="0" /_>_" />

          Everything works fine then.

          This is the code I used to create the port that then breaks the node:

          objPort = node_obj1.AddPort(c4d.GV_PORT_OUTPUT,(c4d.ID_USERDATA,1),message=True)
          

          Am I setting up the .AddPort wrong?

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 08/10/2013 at 14:06, xxxxxxxx wrote:

            Hi.
            I had this problem recently and found something on the web that should do the trick:

            objPort = node_obj1.AddPort(c4d.GV_PORT_OUTPUT, c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA, c4d.DTYPE_SUBCONTAINER, 0), c4d.DescLevel(1)), message=True)
            

            Where the id of the userdata is described with "c4d.DescLevel(1)" for the first userdata. As I said I found it on the web and I don't quite get it myself, but it seems to work.
            Cheers
            Phil

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 08/10/2013 at 14:44, xxxxxxxx wrote:

              Thanks Phil! That did the trick! I appreciate the help. 🙂

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