Get the objects in group without ungrouping or changing the group structure in Grasshopper

Hi,

Is there any way to get the objects (the geometries) in a group in Grasshopper without ungrouping them? I am grouping objects (geometries) for modeling purposes but now I need to get access to those objects (geometries) without modifying the group structure. Would really appreciate a solution.

Thanks!

You can, ungroup, edit, regroup. All by keeping original groups structure.

Can you attach some minimal and internalized) example of your situation?

Actually, I was trying to avoid ungrouping actually. Thanks!

See if this is any useful…

2021-05-05 00_24_07-Window
group extractor.gh (6.1 KB)

Implementation not tested, code needs to be fixed depending on item/list/tree structure of “G” and “i” inputs…
Currently performance is trash as it exponentially waste resources as is the number of groups.
Code just as proof of concept:

  private void RunScript(object G, int i, ref object O)
  {
    Grasshopper.Kernel.Data.IGH_Structure data = this.Component.Params.Input[0].VolatileData;
    for(int j = 0; j < data.DataCount; j++){
      Grasshopper.Kernel.Types.GH_GeometryGroup g = (Grasshopper.Kernel.Types.GH_GeometryGroup) data.get_Branch(0)[0];
      O = g.Objects[i];
    }
  }
1 Like

Let me try this one but yes, wondering about the same thing - what would happen if the group has multiple branches in one tree. Thanks a lot!