Fit blocks to default frames.

Fit blocks to default frames.

Dan-Rod
Advocate Advocate
170 Views
1 Reply
Message 1 of 2

Fit blocks to default frames.

Dan-Rod
Advocate
Advocate

Hello group, I have an lsp that I attach which generates .png images, adjusting the image according to the size of the block.

I want to see if it is possible for some routine to do something similar but it is to adjust blocks to the size of 3 frames that I already have predetermined, this is the image of the frames and their measurements in millimeters, I attach the example dwg, the idea is that the block is scaled to the frame that is closest to its original size.

 

 

DanRod_0-1728941376872.png

 

0 Likes
171 Views
1 Reply
Reply (1)
Message 2 of 2

Sea-Haven
Mentor
Mentor

Maybe something like this as a start.

(defun c:wow ( / )
(setq obj (vlax-ename->vla-object (car (entsel "pick object "))))
(setq bname (vlax-get obj 'name))
(vla-GetBoundingBox obj 'minpoint 'maxpoint)
(setq pointmin (vlax-safearray->list minpoint))
(setq pointmax (vlax-safearray->list maxpoint))

(setq X (- (car pointmax)(car pointmin)))
(setq Y (- (cadr pointmax)(cadr pointmin)))

(setq bx1 75 by1 60)
(setq scx (/ bx1 x))
(setq scy (/ by1 y))

(setq pt (getpoint "\nPlease pick lower left "))

(command "rectang" pt (mapcar '+ pt (list bX1 bY1 0.0)))

(setq pt (mapcar '+ pt (list (/ bX1 2.0) 0.0 0.0)))

(if (< scx scy)
  (command "-insert" bname pt scx scx 0.0)
  (command "-insert" bname pt scy scy 0.0)
)

(princ)
)

 Found a problem block "1" has insertion at middle so would need more code to check.

Not sure how to work out closest match to a rectang size so I chose one for a simple start. 

0 Likes