Picking group of objects with Geometry Filter

I’m trying to pick group with geometry filer but i get message “Cannot use these objects.Removing them from selection”

With single object everything worked ok so i assume bitwise operators are here ok:

                go.AcceptNothing(false);
                go.DisablePreSelect();
                go.GeometryFilter = Rhino.DocObjects.ObjectType.Surface | Rhino.DocObjects.ObjectType.Extrusion | Rhino.DocObjects.ObjectType.Brep | Rhino.DocObjects.ObjectType.Mesh | Rhino.DocObjects.ObjectType.InstanceDefinition | Rhino.DocObjects.ObjectType.InstanceReference;
                go.GroupSelect = true;
                go.Get();

@Dale would you mind to look at this? I tried adding go.GetMultiple(1,0) but nothing changed.

Hi @D-W,

The "Cannot use these objects. Removing them from selection. occurs when you’ve picked more objects than the picker allowed. In the case of your code above, you’ve allowed for group selection but you are only picking a single object.

If you want to pick a single object that belongs to some group, then you can us a custom GetObject class.

public class GetGroupObject : Rhino.Input.Custom.GetObject
{
  public override bool CustomGeometryFilter(
    RhinoObject rhObject, 
    GeometryBase geometry, 
    ComponentIndex componentIndex
    )
  {
    if (null != rhObject)
    {
      if (rhObject.Attributes.GroupCount > 0)
        return true;
    }
    return false;
  }
}

Does this help?

– Dale

Hello @dale!

I’d like to pick the whole group of objects not single obj from the group - i had code earlier which was picking one obj - also one from group, but now i see that user will need to pick one object which fits in geometry filter or group which consist of objects that are fitting geometry filter.

I hoped that simple Rhino.Input.Custom.GetObject go = new Rhino.Input.Custom.GetObject(); will be enough for this. Is custom class which inherits from Rhino.Input.Custom.GetObject the only way in this case?

[Edit] Oh i didn’t realized that GetMultiple is last method which i should call. Earlier i had:

GetMultiple(1,0);
Get();

Now it works. Theres only one question more is there any possibility to know if user already picked one group and end command of picking? Now user can pick multiple objects and multiple groups i’d like to end command if user will pick one object or one group without possibility to pick next objects or groups.

[Edit 2]
And the answer is:

GetMultiple(1,-1);

Anyway thanks for quick response!

[Edit 3]
The same info in meta showed me next issue which is drag selection :frowning: Any idea to prevent window pick, crossing pick, or Sel* command during GetObjects ? As i supose OneByOnePostSelect wont help here?

[Edit 4]
it worked! :slight_smile:

go.OneByOnePostSelect = true; //without enabling post selection dont allow to pick with window selection
go.EnableTransparentCommands(false); //solved command problem

:+1: