Use Custom Node inside Zero Touch Node

Hi!
I want my zero touch node to use a custom node. I tried to enter the custom node as a delegate function to my zero touch node, but it didn’t work.

Here’s a snapshot of what I am trying to do:

However, it gives me this error

Warning: Covid19.SCH_Example expects argument type(s) (int, double[][], double[], double[], System.FuncOfListOfListOfDoubleAndListOfDouble), but was called with (int, double[], int[], int[], Function).

My ZT node expects FuncOfListOfListOfDoubleAndListOfDouble but receives Function.

My zero touch node have this code:

    public static List<List<double>> SCH_Example( int limit,
        List<List<double>> initValues,
        List<double> lowerLimits, List<double> upperLimits,
        Func<List<List<double>>, List<double>> fitFunction)
    {
               return new List<List<double>>();
    }

In other word, How to input a custom node as a parameter to my zero touch node? I want to make something like whileLoop found on Dynamo.

Thanks a lot…
@Michael_Kirschner2
@GavinCrump
@Dimitar_Venkov

The SCHFitnessFunction-1 node has a missing input, and as such is in a function state (note the lighter grey color). Add the required input and you should get the info you need.

@JacobSmall
Hello Jacob. Thanks for replying…
Unfortunately, this doesn’t work.

I need the the last input to be a function reference that I could use inside my ZTN, not a function output.

Here’s the error it gave me.

Looks like the object type returned by the SCH Fitness Function-1 node is a double, but your Covid19SCH_Example node is expecting something else.

Did you create the fitness function node as well? if so consider migrating that over to a zero touch node so that it returns the custom data type you’re using in your zero touch node (System.FuncOfListOfListOfDoubleAndListOfDouble to be precise).

Thanks again.

Actually, this is something I was trying to avoid… I wanted the user to define his custom logic as a custom node and then input it as a parameter to my ZTN.

I could make this custom node as another method inside my code, but this will not serve me on the long term.

LoopWhile node receives Function Object as a parameter to loopBody and continueWhile inputs… I want to make something exactly like loopWhile

Ah! I am not aware of a way to consume a function with a ZT node… The object type would likely need to be a dynamo function rather than the custom object type which you’re using now.

There may be a few options other for the process you’re working though (pass your node as a Dynamo function into something which consumes the design data) but without seeing more of the overall scope it’s hard to say.

1 Like

to do this, you’ll need to implement your node that same way map or loop while are implemented - with designscript:

the issue is that the DS functionObject needs to be marshaled to a c# delegate to be called in your ZT node - but thats not easy to do - what if the function is pointing to DS code, .net won’t know how to marshall that or execute it.

2 Likes

Thanks

Indeed, .Net will not be able to execute the ds code.
I think I’m done with this problem… Thank you

1 Like