Hi everyone, I’m having an issue with subobject selection in Rhino 6 SR5 (the latest at the time of writing).
I have a (1) valid, closed solid polysurface with 6 surfaces. My plugin allows the user to select all of its surfaces by dragging the mouse, do some processing that generates some user data relative to each single surface individually, which is then visualized after clicking on the specific surface.
My problem is that if I select one or more surface in the first step, I get an ObjRef with a GeometryComponentIndex that is valid (from 0 to 5, since I have 6 surfaces, a BrepFace type), but if I do it after the processing, no matter the (single) surface I select, I get ID -1 and an invalid type as GeometryComponent.
This means I have no way of finding out which of the many surfaces available the user has selected. Please note that the surfaces share the same ObjectId, since they belong to the same polysurface.
Does anyone know if I’m doing something wrong? Does the User data get attached only to the top level object? maybe that’s the reason why I cannot get the “bottom” object?
I’m using the C# API.
Here the code:
…
Dictionary<ObjRef, Panel> panels = new Dictionary<ObjRef, Panel>();
…
GetObject go = new GetObject();
go.SetCommandPrompt(“Select surface to visualize.”);
go.AcceptNothing(false);
go.GeometryFilter = ObjectType.Surface | ObjectType.Brep;
go.OneByOnePostSelect = true;
go.BottomObjectPreference = true;
go.SubObjectSelect = true;
go.EnableClearObjectsOnEntry(false);
go.EnableUnselectObjectsOnExit(false);
go.DeselectAllBeforePostSelect = false;
go.ReferenceObjectSelect = false;
go.EnablePreSelect(false, true);
go.AlreadySelectedObjectSelect = true;
while (go.Get() == GetResult.Object)
{
ObjRef selObject = go.Object(0);
var subObj = selObject.Object().GetSelectedSubObjects();
var panel = panels.Where(x => x.Key.ObjectId == selObject.ObjectId &&
x.Key.GeometryComponentIndex.Index == selObject.GeometryComponentIndex.Index).Single();
//Here the GeometryComponentIndexes don't match
MouldDisplayConduit pdc = new MouldDisplayConduit(doc, mould, panel.Value);
}