Reading variadic ports with GetPorts always has a port
-
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
-
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 ID1
, and the 2nd manually created layer then the ID_0
(because of course it does):
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