Batch Printing LSP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to create a LSP routine that will run through the dwg files in a folder, open them up one by one and then print. I have adapted this lisp to do so but am having some problems.
As I understand it you cannot run a .lsp without an open drawing? So, I load up a drawing, any drawing, and then try to run this lisp. CAD will then open up each of the drawings in the selected directory but will only do so in the background of the existing drawing. When it goes to run the predetermined plot routine it will just keep printing the first drawing I had open over and over again. Now obviously I don't want this to happen
So what am I missing to make it open a drawing, plot, open the next drawing, plot etc
Also is there a better way for me to go about doing this?
Thanks
(defun c:batch (/ dir files total ct docs doc) (defun listAllFiles (path ext /) (apply 'append (cons (mapcar (function (lambda(x) (strcat path "\\" x))) (vl-directory-files path ext 1) ) (mapcar (function (lambda(x) (listAllFiles (strcat path "\\" x) ext))) (cddr (vl-directory-files path nil -1)) ; to exclude "." and ".." ) ) ) ) (if (and (setq dir (getfiled "Select a directory to process..." "Start here" "" 33)) (setq dir (vl-filename-directory dir)) ) (if (setq files (listAllFiles dir "*.dwg")) (progn (vl-load-com) (setq total (itoa (length files)) ct 0 docs (vla-get-documents (vlax-get-acad-object)) ) (foreach file files (setq doc (vla-open docs file) ct (1+ ct) ) (command "tilemode" "0") (command "-plot" "y" "Layout1" "\\\\CTASERVER\\Brother MFC-J6520DW Printer" "A3 (297 x 420 mm)" "M" "L" "N" "e" "F" "" "Y" "" "Y" "y" "N" "N" "n" "N" "y" ) (setvar"DynMode" 0) (prompt (strcat "\r" (itoa ct) " of " total " drawings processed.")) (vla-close doc :vlax-false) ) (vlax-release-object doc) (vlax-release-object docs) ) (prompt (strcat "\nNo files of that type found in " dir " !")) ) (prompt "\nNo path specified!") ) (princ) )