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

