Input Groups from rhino document to gh, into a series of lists



Hi I’m looking for an easy and simple way to get rhino document groups into grasshopper with python, as a series of list containing geometry elements.

what i’m currently doing in the python component of gh is this:
if y:

rs,obj_ref = RhinoGet.GetMultipleObjects("Select object", False, ObjectType.AnyObject)
#print obj_ref

for ref in obj_ref:
    r= ref.Object()
    print r.Attributes.GetGroupList()[0]

After i can get for each element a reference for the group where it belongs and use it later with a grouping function, like groupby().
In this way i will get a series of lists containing all the elements with the same Attributes.GetGroupList() of each geometry, and iterate each list (group) to do what i need.

This might work but it looks very complicated, Any other ideas?
I have also seen this, Rhino.Input.Custom.GetObject() with the GroupSelect property set on True, but i’m not sure how to run the all series of commands, and if it will do what i need.



I found an easier way to iterate objects in python. that was actually quite simple to do in rhinoscript syntax.

I post it also if something quite similar is already around this forum in the script channel

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
import Rhino.Geometry as rg

sc.doc = Rhino.RhinoDoc.ActiveDoc


for i in range(rs.GroupCount()):

#print gnames[i]
for j,id in enumerate(group):
     """from here you start interating in the groups"""