;;; This routine can batch process drawing files in a directory.

;;; You can edit the following command line for your needs.

;;; For example, you can use this routine to batch audit drawings

;;; or batch convert drawings from one AutoCAD version to another.

(defun C:RV ( / COUNT DIR FILENAME FILES SCRIPTNAME)
(if (setq dir (getfiled "Select the drawing directory:" "" "dwg" 0))
(setq dir (vl-filename-directory dir))
)
(if dir
(setq files (vl-directory-files dir "*.dwg" 1))
)
(if files
(progn
(setq scriptname (open "C:\\batch.scr" "w")
count 0
)
(while (setq filename (nth count files))
(setq filename (strcat dir "\\" filename))
(write-line (strcat "_open \"" filename "\"") scriptname)

(write-line "_zoom extents" scriptname) ;here you put your own command
(write-line "esconvert" scriptname) ;here you put your own command
(write-line "_qsave" scriptname) ;here you put your own command
(write-line "_close" scriptname) ;here you put your own command

(setq count (1+ count))
)
(close scriptname)
)
)
(princ)
)
(c:rv)
(command "script" "C:\\batch.scr")

Advertisements