AnsweredAssumed Answered

Robust Selections

Question asked by John Alexander on Apr 20, 2018
Latest reply on Apr 25, 2018 by John Alexander

I try to avoid using selection-dependent functions in my macro workflow - it isn't always possible.

 

Sometimes I hit a dead end and the only feasible method of progressing is to use SelectbyID2 on some coordinates.

2012 SOLIDWORKS API Help - SelectByID2 Method (IModelDocExtension)

 

One problem I have is that the viewport can impact the behaviour of the selection event.

 

Figure 1 - macro collects data regarding hole instances on a part in a drawing.

 

Figure 2 - same macro fails to relate dimensions to hole instances because the view is zoomed out.

 

This is a pretty extreme example, but I don't like having uncaptured/irrelevant UI state determining how my macro performs.

 

Does anyone have any suggestions for making these selection-dependent functions more robust? They seem to be ubiquitous in this API so it would be nice to develop a consistent method. Is it common practice to zoom the camera port to the selection point before calling SelectbyID? Is there something like AddToDB but for selection points?

Outcomes