ZT node error: Dictionary.ValueAtKey expects argument type

Hey guys,

I have a question regarding the MultiReturn attribute. I use it to rename the output of a ZT node, but apparently, when nothing is connected on the ‘DynamoPointList’ input, i get this error:

Warning: Dictionary.ValueAtKey expects argument type(s) (Dictionary, string), but was called with (Function, string).

The node works fine when Dynamo points are input.

My code looks like this:

    [MultiReturn(new[] { "ModelData" })]
    public static Dictionary<string, List<object>> Node(IEnumerable<Autodesk.DesignScript.Geometry.Point> DynamoPointList, string Support = "YYYYYY")
    {
        //stuff happening here
        return new Dictionary<string, List<object>>
            {
                { "ModelData", Arcadis_Nodes_object }
            };
    }

Does anyone have an idea how to solve this?

Or is there another/better way to rename output?

Thanks!

Only use a dictionary/multi output port node if you have multiple outputs rather than using them as a hack. Dynamo reroutes dictionary values to the ports and single keys cause exceptions. Plus you’re going to end up adding another rank to your list unnecessarily and force users into circumventing the problem you’ll create using lacing aimlessly. If you correct it in the future (by reverting to a list as your return type), you’ll break every graph where it’s used so always get the basics right from the outset. Use the return statement followed by the object you want to return (not a new dictionary obviously!) for single output ports.

If you want to rename the output port add XML documentation to your project. Once added, type a triple slash above your method to add the tags. You’ll see a tag called <returns></returns> - insert the name property and recompile. Eg <returns name = “something”></returns>

1 Like

That works well!

Thanks for the help :smiley: