I’ve created some dropdown nodes for my package and they are disconnecting when saving/reopening a graph. Here’s what gets recorded in the log.
Any advice? I inherited from DSDropDownBase like this example and made sure to include the JSON constructor, but I’m wondering if I still missed something to make sure that the ports get serialized.
By inheriting from DSDropDownBase, does that mean that I don’t have to register the ports separately?
// you can populate the InPorts and the OutPorts
// collections with PortData objects describing your ports.
// Nodes can have an arbitrary number of inputs and outputs.
// If you want more ports, just create more PortData objects.
OutPorts.Add(new PortModel(PortType.Output, this, new PortData("upper value", "returns a 0-10 double value")));
OutPorts.Add(new PortModel(PortType.Output, this, new PortData("lower value", "returns a 0-100 double value")));
// This call is required to ensure that your ports are
// properly created.
RegisterAllPorts();
// The arugment lacing is the way in which Dynamo handles
// inputs of lists. If you don't want your node to
// support argument lacing, you can set this to LacingStrategy.Disabled.
ArgumentLacing = LacingStrategy.Disabled;
// Set initial slider value.
sliderValue = 4;
}
I figured it out. I was just missing the inPorts
and outPorts
parameters in the method signature for the base class. So I had:
public DropDownBase(string outputName, IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(outputName)
instead of:
public DropDownBase(string outputName, IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(outputName, inPorts, outPorts)
Turns out all I needed was a good night of sleep and fresh eyes
2 Likes