TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Peter2 on October 11, 2018, 09:47:38 AM
-
As written above: How to get "extmin" and "extmax" from current UCS?
A simple "trans" of the sysvars (from WCS) does not do "enough" - there should be also a "scaling", depending on the angle between WCS and UCS?
-
Thinking out loud:
"Isn't this a orthogonal boundingbox of the (rotated) rectangle that's defined by the corners of EXTMIN and EXTMAX ?"
-
Hi Crank
the problem (or maybe: my wrong thoughts) is: the proportion of the bounding box is changing.
Example:
- a line form 0,0 to 10,10 in WCS
- bounding box: length of x = 10, length of y = 10; diagonal = 14.1
Set of UCS, rotated 45°:
- a line form 0,0 to 0,10 in UCS
- bounding box: length of x = 0, length of y = 14.1
And "trans" on the two sysvars does not handle the entire modification.
-
What Crank has explained is the approach to go for, although I would say you have to calculate a box around the boundingbox defined by EXTMIN and EXTMAX.
Calculate 8 points from EXTMIN and EXTMAX...
Translate them to the current UCS...
Determine the boundingbox around them (This translated box will in most cases be bigger).
A very similar approach is used by the CAD system to calculate the boundingbox of a rotated insert.
-
Here my current state (simple-minded assumption, under development):
- use WCS
- calculate and save extmin and extmax
- (draw the rectangle for better imagination)
- define rotated (round z-axe) and moved UCS
- use "plan" on the usc
- the rectangle shows: the corners are outside the "current extmin / max". They are "more or less near the extents", but no element is outside these pseudo-elements. And this is important for me
- use "trans" from WCS to UCS to calculate the 4 corners
- search min X/Y (for pseudo-extmin) and max X/Y (for pseudo-extmax)
As said above: It is outside the real extmin / extmax!
-
The EXTMIN and EXTMAX are expressed in the WCS. So you do not need to switch to the WCS before using them.
For the rest I think your 2D procedure works along the same principles as my 3D procedure.
Getting the smallest, tightest, boundingbox in the current UCS is also possible. But it does require some work:
- Copy all MS entities (perhaps to an anon block definition).
- Apply a reversed transformation matrix to account for the UCS settings.
- Get the boundingbox of each entity.
- Calculate the overall boundingbox.
-
Another way could be the usage of the screen-data (alos a kind of "semi-solution":
- start "_zoom" extents
- use the sysvars viewctr, viewsize, screensize
example see here: https://ww3.cad.de/foren/ubb/Forum145/HTML/004606.shtml#000004
- Advantage: one dimension (width or height) is always exact
- disadvantage: the "trans" between WCS nd UCS has always to be considered.
-
I have suggested that approach on the BricsCAD forum where you have posted the same question (https://forum.bricsys.com/discussion/34053/how-to-get-extmin-and-extmax-in-rotated-ucs). But after testing I have found that the extents are bases on a boundingbox around the WCS boundingbox.
-
I have suggested that approach on the BricsCAD forum ...
Oops - sorry roy, just now I understand the "screenpoints" that you mentioned there.
For me, I'm satisfied with the current solutions. Not perfect, but helpful ..