Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

bounding box question

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
1770 Views, 6 Replies

bounding box question

consider a rectangle rotated 45 degrees
the vla-getbondingbox method, will return the lower left and upper right of
a rectangle's bounding box

how would i obtain the smallest bouding box of the rectangle,
in other words, is there a way to read a 45 rotated ucs for this rectangls.
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

On 3/30/2010 10:23 AM, Mark wrote:
> consider a rectangle rotated 45 degrees
> the vla-getbondingbox method, will return the lower left and upper right of
> a rectangle's bounding box
>
> how would i obtain the smallest bouding box of the rectangle,
> in other words, is there a way to read a 45 rotated ucs for this rectangls.
>

As you noted, (vla-getBoundingBox) returns points in WCS coordinates.
Attached is a LISP that returns the bounding box in current UCS
coordinates. You will need to rotate the UCS to match the object to get
the smallest bounding box.
Message 3 of 7
Anonymous
in reply to: Anonymous

with polar and inters
you can calculate a line from lower left in direction of your text
(attribute...)
a line from upper right with (/ pi 2) change in direction from your
first line
inters the 2 lines and you get the 3. point
do the same with
calculate a line from upper right in direction of the text
a line from lower left with (/ pi 2) change in direction from your first
line
inters and you get the 4. point of your rectangle

Mark wrote:
> consider a rectangle rotated 45 degrees
> the vla-getbondingbox method, will return the lower left and upper right of
> a rectangle's bounding box
>
> how would i obtain the smallest bouding box of the rectangle,
> in other words, is there a way to read a 45 rotated ucs for this rectangls.
Message 4 of 7
Kent1Cooper
in reply to: Anonymous

What is the rectangle? A Polyline? A Block? If it's a Polyline, and really rectangular, its own vertices are the smallest bounding box, regardless of its rotation angle, so there should be no need for a get-bounding-box operation. If it's a Block, defined [as I have one] as an orthogonal 1-drawing-unit square, with its size determined by scale factors and its angle by its insert rotation, the smallest bounding box could be calculated from those scale and rotation elements of the entity data, or you could rotate the UCS to match its rotation and do Bill's thing.

If you want to find the smallest bounding box of something that's not rectangular, then you would need some way of deciding at what rotation to consider it. Or perhaps you could make a routine that would try it out at a series of different angles, and report back the smallest result, but that would be limited in its precision by the increment between those angles.

--
Kent Cooper


Mark wrote...
consider a rectangle rotated 45 degrees
....
how would i obtain the smallest bouding box of the rectangle....
Kent Cooper, AIA
Message 5 of 7
Anonymous
in reply to: Anonymous

i am working w/ regions and the rotation is "principal directions"
wrote in message news:6365576@discussion.autodesk.com...
What is the rectangle? A Polyline? A Block? If it's a Polyline, and
really rectangular, its own vertices are the smallest bounding box,
regardless of its rotation angle, so there should be no need for a
get-bounding-box operation. If it's a Block, defined [as I have one] as an
orthogonal 1-drawing-unit square, with its size determined by scale factors
and its angle by its insert rotation, the smallest bounding box could be
calculated from those scale and rotation elements of the entity data, or you
could rotate the UCS to match its rotation and do Bill's thing.

If you want to find the smallest bounding box of something that's not
rectangular, then you would need some way of deciding at what rotation to
consider it. Or perhaps you could make a routine that would try it out at a
series of different angles, and report back the smallest result, but that
would be limited in its precision by the increment between those angles.

--
Kent Cooper


Mark wrote...
consider a rectangle rotated 45 degrees
....
how would i obtain the smallest bouding box of the rectangle....
Message 6 of 7
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:
....
If you want to find the smallest bounding box of something that's not rectangular, then you would need some way of deciding at what rotation to consider it. Or perhaps you could make a routine that would try it out at a series of different angles, and report back the smallest result, but that would be limited in its precision by the increment between those angles.
....

Reviving an old thread, but if someone finds this while looking for a smallest-rectangle-at-any-angle routine, that doesn't require adjusting the UCS as Bill Gilliss's routine above does, and works with any size selection set rather than one object, look at the second version of SmallestRectangle.lsp [the one that's an attachment, not the one in a code window that draws the orthogonal one], here.

Kent Cooper, AIA
Message 7 of 7
mdhutchinson
in reply to: Kent1Cooper

sometime ago, and under a different employer I purchaced an active  x component that I used in vba. I was also succesful in reading in the library into lisp properties, methods and events. It made matrix math a breaze.

check it out at http://www.bluebit.gr/

I think I did a post on it then on using it in lisp code.

 

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Convex-Hull-optimal-bounding-rectangl...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost