RC - subobject selection routine problems

Trying to be able to select some subobjects via RhinoCommon and have them remain selected once the Get() operation is finished. So far, all I figured out how to do is have the whole object selected.

The second problem is (with the snippet below) that despite the fact that both surface edges and faces are enabled, I can only get the faces - If I zoom in close and try to pick an edge, the multi-selection box only indicates faces, no edges in the list.

import Rhino

def TestSO(prompt):
    go = Rhino.Input.Custom.GetObject()
    go.SetCommandPrompt(prompt)
    filt=Rhino.DocObjects.ObjectType.Curve | Rhino.DocObjects.ObjectType.Surface
    go.GeometryFilter=filt
    go.SubObjectSelect=True
    go.GetMultiple(1,0)
    if go.CommandResult()!=Rhino.Commands.Result.Success:
        return go.CommandResult()
    objrefs = go.Objects()
    if not objrefs: return Rhino.Commands.Result.Nothing
    rc=[]
    for objref in objrefs:
        indices=[item.Index for item in objref.Object().GetSelectedSubObjects()]
        #objref.Object().Select(True)  <-- selects the whole base object
        rc.append([objref.ObjectId,indices])
    return rc

result=TestSO("Select sub objects")
pass

image

What am I missing here?

TIA, --Mitch

You can use RhinoObject.SelectSubObject Method like this:

for objref in objrefs:
        for i in objref.Object().GetSelectedSubObjects():
            objref.Object().SelectSubObject(i, True, True, True)

SubObjectsSelection.py (647 Bytes)

1 Like

Ah, OK, thanks! I was looking in the various GetObject classes because I thought it should be there, didn’t think to look elsewhere. :confounded:

Still do not know why I can’t select concurrent surface edges though. If I have only one selection type - edges or faces - it works, but not both.

Edit - Ah, found it…
https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_Input_Custom_GetObject_ChooseOneQuestion.htm

1 Like