Grasshopper

algorithmic modeling for Rhino

Construct a Tree or List<List<>> form one GH input parameter

Hi,

I have two collections of Breps as shown in the attached image. (One contains 1 object the other one two). Both are plugged into the x input of the second component. Inside this component I would like to be able to construct either a Tree with two branches or a List<ListBrep>> where one List contains one object and the other two.

However, Grasshopper seems to flatten whatever it gets in x to just one list that lost the hierarchy that I mentioned above.

When x is set to item access - the following does not work:

private void RunScript(object x, ref object A)
{

IEnumerable objEnum = x as IEnumerable;
foreach (object item in objEnum)
{
IEnumerable enumerable = item as IEnumerable;
foreach (object obj in enumerable)
{
DoSomething((Brep) obj));
}
}

...}

Similar for List access.

With Tree access x becomes a tree with one branch and three objects.

Is there any way to get the above mentioned hierarchy without creating a tree structure before the Breps get plugged into x?

Thanks a lot in advance,

Tim

Views: 485

Attachments:

Replies to This Discussion

Hi Tim,

If the paths of those two lists are the same, then they will be merged inside the x parameter before the script even gets a chance. I'd use the [Entwine] component to create this tree, no scripting required.

--

David Rutten

david@mcneel.com

Tirol, Austria

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2025   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service