How to know if an object was selected using Sub-Object selecting?

Working on a command for a plug-in and for logic further down the line I need to figure out whether the user selected a specific surface through sub-object selection (Ctrl+Shift while clicking) or regular clicking on the Brep. Is there any way to do this or am I forced to create separate commands for the different ways of selecting?

I don’t have direct experience, but this looks useful

Thanks! I’ll give this a go and report back

Hmno, I might be doing something wrong. But it returns a True boolean both when I Ctrl+Shift click or regular click on the object. :confused:

How do you currently perform the object selection?

This script seems to work once you cancel out the filter:

import Rhino
import scriptcontext

def test_get_brep_face():
    go = Rhino.Input.Custom.GetObject()
    go.SetCommandPrompt("Select surfaces")
    #go.GeometryFilter = Rhino.DocObjects.ObjectType.Surface
    go.SubObjectSelect = True
    go.GetMultiple(1, 0)
    if go.CommandResult()!= Rhino.Commands.Result.Success:
        return
        
    for objref in go.Objects():
        print(objref.ObjectId)
        print(objref.GeometryComponentIndex.ComponentIndexType)
        print(objref.GeometryComponentIndex.Index)

if __name__ == "__main__":
    test_get_brep_face()

Hmm I use Brep as a filter instead of Surface. Could that be the problem?

Stripped down it looks something like this right now:

var go = new GetObject();
go.GeometryFilter = ObjectType.Brep;

go.SubObjectSelect = true;
while (true)
{
    go.GetMultiple(1,0);
    if (go.CommandResult() != Result.Success)
        return Result.Failure;
    break;
}

I don’t know the rest of your code, but if I try this it still seems to function:


from Rhino.Input.Custom import GetObject
from Rhino.DocObjects import ObjectType
from Rhino.Commands import Result



def go():
    go = GetObject()
    go.GeometryFilter = ObjectType.Brep
    
    
    go.SubObjectSelect = True
    while (True):
    
        result = go.GetMultiple(1,0)
        if (go.CommandResult() != Result.Success):
            return Result.Failure
        else:
            return go.Object(0).Geometry()
        break
print go()

Hi @Gijs, But how does it indicate whether you have selected the Brep using Sub-object selecting (so Ctrl+Shift to select 1 surface of the brep) or regular selecting (just clicking and selecting the whole brep)?

if I run the last script I posted and subselect a face (of a box) I get this as result:
<Rhino.Geometry.BrepFace object at 0x0000000000000088 [Rhino.Geometry.BrepFace]>
now if I run again and select normally I get:
<Rhino.Geometry.Brep object at 0x0000000000000089 [Rhino.Geometry.Brep]>

1 Like

Sorry, I should have tested this before asking.
Thanks, I think this should get me going!

1 Like