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

    Reading variadic ports with GetPorts always has a port

    Cinema 4D SDK
    c++
    2
    2
    462
    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.
    • B
      bojidar
      last edited by bojidar

      Hi
      Currently we iterate over variadic ports with variadicPort.GetPorts but it seems to always have one default port ("#") when all variadic children are cleared. I guess that is expected behaviour so is there some safe way to know when to ignore the port? Can we simply check if the id of the port is "#"? Or should we think about using a different approach e.g. somehow calling GetChildren on a maxon::GraphNode which at first glance seems to work?

      With the example gradient node after clearing all knots in the first ramp I get something along the lines of:

      maxon::nodes::PortList portList = maxon::nodes::ToPortList(gradientBundle)
          iferr_return;
      for (auto portResult : portList.GetPorts())
      {
          WarningOutput(portResult.GetValue().ToString(nullptr));
      }
      gradientnode@R9OPuVzGMZ5nE94TL6Qp2q<firstbundle/#
      gradientnode@R9OPuVzGMZ5nE94TL6Qp2q<secondbundle/_0
      gradientnode@R9OPuVzGMZ5nE94TL6Qp2q<secondbundle/_0
      
      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @bojidar
        last edited by ferdinand

        Hey @bojidar,

        I would suggest that you write a mail about this, so that I can forward it. All I can tell you is that for variadic ports all bets are off. I really ran into this issue when I had to handle variadic ports for graph descriptions.

        When you instantiate a node with variadic ports, it usually has some default children. I have never tried what happens when you try to remove all ports (graph description can do this, but they then do not test if the system does not regenerate them). There is also no guarantee that the 1st variadic port has the ID _0. It is just a convention, which is for example directly borken by the Standard Renderer Material node, as it gives its first BSDF layer port the ID 1, and the 2nd manually created layer then the ID _0 (because of course it does):

        76bb0bfe-ff1f-4530-a55c-059bc195e46b-image.png
        1aa63fb8-e9dc-4e83-80b6-7ffa782752af-image.png

        You really have to write a mail here, because this is so deep in the Nodes API internals, it requires a true specialist to answer it.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

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