TemporaryCAD Posted July 25, 2022 Posted July 25, 2022 Hello, I'm trying to obtain the bounding box of a block, to get the extents of the block. I've fallen back to Lee Mac's code, which can be found here. I've drawn the obtained boxes in the image. As you can see, when the block is rotated the bounding box is very inaccurate - it is including the hypothetical intersection of the sides of the block! Is there a way to ensure the box precisely envelops the block? Thank you! Quote
mhupp Posted July 25, 2022 Posted July 25, 2022 (edited) http://www.lee-mac.com/minboundingbox.html --edit The higher the angular precision and the more objects you select the longer it takes to calculate. I use (LM:minboundingbox sel 0.001) usually only takes a sec to calculate the box. Edited July 25, 2022 by mhupp Quote
TemporaryCAD Posted July 25, 2022 Author Posted July 25, 2022 11 minutes ago, mhupp said: http://www.lee-mac.com/minboundingbox.html --edit The higher the pension and the more objects you select the longer it takes to calculate. I use (LM:minboundingbox sel 0.001) usually only takes a sec to calculate the box. Thank you for the quick reply. Unfortunately, that is not exactly what I am looking for. I still want the bounding box to be parallel to the x/y axes of the drawing. Additionally, I do not believe it is acceptable to use Lee Macs' code for commercial use. The goal is to align the object within a drawing to both the x and y axes regardless of rotation. I want to calculate the offset utilizing the coordinates of the bounding box. Is there a better way to do this? Quote
Lee Mac Posted July 25, 2022 Posted July 25, 2022 Thank you for the recommendation @mhupp, however, where the bounding box of a rotated and/or (uniformly) scaled block reference is concerned, I would suggest using a method demonstrated by the functions I have shared here - this approach will calculate an accurate rectangular bounding box for block references at any (uniform) scale, rotation, and orientation, with negligible performance costs over the standard getboundingbox method. Quote
TemporaryCAD Posted July 26, 2022 Author Posted July 26, 2022 16 hours ago, Lee Mac said: Thank you for the recommendation @mhupp, however, where the bounding box of a rotated and/or (uniformly) scaled block reference is concerned, I would suggest using a method demonstrated by the functions I have shared here - this approach will calculate an accurate rectangular bounding box for block references at any (uniform) scale, rotation, and orientation, with negligible performance costs over the standard getboundingbox method. Hi Lee Mac, I have tried your function, but it draws a rotated bounding box. I would like a bounding box aligned with the x and y axes, as the goal is to get any arbitrary shape to sit nicely in a corner (i.e. constrained to two lines, one vertical, one horizontal). I believe bounding boxes would be the optimal method to do so. I would be curious to hear your input, as you are so experienced with autolisp. Additionally, this code is for internal commercial use. Will it be an issue to implement your code? Thank you! Quote
mhupp Posted July 26, 2022 Posted July 26, 2022 its finding the bounding box. from there you need to calculate the longest side calculate the angle rotate block Quote
BIGAL Posted July 27, 2022 Posted July 27, 2022 (edited) If you insert the block at say 0,0 with 1 1 0 then do a bounding box (entlast) it will return the size of the block aligned to X & Y so can compare to another insert and get current scale apply to the min max from the bounding box, then just erase the dummy block insert. This will ignore say rotation but it sounds like that is ok. Edited July 27, 2022 by BIGAL Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.