How to output a double[,] ? (like a tree object?)


(Vapeurz) #1

Dear all,

In the c# component, I set an output named “y”, and

double [, ] mylist = new double [2,3];
and initiate mylist;
y = mylist;

but y is always a single list like double[], rather than a tree object double[,]

is there any way to set my output y to a tree list, or I have to arrange it using other component provided in grasshopper, I tried the later but I think it is a little bit trivial.

(Giulio Piacentino) #2

Probably the only working way would be to directly construct a DataTree from scratch.

(David Rutten) #3

If you want to output a tree, your only option is to create an actual DataTree. GH1 is not smart enough to convert nested arrays or multi-dimensional arrays into trees.

(Vapeurz) #4

Thanks! is there a way to just output a 2d array?

(David Rutten) #5

Any data you output, if it isn’t already of type IGH_Goo, will be interpreted by Grasshopper and converted (if possible) into a known type. Anything which provides an IEnumerable interface will be converted into a collection. If you want to maintain your 2D array, you must wrap it into a GH_ObjectWrapper before outputting it, that will prevent GH from trying to inspect and convert it.

(Vapeurz) #6

Many thanks! Good to know!:grinning: