Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
47 lines (43 sloc) 1.49 KB
using System;
using System.Collections.Generic;
using Dynamo.Graph.Nodes;
using HelloDynamo.Hello;
using ProtoCore.AST.AssociativeAST;
namespace HelloDynamo.HelloNodeModel
/// <summary>
/// Sample NodeModel
/// In order to execute AstFactory.BuildFunctionCall
/// the methods have to be in a separate assembly and be loaded by Dynamo separately
/// File pkg.json defines which dll are loaded
/// </summary>
[NodeDescription("Example Node Model, multiplies AxB")]
[InPortNames("A", "B")]
[InPortTypes("double", "double")]
[InPortDescriptions("Number A", "Numnber B")]
[OutPortDescriptions("Product of AxB")]
public class HelloNodeModel : NodeModel
public HelloNodeModel()
public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
if (!HasConnectedInput(0) || !HasConnectedInput(1))
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), AstFactory.BuildNullNode()) };
var functionCall =
new Func<double, double, double>(SampleFunctions.MultiplyTwoNumbers),
new List<AssociativeNode> { inputAstNodes[0], inputAstNodes[1] });
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), functionCall) };