RhinoCommon Select SubObjects

Hello,

I have been trying to do some highlighting and select synching in Rhino via my Modeltree, however i stumpled upon an issue that I cannot get the subobjects selected, only highlighted and thus also the Gumball never activates.

I made this quick tester, which is esentially what i am using. My guess is the SelectSubObjects doesnt really work as I am imagining it?
Using this script, the subobject does not get highlighted nor selected. How can i do that?


    public override string EnglishName => "TestSelectBrepFace";

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
        ObjRef objRef;
        var rc = RhinoGet.GetOneObject("Select a Brep or polysurface", false, ObjectType.Brep, out objRef);
        if (rc != Result.Success || objRef == null)
            return rc;

        var rhObj = objRef.Object();
        if (rhObj == null) return Result.Failure;

        int faceIndex = 0;
        rc = RhinoGet.GetInteger("Face index (0-based)", false, ref faceIndex);
        if (rc != Result.Success) return rc;

        var ci = new ComponentIndex(ComponentIndexType.BrepFace, faceIndex);

        doc.Objects.UnselectAll();

        // I thought this selects and higlights the subojbect.
        rhObj.SelectSubObject(ci, true, true);

        doc.Views.Redraw();

        RhinoApp.WriteLine($"Selected BrepFace {faceIndex} on object {rhObj.Id}");
        return Result.Success;
    }
}

Hi @Benterich,

Add one more true to the end of RhinoObject.SelectSubObject.

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  var go = new GetObject();
  go.SetCommandPrompt("Select surface");
  go.GeometryFilter = ObjectType.Surface;
  go.SubObjectSelect = true;
  go.EnableUnselectObjectsOnExit(false);
  go.Get();
  if (go.CommandResult() != Result.Success)
    return go.CommandResult();

  var objRef = go.Object(0);
  var rhObj = objRef.Object();
  if (null == rhObj)
    return Result.Failure;

  var ci = objRef.GeometryComponentIndex;

  rhObj.Select(false);
  rhObj.SelectSubObject(ci, true, true, true);

  doc.Views.Redraw();
  return Result.Success;
}

– Dale

Oh wow, yup that solved it. Thanks!