Node model has duplicate In/Outputs when script reloaded

Hello dear Dynamo users,

I am developing some custom nodes for my colleagues (C#). Nodes are developed with NodeModel approach NodeModel Case Study - Custom UI · GitBook and work with Civil3D.

Version of Dynamo:

I works quite well except one thing. If I close .dyn file with some node from my plugin and then reopen nodes in from my package have duplicated input and outputs. See image below.

It is quite inconvenient as those nodes needs to be delete, inserted and wire again. Code for node model is bellow. View is not rewritten at all. No other plugins are installed.

using System;
using System.Collections.Generic;
using Dynamo.Graph.Nodes;
using Dynamo.Models;
using ProtoCore.AST.AssociativeAST;
using Autodesk.DesignScript.Geometry;

using CheetahNodeModelFunctions;

namespace CheetahNodeModel
{
    [NodeName("StationingAnnotations")]
    [NodeDescription("Generate stationings marks along alignment")]
    [NodeCategory("Annotaions")]
    [InPortNames("AlignmentName", "ProfileName", "Stationings", "Elevation", "TextHeight", "TextStyle")]
    [InPortTypes("string", "string", "double[]", "double", "double", "string")]
    [InPortDescriptions("Name of alignment", "Name of profile which belongs to alignment", "Stationing range for position calculation", "Elevation above the alignment for text positioning", "Text height", "Text style")]
    [OutPortNames("Result")]
    [OutPortTypes("bool")]
    [OutPortDescriptions("True on succes false on fail")]
    [IsDesignScriptCompatible]
    public class StationingAnnotationsNodeModel : NodeModel
    {     
        public StationingAnnotationsNodeModel()
        {
            RegisterAllPorts();
        }
        public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
        {
            if (!InPorts[0].Connectors.Any() || !InPorts[1].Connectors.Any() || !InPorts[2].Connectors.Any() || !InPorts[3].Connectors.Any() || !InPorts[4].Connectors.Any() || !InPorts[5].Connectors.Any())
            {
                return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), AstFactory.BuildNullNode()) };
            }
            var functionCall =
              AstFactory.BuildFunctionCall(
                new Func<string, string, List<double>, double,double,string, bool>(StationingAnnotationsNodeFunctions.CalculateStationings), 
                new List<AssociativeNode> { inputAstNodes[0], inputAstNodes[1], inputAstNodes[2] , inputAstNodes[3], inputAstNodes[4], inputAstNodes[5] });

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

Thanks for any help and reply

Best

Ondřej Janota

1 Like

Everytime I have seen this is has been due to a dependency conflict with newtonsoft or another component which Dynamo itself leverages, usually from a Revit add-in.

Some things to try:

  1. Can you replicate the issue in Dynamo core? If so check your Dynamo log from core to see which references are indicating a conflict.
  2. If you can’t replicate in core, disable ALL your Revit customizations and see if that resolves the issue. If so, add them back in small groups until youf ind the conflict. You can also check your Revit journals for clues around which add-ins are causing the conflict.

Hi @jacob.small,

thanks for reply. I am new to Dynamo development, so I would appreciate more detailed info. What do you mean by Dynamo core. I do not use Revit at all, but I have it installed in my PC. I am using Dynamo under Civil3d.

Thanks for more details

Ondřej

Hi @ondrej.janota,

You need to add a JSON constructor. See below:

2 Likes

Thanks for advice. It seems to work.

Best

Ondřej

1 Like