RhinoCommon - Select / Highlight SubObject

How to select SubObjects ?

let s say i have a Brep ( closed Polysurface ) and i want to Feedback a selected Face to the user.
how to do this ?
what is missing ? what is wrong ? thanks for any help.

rhObj.HighlightSubObject(index, true);
rhObj.SelectSubObject(index, true, true);
rhObj.CommitChanges();
doc.Views.Redraw();

Hi @Tom_P , below is a python example which flashes a selected surface of a brep:

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

def DoSomething():
    obj_ref = rs.GetObject(filter=8, preselect=False, subobjects=True)
    if obj_ref:
        index = obj_ref.Surface().ComponentIndex()
        obj = obj_ref.Object()
        for x in xrange(4):
           obj.HighlightSubObject(index, True)
           scriptcontext.doc.Views.Redraw()
           rs.Sleep(200)
           obj.HighlightSubObject(index, False)
           scriptcontext.doc.Views.Redraw()
           rs.Sleep(200)

if __name__=="__main__":
    DoSomething()

I remember asking a similar question in the past. Using this to “select a subobject” eg:

obj.SelectSubObject(index, True, True)

can be used, but the selection does only remain while the script is running and does not stay, so it cannot be used to make eg. a transformation with a pre-selected subobject after the script finished.

c.

Would the above work? I’m trying to select some subd edges based upon a prior selection (edge loops to rings).

Hi @Jonathan_Hutchinson1,

do you want to prompt for the selection or do you have the subd edge indices of the rings and want them to be selected using code ?

_
c.

Dear Clement, I got lucky, and managed to solve as below. It was the SelectSubObject method for ObjRef objects, but from the API it looks like there might be a lot of ways to do it. I’m not sure whether mine was the best or quickest.