I try to select an ON::Curve inside an ON::instance_reference. I have the object UUID and the ON_COMPONENT_INDEX from the curve. My code works when selecting curves inside breps, but I can not select any subobject from an instance_reference.
I tried using “obj->SelectSubObject(index, true, true, true);” and also the following code:
obj = CRhinoObject::FromId(0, uuid);
const CRhinoInstanceObject* iref = CRhinoInstanceObject::Cast(obj);
const CRhinoObject* sub_obj = iref->SubObjectFromComponentIndex(index); (I get an ON::Curve object here)
sub_obj->Select(true, true);
But none of this works. Are there any hints how to select a subobject of an instance_reference?
I use this as a preselection for a “CRhinoGetObject” so the User can change his previous selection.
My code still not works as intended. I think I was on the wrong path here.
The selection works, but when starting a CRhinoGetObject afterwards, the selection inside the instance_reference is not preselected in the CRhinoGetObject.
First I select the object from my stored uuid and component index. This works as inteded
context.m_doc.UnselectAll(); //To make sure nothing old is selected
obj = CRhinoObject::FromId(0, uuid);
obj->SelectSubObject(index, true, true, true);
context.m_doc.Redraw();
Then I start the CRhinoGetObject and the selection of the curve inside the instance suddenly disappears. This code works for curves that are not in any object and curves in Breps. When I let this run in a debugger, the curve stays selected until “gc.GetObjects()” starts.
// setup GetObject
CRhinoGetObject gc;
gc.SetCommandPrompt(prompt.c_str());
gc.SetGeometryFilter(geometry_type_filter);
gc.SetGeometryAttributeFilter(geometry_attribute_filter);
gc.EnableSubObjectSelect(true, true);
// options required to include pre-selected objects from uuid-list
gc.EnableClearObjectsOnEntry(false);
gc.EnableUnselectObjectsOnExit(false);
gc.EnableDeselectAllBeforePostSelect(false);
gc.EnableAlreadySelectedObjectSelect(true);
gc.GetObjects(min_objects, max_objects);
Finally I process the Objects… But the preselected curve never arrives here
// deselect all objects in the end
context.m_doc.UnselectAll();
for (int i = 0; i < gc.ObjectCount(); i++) {
//process the selected objects
}