Creating a custom C# component


#1

Hi All,

I am trying to create a custom C# component by I have no luck. Here is my code below. It compiles with no problem but I cannot load it into Dynamo. Any ideas why?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Microsoft.FSharp.Collections;
using Dynamo;
using Value = Dynamo.FScheme.Value;

using Dynamo.Core;
using Dynamo.Controls;
using Dynamo.Models;
using Dynamo.Revit;
using Dynamo.Utilities;
using Dynamo.UI;
using Dynamo.UI.Prompts;
using Dynamo.ViewModels;
using Dynamo.Nodes;
namespace SMARTDynamo
{
[NodeName(“Value.Compare”)]
[NodeCategory(BuiltinNodeCategories.CORE_SCRIPTING)]
[NodeDescription(“Returns the maximum of two give numbers.”)]

class MyFirstNode : NodeWithOneOutput
{
public MyFirstNode()
{

InPortData.Add(new PortData(“A”, “A number to compare”, typeof(FScheme.Value.Container)));
InPortData.Add(new PortData(“B”, “A number to compare”, typeof(FScheme.Value.Container)));

OutPortData.Add(new PortData(“Max”, “The greater of the two inputs”, typeof(FScheme.Value.Container)));
RegisterAllPorts();
}

public override Value Evaluate(FSharpList<Value> args)
{
double a = (double)((FScheme.Value.Number)args[0]).Item;
double b = (double)((FScheme.Value.Number)args[1]).Item;
double c = Math.Max(a,b);

return FScheme.Value.NewContainer©;
}
}
}

All the best,

-Miguel


#2

This sample node is for Dynamo .63… The evaluate method if the giveaway :slight_smile:

check these links for .7 development

 

Or were you trying to make a .63 node?

 


#3

Thanks, I think this is more than enough to get me started.

 

-Miguel

 

PS. I was trying to get something working tor the last version of Dynamo 7.1.2