Declare RangeCoords as a List of doubles:
RangeCoords store the coordinates of the range or extents of an object.
The image above shows the range or the extremes of a single object. A collection of several objects also have a range:
Note in image above that the cutting plane B-B and the detail envelope A are not selected hence they are not included in the range of objects.
Further the GetSeedRange sub routine takes the selection set oSel and the List of doubles as arguments by reference and calculate the four values i.e. X and Y coordinates of the lower-left and upper-right points of the range of a valid object in the selection set. This is done since we cannot simply take the range of the first object in the selection set as the seed range. This is because some objects on the draft sheet like Tables, Cutting Planes or Detail Envelopes do not have a Range method hence they return 0 as X and Y coordinates for both extreme points.
The seed range in turn is required as a starting range. The range or extents of any one object in the selection set is taken as the full range and then subsequent objects in the selection set are then compared if they are farther outside the limits of the first seed object. This way the overall range of the selection is established progressively.
Inside the GetSeedRange function, a For loop is used to go through each object and its range is calculated. Any valid object will have a non-zero range coordinates which can be taken as a seed range.
Once there are seed or starting range values, the selection set is again traversed and the extreme limits are calculated by comparing each one with the next incoming object. Each larger and smaller value is set as the current and the other is discarded.
The coordinates of the Lower-Left and Upper-Right corners are in the display or document units like mm or inches.
These numbers are not useful to specify zooming extents. The zoom coordinates need to be expressed in terms of the screen coordinates. For this the ModelToWindow method is used as below:
The model in this case is the sheet whereas the Window is the screen. Zooming is always relative to the screen and not the Sheet.
It is important to note that screen coordinates always remain the same irrespective of the sheet coordinates. To check this, draw a line as below in a sheet with mm as units. Right click on the line and check its start and end-point coordinates:
Copy-Paste the same line in another document with inches as units. The coordinate reading might look something as below:
Note that in both cases the screen or window coordinates would be the same for my screen resolution, since the lines occupy the same screen area:
You can un-comment the MessageBox line in the code to check this.
I think there is an argument missing in the Private sub getseedrange
ReplyDeleteByRef rangecoords As List(Of Double).
Thanks
Instead of measuring all the objets in the drawing view. Why not measuring the background sheet only. Maybe it is not possible.
ReplyDelete