Dynamo 2.0 duplicates ports of custom node when file is saved and reopened?

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]”,“String [Item]”,“String [Item]”)]
[InPortDescriptions(“Streams [List]”,“Stream ID [Item]”,“Stream Name [Item]”)]
[OutPortNames(“S”,“Ls”,“Os”,“Ds”)]
[OutPortTypes(“Stream [Item]”, “Layer [List]”, “Object [List]”,“Dictionary [List]”)]
[OutPortDescriptions(“Stream [Item]”, “Layers [List]”, “Objects [List]”,“Dictionaries [List]”)]

public class Stream_Node : NodeModel
{
    public Stream_Node()
    {
        RegisterAllPorts();
    }

    public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
    {
        var functionCall = AstFactory.BuildFunctionCall(
            new Func<Stream, List<Layer>>(Receive),
            new List<AssociativeNode>() { inputAstNodes[0] });

        return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), functionCall) };
    }       

}

Best, Eckart

@Eckart-S when implementing a nodeModel node in Dynamo 2.0 you must write a json constructor - you can look at some of our nodeModels as a guide- we’ll be releasing some developer docs on this in the near future.

@Racel FYI.

1 Like

Thank you very much Michael, I will have a look and try things out later.
The dictionary features of 2.0 are really helpful for my plugin so supporting 2.0 will be the key.

Best, Eckart

Dear @Michael_Kirschner2 & @Racel

I tried a couple different things but I don’t think the missing Json Constructor is the reason why the duplicated ports are produced for custom nodes residing in external dlls. Other custom nodes from different authors seem to have this issue as well, so this might be a global issue / bug?

The internal ColorRange node seems to work in Dynamo 2.0 but maybe this is due to the different environment, e.g. namespace, internal-only classes / parameters, etc.?

I put a VERY simple external custom node here that just forwards strings:

Can you have a look if you encounter the same issues (duplicating ports) with this and if you can figure out what is wrong? What could be the issue here apart from the new Json Constructor in Dynamo 2.0?

Before saving it looks like this:
image

After saving and reopening the Dynamo file it looks like this:
image

Thank you very much!
Best regards, Eckart

Hi @Eckart-S - I see that you are referencing a different version of json.net than dynamo does, I also see that you deliver this other version with your package. This is almost surely the problem. Likely both versions of json.net are loaded into the current app domain, and then when json.net attempts to find the [jsonConstructor] attribute it fails to find the one on your constructor method as equal.

Try either referencing an 8.0 version of json.net (I think we use 8.03) and/or do not deliver json.net with your package, it will already be loaded by dynamo.

If this is the case we will document this throughly, and thanks for trying out 2.0.

1 Like

Ah I think that solves the big mystery.
I did a very quick test with 8.03 and it seems to work. Will try more properly later.

I think most people will just use NuGet and install the newest version of json - v8 is pretty old :slight_smile:

Are there other requirements or recommendations regarding versions to keep in mind? E.g. which .NET version to use, etc.?

Thanks a lot for the hint Michael!

Hi @Eckart-S we will update the docs with a version to use and hopefully we will change our nugets to include a dep on the right version so it should just work and be available when you reference dynamo nugets.

Ok cool. Thanks a lot! :slight_smile:

Hi @Eckart-S This is fixed in https://github.com/DynamoDS/Dynamo/pull/8860, and you should be able to see it become in effect in nugets starting from 2.0.1.4955 at https://www.nuget.org/packages/DynamoVisualProgramming.Core/2.0.1.4955. NewtonSoft.Json should be referenced automatically for you in the future which use same version DynamoCore is depending.

Cheers

2 Likes

I just wanted to bump the solution for anyone experiencing the multiple output ports problem.

I can now also confirm that ‘downgrading’ to Newtonsoft Json version 8.03 worked!

Hope this helps someone.

Michael

Similar problem encountered here - turns out Visual Studio was interpreting the [JSONConstructor] attribute as belonging to System.Text.JSON, not Newtonsoft.

2 Likes