Convert Python to C# - RhinoObject by uuid?[Solved]

I’m trying to convert a code snippet (by clement) from Python to C# (see code below). After spending an hour searching the RhinoCommon API I got nowhere.

The problem I can’t get my head around is how to get the “HighligtedSubObject” indicies from the Mesh (starting from the id or from the Mesh).

The Mesh type doesn’t provide with the UI stuff, and I don’t understand how I can get hold of the RhinoObject (from there I guess I can get the Mesh via Geometry, but that’s another story) based on the id, although it seems so trivial to do in the Python code below :

if not id: 

obj_ref = Rhino.DocObjects.ObjRef(id)
obj = obj_ref.Object()

comp_indices = Rhino.DocObjects.RhinoObject.GetHighlightedSubObjects(obj)

The C# equivalent to the above, anyone?

// Rolf

Not being much for Python myself, but I think it might be something akin to:

ObjRef objRef = new ObjRef(id);
RhinoObject obj = objRef.Object();
if (obj == null)

ComponentIndex[] indices = obj.GetHighlightedSubObjects();
if (indices == null || indices.Length == 0)

foreach (ComponentIndex index in indices)
  if (index.ComponentIndexType == ComponentIndexType.MeshTopologyEdge)
    // This means a mesh edge was selected.
1 Like

Yess! It works. Many thanks.

Now I can continue pretending to be doing something useful again.

// Rolf