How to achieve Preselect with number control?

Hi all, so for example the Rhino native BlockEdit command will allow pre-select but if you have more than 1 block selected if will ignore them and ask you to select one object, how should one go about implementing this in their own code? With some basic digging I only understand enable/disable pre-select and selection filter, but what about selection number control? Do you for example just do GetObjects, check for number/type (say if you want two crvs only, or one crv and 2 points, etc.) and then feed into the actual command with pre-select enabled or is there some way more efficient?
Thank you!

This should do it:

var go = new GetObject();
go.SetCommandPrompt("Select block to edit");
go.GeometryFilter = ObjectType.InstanceReference;
go.ReferenceObjectSelect = false;
go.EnablePreSelect(true, true);
go.Get();
if (go.CommandResult() != Result.Success)
    return go.CommandResult();
// todo...

When picking multiple object types, the GetObject class does not have a way of specifying how many of an particular type to pick. You’ll have to code up this logic yourself. Or, just prompt for one type of object at a time.

– Dale

1 Like

Thank you Dale!
Are ReferebceObject here linked blocks?

Hi @Jun_Wang,

A reference object is an object that is referenced from an external file. The object could be from from a linked block, or it could be from a non-active worksession document.

– Dale

1 Like