Get height of block

Get height of block

erichter
Advocate Advocate
271 Views
2 Replies
Message 1 of 3

Get height of block

erichter
Advocate
Advocate

Hey all! I have a script that pulls exported .dxf files from a Windows folder and batch inserts them into AutoCAD as blocks stacked vertically in the -Y direction. This script works great except that I have to guess the spacing increment and do some ctrl-z trial and error.

 

Is it possible to get the local max Y coordinate of the last inserted block, like with like (ssname (ssget "_L") 0), so that I can move the last inserted block based on that value?

 

(defun c:BI ( / DPATH DWGLST I MSG PT)
(vl-load-com)
(vla-StartUndoMark (setq *DOC* (vla-get-ActiveDocument (vlax-get-acad-object))))
(if (and (setq dpath (getfiled "Open a file in the DXF folder" (strcat (getenv "userprofile") "/Documents/") "" 8))
(setq i (getreal "\nEnter vertical spacing: "))
);; and
(progn
(setq
dpath (substr dpath 1 (- (strlen dpath) (vl-string-search "\\" (vl-list->string (reverse (vl-string->list dpath))))))

dxflst (vl-directory-files dpath "*.dxf" 1)
pt '(0. 0. 0.)
)

(foreach dxf dxflst
(command ".-insert" (strcat dpath dxf) pt "" "" "")

(setq
pt (list 0. (- (cadr pt) i) 0.)
)

);; foreach
);; progn
);; if
(princ)
(vla-EndUndoMark *DOC*)
)

 

0 Likes
Accepted solutions (1)
272 Views
2 Replies
Replies (2)
Message 2 of 3

Kent1Cooper
Consultant
Consultant
Accepted solution

@erichter wrote:

....

Is it possible to get the local max Y coordinate of the last inserted block, ... so that I can move the last inserted block based on that value?


You may be able to use the approach in my BlockChart routines, >here<.  Are you knowledgeable enough to incorporate their spacing elements into your other routine?

Kent Cooper, AIA
0 Likes
Message 3 of 3

erichter
Advocate
Advocate

This is it. Thanks! Your routine pretty much does the same thing as mine except it has the automatic spacing I was looking for, so I won't have any issue incorporating it.

0 Likes