Hello,
I’m attempting to create a very simple custom NodelModel, but with no success, an Error: Dereferencing a non-pointer keeps apperaing. Dynamo version: 1.0.0.1180.
If no input is connected, the node shows gray as normal, but if two numbers are connected as input I get:
I’ve been following the same structure of other Dynamo nodes, so I cannot explain myself what’s wrong or missing. The node simply multiplies two numbers, below the full code:
using System;
using System.Collections.Generic;
using Dynamo.Graph.Nodes;
using ProtoCore.AST.AssociativeAST;
namespace TestNodeModel
{
[NodeDescription("Test Node")]
[NodeName("TestNode")]
[NodeCategory("TestCategory")]
[InPortNames("A", "B")]
[InPortTypes("double", "double")]
[InPortDescriptions("Number A", "Numnber B")]
[OutPortNames("Output")]
[OutPortTypes("double")]
[OutPortDescriptions("AxB")]
[IsDesignScriptCompatible]
public class TestNodeModel : NodeModel
{
public TestNodeModel()
{
RegisterAllPorts();
}
public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
{
if (!HasConnectedInput(0) || !HasConnectedInput(1))
{
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), AstFactory.BuildNullNode()) };
}
var functionCall =
AstFactory.BuildFunctionCall(
new Func<double, double, double>(DoCalc),
new List<AssociativeNode> { inputAstNodes[0], inputAstNodes[1] });
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), functionCall) };
}
public static double DoCalc(double a, double b)
{
return a * b;
}
}
}