Returning a List from a funtion which also takes a List as an input

I am constructing a function that would take an array(list) as its argument(input) and returns another array. On calling the function the code shows a warning and returns null. The warning says “Converting an array to var would cause array rank reduction and is not permitted”.
However, the same function works fine if only one single element is given as a return. I am attaching screenshots of the function for reference. Can someone tell me what is wrong?

The Screenshot:-

Hello Shivam,

In your function definition, you are calling : var[] which forces the function to call itself at the rank value of 1. If you are looking for a list, then try changing that to : var[]..[] which allows arbitrary rank.

As shown below:
image d

You can find more information on DesignScript here: https://dynamobim.org/wp-content/links/DesignScriptGuide.pdf

3 Likes

Hello Sol Amour,
Thanks for clearing the doubt on ranks. The function is working now as needed.
The new function:

def func : var[]..[](IN : var[]..[])
{
geo[0] = Autodesk.Geometry.Circle.ByCenterPointRadius(IN[0],IN[1]);
geo[1] = Autodesk.Geometry.Line.ByStartPointEndPoint(IN[0],IN[2]);
return geo;
};
1 Like