RhinoCommon - Select / Highlight SubObject


#1

How to select SubObjects ?

http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_DocObjects_RhinoObject_SelectSubObject.htm

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();


#2

Hi @Tom_ , 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.