Message 1 of 22
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have roughly ~5000 .dxf files containing fabrication patterns. Is there a way I could process all of them to obtain the maximum height and width of the lengths of the sides of a bounding box around each file's geometry and export that to some text or spreadsheet file?
I quickly put together the following code to handle a single drawing, but I'm struggling with the batch processing part.
(defun C:DIMEXPORT ( doc / ss fn x y)
(setq ss (LM:ssboundingbox (ssget "X")))
(setq fn (strcat (getvar "dwgprefix")(getvar "dwgname")))
(setq x (- (car (cadr ss)) (car (car ss))))
(setq y (- (cadr (cadr ss)) (cadr (car ss))))
(if (setq file (open "c:\\temp\\DIMEXPORT" "W"))
(progn
(write-line (strcat "File Name: " fn) file)
(write-line (strcat "Horizontal Measurement: " X) file)
(write-line (strcat "Vertical Measurement: " Y) file)
);progn
)
)
;; Selection Set Bounding Box - Lee Mac
;; Returns a list of the lower-left and upper-right WCS coordinates of a
;; rectangular frame bounding all objects in a supplied selection set.
;; sel - [sel] Selection set for which to return bounding box
(defun LM:ssboundingbox ( sel / idx llp ls1 ls2 obj urp )
(repeat (setq idx (sslength sel))
(setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))))
(if (and (vlax-method-applicable-p obj 'getboundingbox)
(not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list obj 'llp 'urp))))
)
(setq ls1 (cons (vlax-safearray->list llp) ls1)
ls2 (cons (vlax-safearray->list urp) ls2)
)
)
)
(if (and ls1 ls2)
(mapcar '(lambda ( a b ) (apply 'mapcar (cons a b))) '(min max) (list ls1 ls2))
)
)
Any advice or expertise to share?
EDIT: I should mention that solutions that don't require admin access would be preferable if possible.😀
Solved! Go to Solution.