Do you know what I am doing wrong?
It is originally a List<List>
Can I turn the object to a List<List> again?
202203191333Q.gh (19.6 KB)
Do you know what I am doing wrong?
It is originally a List<List>
Can I turn the object to a List<List> again?
This an annoying beauty of grasshopper because you did not input datatree of int. Grasshopper does not know what is a list of lists.
So you must cast them in the code from object to a list of int.
Or if you are lazy, create new c# component write A=x which will convert your lists to a datatree
How do you cast an object to a list of int in this situation?
Or is it in the business more usual to import things as datatrees? What means that I should have output the initial data as a datatree in the first place.
A=x; gives me the same input but than as an output.
Set input type object then iteratate lists and cast them i.e. var list = (List < int> )x[i];
I don’t understand System.Collectins.Generic.List
I think I have to do something with that.
Seems that you also need to iterate items and cast objects to int.
Also worth to test cast with keyword as.
There are bunch of answers here too:
Hi, do you have the origin data for List<List> ?
I did some casting test for you already, but seems like there’s no valid int inside.
Thanks
202203191334A.gh (10.7 KB)
grasshopper can’t output list of list or array of array directly otherwise you will get a list of objects. The right way is to use “DataTree” or “GH_Structure”.
Learn C# what else?
ListOfList.gh (13.9 KB)
BTW you can’t unbox “straight” an object in a collection - for more than obvious reasons.
BTW: Since long time you have the answer on hand (The catigator case and the likes). But long is the path (and hilly).
Your problem is mainly that you converted yout “object” into an actual string.
You probably did something like this:
Your “Data” parameter contains nothing more than a simple List of strings/texts.
Your “System.Collections.Generic.List`1[System.Int32]” object are just 47-character-long strings.
Thank you
forgive me, that is so stupid of mine… . I internalised it as a string thank you (me trying to fade out this blunder with emojis)
Wait … attached the wrong thing (blame the state of things in AMG W13 car [F1] that is a 100% pig > how Lewis can grab the 8th crown with this aero disaster ???).
I’ll attach the correct C# soon.
In the mean time get (again) a “general” (of some sort) case:
Collections_TheArtOfPointless_V1A.gh (123.4 KB)
For some hardcore machoists. If you like List of List of List of List of int you can wrap that collection into a Tuple of List of List of List of List of int … This allows you to pass it from one component into another as a single object. All you need to do then is cast that single object into a Tuple of List of List of List of List of int and access the collection item.
Not quite so: what if the World is NOT made solely from R/GH? (thus DataTrees are more or less … blah, blah)