Is it possible to select only 1 group?

I’d like to ask the user for selecting 1 group (and one group only) of objects and then continue the script.

I guess I could ask the user to select 1 object which is part of a group and then find which objects are in the same group. But I like that, when you are accidentally selecting multiple groups, it shows you the options of which group you want to select and you don’t get that when asking for a single object.

Hi @siemen,

Here is one example:

import Rhino

class GetOneGroup(Rhino.Input.Custom.GetObject):
    def __init__(self):
        self.m_objects = []
    def CustomGeometryFilter(self, rh_object, geometry, component_index):
        if rh_object and rh_object.GroupCount > 0:
            return True
        return False
    def GetGroup(self):
        if self.CommandResult() != Rhino.Commands.Result.Success:
            return self.CommandResult()
        rh_object = go.Object(0).Object()
        groups = rh_object.GetGroupList()
        for group in groups:
            rh_objects = rh_object.Document.Groups.GroupMembers(group)
            for rh_obj in rh_objects:
    def GroupObjects(self):
        return self.m_objects

go = GetOneGroup()
go.SetCommandPrompt("Select group")
if go.CommandResult()== Rhino.Commands.Result.Success:
    object_ids = go.GroupObjects()
    for obj_id in object_ids:
        print obj_id

Note, if you call GetObject::GetMultiple, because you like the “choose one group” menu, then no way to stop picking without pressing .

– Dale