Zerotouch - How to set a default input for a List of ...?

Hey guys,

I have a question about setting default inputs for zerotouch nodes. In my projects it can sometimes be convenient to have some predefined default input, so that the user need not plug something into that port. Does anyone know how to do that?

For instance below I can set the string Description to an empty string, but how could I set the curve list to an empty curve list?

Thanks!

        public static List<object> ExampleCode(List<Autodesk.DesignScript.Geometry.Curve> Curves, string Description = "")
        {
            List<object> ObjectToReturn = new List<object>();
            //code here
            return ObjectToReturn;
        }

Curves = null should do the trick?
or

public static List<object> ExampleCode(List<Autodesk.DesignScript.Geometry.Curve> Curves = new List<Autodesk.DesignScript.Geometry.Curve>() , string Description = "")
    {
        List<object> ObjectToReturn = new List<object>()
        //code here
        return ObjectToReturn;
    }

I could do Curves = null yes, but that won’t result in the Dynamo node functioning when there is nothing connected on that port.

But thanks for the suggestion! Any other ideas?

you can use the default argument attribute to execute a snippet of ds code.

or you can use a default token - which you check for in your code, ie, something like null - but not null (since that is a special type) which dynamo interprets as nothing being connected.

it will work if you use null from inside a default argument attribute though.

4 Likes

Hi Michael!

That seems to work but I get the message the default value is disabled?

What I have now:

        public static List<object> ExampleCode([DefaultArgument("Autodesk.DesignScript.Geometry.Point.ByCoordinates(0, 0, 0)")]Autodesk.DesignScript.Geometry.Point Points, string Description = "")
    {
        List<object> ObjectToReturn = new List<object>();
        //code here
        ObjectToReturn.Add(Description.ToString());
        return ObjectToReturn;
    }

[edit] I see now there was already a topic on this:

I didn’t realize you could right click the port to enable this. Is there a way to enable this by default?

1 Like

I believe it should be on by default - if you add a new instance of that node from the library is it still disabled?

This normally happens if you save a graph with your ZT node in it and recompile a new version of the node with either new default inputs or change an existing input to have a default input; when you reopen the graph, the default value will not be automatically set.

4 Likes

Hi Thomas,

You are right, this was what was happening. Thanks!

Thanks guys for the solution, this is working really well now :slight_smile: