Hi
That was a good point. Two more ways to handle multiple selection:
Quick: The objects can be selected in Model explorer and there is an event which notifies about what was selected. See “Selection Notification” at
http://www.dynoinsight.com/Help/Component/Explorer.aspx
Good: To select several objects with a rectangle (probably after zooming out):
a) Draw a rectangle yourself. The easiest way to do it is inside a ClientDraw handler. Search for *ClientDraw* in samples there are plenty of examples. This way your will not need to add any objects.
b) Implement MouseDown/Up/Move event handlers (See “Events” at
http://www.dynoinsight.com/Help/KernCADProps.aspx ) to process location and size of the rectangle
c) Inside MouseMove handler construct the rectangle. See details below.
d) Loop through all objects in the model (details below) and calculate the minimal sphere containing it using location of the local frame as centre of the sphere and dimensions of half of diagonal of the bounding box obtained via IMetrics.GetDimentions()
e) This sphere projects to the rectangle as a circle of the same radius. So you consider object selected if the circle is fully inside the rectangle, which is easy to check.
f) To calculate the projection in e) you need only projection of the centre obtain global frame expressed in frame aligned to the screen: KernelCAD > GetView() > IView > IFrame > IFrameEx. (
http://www.dynoinsight.com/Help/ModelVi ... lobalFrame ) Use IFrameEx.ToGlobal() to convert the centre of the bounding sphere to eye frame. Take its first two coordinates. This will be the centre of the projected circle.
Each step is quite simple. The mouse handling events have screen (pixels) coordinates. To convert them to 3D coordinates for the rectangle mentioned in c) use ILookEx.ScreenTo3D() obtained via: KernelCAD > GetView() > IView > ILookEx
To loop through all objects independently of child/parent hierarchy obtain array of them via IModel > IPropertyArray. IArray iArrFlat = (IArray)GetProperty("FlatObjectArray");
I hope we will be able to add this in the nearest updates
Regards
Nick