Is there a way to reference rhino group to grasshopper?

Hi,

Is there a way to reference rhino group to grasshopper?
When referencing rhino objects as guid it only references one object at a time.
If it is not possible to do with native grasshopper components how it could be done via rhino-common?

1 Like

Hey Petras

Could you elaborate on what exactly you are trying to do?
Simply reading your question, it sounds like what you’re looking for is right clicking the component and selecting “Set Multiple Guids”. (I should mention that you can also use a Brep, Curve, Geometry, Mesh, or even another component to do the same.)
Alternatively, you could also use the Geometry Pipeline, if the objects you wish to select are on the same layer and/or have distinct names.

I hope that helps a little.

Hi,

Steps I have:

  1. Draw two boxes in Rhino. 2. Ctrl+G to group them.
    Then
    I want to reference them in rhino but instead of one object 2 objects are referenced as guid.

More simply I would like to keep track of grouped rhino objects in order to create nested array of objects.
For instance:

There is no such container object type called group that would do what you want.

Yup, that is the reason I am asking what would be an approach to do this with rhinocommon.
Do I need to loop through all objects in Rhino Object List and find their group id? is there any reference to this?

I do not see any other method than to go through all the objects.

  private void RunScript(ref object A)
  {
    var groups = from o in RhinoDoc.ActiveDoc.Objects
                 group o.Id by o.GetGroupList()[0];
            
    var tree = new DataTree <Guid> ();
    foreach( var g in groups ) tree.AddRange(g.Select(id => id), new GH_Path (g.Key));
  
    A = tree;
  }

image

@DavidRutten, it is strange, why the CastFrom don’t work in this case:

  private void RunScript(ref object A)
  {
    var groups = from o in RhinoDoc.ActiveDoc.Objects
                 group o.Id by o.GetGroupList()[0];


    var ghgroups = new List<GH_GeometryGroup> ();
    foreach( var g in groups )
    {
      var ghg = new GH_GeometryGroup ();
      ghg.CastFrom(g.ToArray());
      ghgroups.Add(ghg);
    }

    A = ghgroups;
  }

image

Thank you.
jmv

You answered all my questions:) Thanks.

1 Like

Rhino Groups are stored as attributes; every object can have a collection of Group Indices which indicates which group it belongs to. As long as you have a reference to the objects that are grouped, you can retrieve their group indices in GH with Human with the Object Attributes component. Then use Assign Paths to separate them into branches, and even create grasshopper group objects from there if you want.

5 Likes

sorry to resurrect.

where can i find the Assign Path component?

image
-wim

my install doesn’t have it?

Nope, you need Treefrog…

-w

got it, installed the wrong version. thank you.

Hi Andrew,

I’ve tried your method and it works well, but there’s something I want to do and I haven’t found any way. Do you know how to set a name for each group? I’m triying to asign a name because I have a script that create a layout for each group in the drawing named as the group, it is extremely useful when you need to print a lot of layouts, and this help to keep everything in order and named.

Thanks!

I didn’t even know groups could have names! Here’s a couple scripts to get and set the name of a group by its index. Set and get group names.gh (9.4 KB)

3 Likes

Thank you very much!! It works great! I’ve been looking for a while but didn’t found anything.
I’ve tested the scripts and works perfect.

Thanks a lot!