I’ve created some dropdown nodes that inherit from DSDropDownBase
and the issue I’m having is that an extra output port is created every time the graph is saved and reopened. Also after saving and reopening, an exception is thrown saying that “an element with the same key but different value already exists.” Any ideas?
While this is admittedly a pretty cool trick I’ve stumbled upon (who doesn’t want a node that evolves over time?), it’s not what I was going for
public class DropDownExample : DSDropDownBase
{
public DropDownExample() : base("item"){}
// Starting with Dynamo v2.0 you must add Json constructors for all nodeModel
// dervived nodes to support the move from an Xml to Json file format. Failing to
// do so will result in incorrect ports being generated upon serialization/deserialization.
// This constructor is called when opening a Json graph. We must also pass the deserialized
// ports with the json constructor and then call the base class passing the ports as parameters.
[JsonConstructor]
public DropDownExample(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base("item", inPorts, outPorts) { }
protected override SelectionState PopulateItemsCore(string currentSelection)
{
// The Items collection contains the elements
// that appear in the list. For this example, we
// clear the list before adding new items, but you
// can also use the PopulateItems method to add items
// to the list.
Items.Clear();
implement a json constructor that reuses the deserialized ports from the .dyn file.
5 Likes
Thanks Michael! That did it.
For future readers, this old post is helpful for background info. Should’ve searched a little harder before I posted.
When I use my custom nodes (external dll - works properly in 1.3 without issues) in Dynamo 2.0, save the dyn file and reopen it the ports seem to duplicate every time?
[image]
Did someone else have this problem, too?
Any idea what could be wrong or different in 2.0?
The code is pretty standard and looks like this:
[IsDesignScriptCompatible]
[NodeName(“Stream”)]
[NodeDescription(“Stream node.”)]
[NodeCategory(“XXX.Streams”)]
[InPortNames(“Ss”,“I”,“N”)]
[InPortTypes(“Stream [List]”,“Stri…
1 Like