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?

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.

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.

4 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.