Loop over Groups in Python

Hello All,

I would like to ask if is possible to loop over a selection of groups?

for group in groups:
ā€¦

Ultimately, I would like to make a script that will first use the contour command (group = yes)
Afterwards to move each group on a different location
Finally use the command setpt and flatten everything

Thank you in advance!

Hello,
See here for the (python) rhinoscriptsyntax commands relating to groups:
https://developer.rhino3d.com/api/RhinoScriptSyntax/#group
For instance you can use

import rhinoscriptsyntax as rs
for group_name in rs.GroupNames():
    # do something
1 Like

Thanks Graham,

I checked the rhinoscriptsyntax before posting.
However i had the impression that GroupNames command was related to the groupnames :blush:

Yes but you can then use ObjectsByGroup(group_name, select=True) to select the objects and do something with them :sunglasses:

import rhinoscriptsyntax as rs

for group_name in rs.GroupNames():
    group_objs = ObjectsByGroup(group_name, select=False)
    rs.MoveObjects(group_objs, ...# do something
1 Like

Awesome thanks a lot!!

1 Like