Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Batch process all drawings in folder

29 REPLIES 29
Reply
Message 1 of 30
Maynard_Rowley
21177 Views, 29 Replies

Batch process all drawings in folder

I have two large folders of drawings. I need to open all drawings in each folder, purge them, zoom extents, plot them to PDF, save them and close them. I can manage to purge them, zoom extents, save and close them without problem. I have even managed to plot them to PDF (I have to manually put in the filename though, that's a problem to solve later unless someone has a lisp that plots to PDF nicely). The problem I am having is that I have no idea how to process all of the drawings in the folder by running the lisp once (right now I am opening each file individually & running the lisp). Anyone have suggestions?

I am running XP 64 so Script Pro will not work (there is no version available for a 64-bit OS).
29 REPLIES 29
Message 2 of 30
msclout72
in reply to: Maynard_Rowley

look here

http://www.jefferypsanders.com/autolisp.html
i haven't used this one but he has some useful tools..

for a lisp batchlisp
Message 3 of 30
Anonymous
in reply to: Maynard_Rowley

Hi,

These subjects were discussed recently here. The next one is about batch
processing with VisualLISP:

http://tinyurl.com/r5ryr6

As for printing to PDF, it seems that there is a DWG to PDF.pc3 available in
AutoCAD 2008, 2009 and 2010. You can read about it in this thread:

http://tinyurl.com/lk5ln3

HTH


--
Humans are born with a wide horizon.
As time goes by, the horizon narrows and
narrows, until it becomes a point of view.


<67belvedere@sasktel.net> a écrit dans le message de news:
6236012@discussion.autodesk.com...
I have two large folders of drawings. I need to open all drawings in each
folder, purge them, zoom extents, plot them to PDF, save them and close
them. I can manage to purge them, zoom extents, save and close them without
problem. I have even managed to plot them to PDF (I have to manually put in
the filename though, that's a problem to solve later unless someone has a
lisp that plots to PDF nicely). The problem I am having is that I have no
idea how to process all of the drawings in the folder by running the lisp
once (right now I am opening each file individually & running the lisp).
Anyone have suggestions?

I am running XP 64 so Script Pro will not work (there is no version
available for a 64-bit OS).
Message 4 of 30
msclout72
in reply to: Maynard_Rowley

;; DWG2PDF.LSP
;; Plot .DWG to .PDF
;; AutoCAD R2007 Only, with DWG To PDF.pc3 driver, Use AcroBat Reader 6.0 or 7.0
(defun C:PDF-ROOT ( / paper orient filename dwgname dwgpre )
;; Setup section


(setq paper "ANSI B (11.00 x 17.00 Inches)") ;Drawing size Uncomment for printing
;(setq paper "ARCH D (36.00 x 24.00 Inches)") ;Drawing size Uncomment for printing
(setq orient "LANDSCAPE") ;Orientation
(setq tab "Layout1") ;Layout tab to print
(setq plottable "Monochrome.ctb") ;Plot table
(setq plotscale "fit")
;(setq plottername "DWG To PDF.pc3")
(setq plottername "primopdf")
(setq paper "11 x 17") ;Drawing size Uncomment for printing


(setq dwgname (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4) ))
(setq dwgpre (getvar "dwgprefix"))
(setq filename (strcat dwgpre dwgname ".ps"))
(if (> (getvar "cvport") 1)
(command "_plot" "Y" "MODEL" plottername paper "inches" orient "N" "E" plotscale "C" "Y" plottable "Y" "A" filename "N" "Y")
(command "_plot" "Y" tab plottername paper "inches" orient "N" "E" plotscale "C" "Y" plottable "Y" "Y" "N" "N" "y" filename "N" "Y")
)
(prompt "\n ")
(princ)
); end function
(princ)
(C:PDF-ROOT)
Message 5 of 30

"These subjects were discussed recently here. The next one is about batch
processing with VisualLISP:

http://tinyurl.com/r5ryr6"


Yup. Read that post already. Trouble is it recommends using Script Pro, which (as I mentioned in my original post) does not work with XP64. The author does mention using LISP or Object DBX but does not provide any information on how one might do so. Thanks anyway.
Message 6 of 30
southie
in reply to: Maynard_Rowley

Maynard,

Try this

This will give you a mult-pick dialog with all drawingings in the current acad folder.
It will then cycle thru the .dwgs you selected performing your lisp code. Sorry for sloppy code but it works.

(vl-load-com)
(setq ins 0)

(setq plist (vl-directory-files (getvar "dwgprefix") "*.dwg" 1))

(defun lmake ()
(setq yy (get_tile "l1"))
);defun

(defun mk_list (/ count item retlist)
(setq count 1)
(while (setq item (read yy))
(setq retlist (cons (nth item plist) retlist))
(while (and (/= " " (substr yy count 1))
(/= "" (substr yy count 1)))
(setq count (1+ count))
)
(setq yy (substr yy count))
)
(setq ww (reverse retlist))
(setq ins1 (nth ins ww))
(setq newdwg (get_tile "newdwg"))
)

(DEFUN WGCH ()
(SETVAR "CMDECHO" 0)
(SETVAR "EXPERT" 4)

(while (/= ins1 nil)
(setvar "lispinit" 0)
(command "open" ins1)


;;**************

;do your lisp inside here ....

;************



(setq ins (+ ins 1))
(setq ins1 (nth ins ww))
);while
(princ));defun

(defun gout ()
(setvar "expert" 0)
(setvar "cmddia" 1)
(setvar "filedia" 1))

(defun C:JB ( / dcl_id)
(setq dcl_id (load_dialog "mprg1.dcl"))
(if (not (new_dialog "mprg1" dcl_id) ) (exit))
(action_tile "accept" "(gout)(mk_list)(done_dialog)")
(action_tile "cancel" "(gout)(done_dialog)")
(start_list "l1")
(mapcar 'add_list plist)
(end_list)
(start_dialog)
(unload_dialog dcl_id)
(wgch)
(SETQ PLIST NIL)
(setvar "lispinit" 1)
(princ))


Below is the .DCL file

mprg1 : dialog {
label="BATCH FILES";
initial_focus="l1";

:boxed_column{
:row{
:column{


:boxed_row {
:list_box {
label="Select Drawings";
key="l1";
action= "(lmake)";
multiple_select=true;
edit_width=300;
}
}
}
}
}
ok_cancel;
}

Southie
Message 7 of 30
Anonymous
in reply to: Maynard_Rowley

I thought that at least it gives you an ideea about what to search for. I
think there's a lot of ODBX threads on this forum and on the Internet in
general and I think that if you were able to write the code that does all
that you are saying in the OP, it seems that you have enough skills and
knowledge to understand the ODBX stuff. I'm sorry, but I don't really have
time these days to help and guide you through this. Maybe somebody else can
do it.

Regartds

--
Humans are born with a wide horizon.
As time goes by, the horizon narrows and
narrows, until it becomes a point of view.


a écrit dans le message de news:
6236131@discussion.autodesk.com...
"These subjects were discussed recently here. The next one is about batch
processing with VisualLISP:

http://tinyurl.com/r5ryr6"


Yup. Read that post already. Trouble is it recommends using Script Pro,
which (as I mentioned in my original post) does not work with XP64. The
author does mention using LISP or Object DBX but does not provide any
information on how one might do so. Thanks anyway.
Message 8 of 30
EC-CAD
in reply to: Maynard_Rowley

Sorry for late response, been busy.
Try this one:
http://www.bobscadshop.com
.. EC-Batch
will do the job.
Bob
Message 9 of 30
gilsoto13
in reply to: Maynard_Rowley

I've found this trying to accomplish exactly the same, I have found the batch purge, audit, save and close routine, (attached)

Also, you can try this batchplot routine.

PlotDwgs.lsp - PlotDwgs is a plot utility program with several unique options including plotting all open drawings, and plotting a folder of user selected drawings. Drawings may be plotted to a specified size, or by selecting the "Varies" option, the program determines the correct paper size to plot. Also included is the option of plotting all layouts in reverse order, and plotting a folder of user selected drawings in reverse order. The associated files are PlotDwgs.lsp, PlotDwgs.dcl and PlotDwgs.dvb.

You can find it here...

http://web2.airmail.net/terrycad/AutoLISP-Code.htm

And if you like DwgToPdf printer from autodesk (installed in 2008, 2009, and 2010) you may use it for modifying that "PlotDwgs.lsp" to make it print multiple pdfs...

this is an automatic pdf printer routine I started and someone helped me to use it for 2008, 2009 or 2010 with the same abbreviation. It´s just for the current drawing thought.

;
(defun c:pdf ()
(setq os (getvar "osmode"))
(setvar "osmode" 0)
(cond
((= (atof (getvar 'AcadVer)) 17.2)(command "tilemode""0""-plot""y""""DWG To PDF.pc3""ANSI expand B (17.00 x 11.00 Inches)""I""L""N""W""25.4,3.81""908.685,603.885""F""0.75,0""Y""M3_11x17.ctb""Y""N""N""N" (strcat (GETVAR "dwgprefix") (getvar "dwgname")) "N""Y"))
((= (atof (getvar 'AcadVer)) 17.1)(command "tilemode""0""-plot""y""""DWG To PDF2008.pc3""ANSI expand B (11.00 x 17.00 Inches)""I""L""N""W""25.4,3.81""908.685,603.885""F""0.75,0""Y""M3_11x17.ctb""Y""N""N""N" (strcat (GETVAR "dwgprefix") (getvar "dwgname")) "N""Y"))
((= (atof (getvar 'AcadVer)) 18.0)(command "tilemode""0""-plot""y""""DWG To PDF2010.pc3""ANSI expand B (11.00 x 17.00 Inches)""I""L""N""W""25.4,3.81""908.685,603.885""F""0.75,0""Y""M3_11x17.ctb""Y""N""N""N" (strcat (GETVAR "dwgprefix") (getvar "dwgname")) "N""Y"))
)
(setvar "osmode" os)
)
;
;
(defun c:pde ()
(setq os (getvar "osmode"))
(setvar "osmode" 0)
(cond
((= (atof (getvar 'AcadVer)) 17.2)(command "tilemode""0""-plot""y""""DWG To PDF.pc3""ANSI expand B (17.00 x 11.00 Inches)""I""L""N""W""1,0.15""35.775,23.775""F""0.75,0""Y""M3_11x17.ctb""Y""N""N""N" (strcat (GETVAR "dwgprefix") (getvar "dwgname")) "N""Y"))
((= (atof (getvar 'AcadVer)) 17.1)(command "tilemode""0""-plot""y""""DWG To PDF2008.pc3""ANSI expand B (11.00 x 17.00 Inches)""I""L""N""W""1,0.15""35.775,23.775""F""0.75,0""Y""M3_11x17.ctb""Y""N""N""N" (strcat (GETVAR "dwgprefix") (getvar "dwgname")) "N""Y"))
((= (atof (getvar 'AcadVer)) 18.0)(command "tilemode""0""-plot""y""""DWG To PDF2010.pc3""ANSI expand B (11.00 x 17.00 Inches)""I""L""N""W""1,0.15""35.775,23.775""F""0.75,0""Y""M3_11x17.ctb""Y""N""N""N" (strcat (GETVAR "dwgprefix") (getvar "dwgname")) "N""Y"))
)
(setvar "osmode" os)
)
; Edited by: gilsoto13 on Aug 20, 2009 6:48 PM
Message 10 of 30

Southie, this is something I was looking for - a simple batch processing engine to run various lisp codes on multiple drawings, and without any intermediate script generation. I badly need your routine to work for me every day, but I could not even test it because of the dcl file... it does not allow for drawings selection! No "browsing" option, just an empty box with "select" and "cancel" buttons. Can you please help to make it work? I hope very much for your help, because I cannot find anything better to run my lisp codes on multiple drawings! My address is eugene_k@wahw.com.au and I would very appreciate your reply. best regards, Eugene
Message 11 of 30
southie
in reply to: Maynard_Rowley

eugene

Try this using explorer browse to a folder where .dwgs are located. Launch a drawing from folder. Then run program.
It workin here. Let me know if that helps.

Southie
Message 12 of 30

Southie, I have worked this out already, thank you, but I found another probelm: the actual batch process doesn't work - I can only get one drawing processed (i.e. not the few selected drawings. For example, when I want to etransmit few drawings (see the attached) I only get one drawing etransmitted... I was looking for simolar codes available but unable to find anything better then this one, if I manage to mek it work of course... Did you test it? Would you please try the attached and let me know if it works at your end?
Message 13 of 30
southie
in reply to: Maynard_Rowley

eugene

Ran code on four selected .dwgs and it gave me four compressed zip files and four text files see example below.
But files were in a different folder named PlotCfgs.

hth

Southie


Transmittal Report:

Created by AutoCAD eTransmit Tuesday, April 06, 2010, 9:35 AM.



Drawing:

This is a transmittal based on 84813751.dwg.



Files:



Root Drawing:

84813751.dwg



AutoCAD Font Map References:

acad.fmp



AutoCAD Color-dependent Plot Style Table File References:

PlotCfgs\monochrome.ctb





Notes for distribution:



.CTB/.STB plot style tables:

Please copy these files to the AutoCAD Plot Style Table Search Path directory.
Message 14 of 30
southie
in reply to: Maynard_Rowley

Correction the .dwgs and text files are in a subfolder called the "drawing name" under folder you launched dwg from

Southie
Message 15 of 30

Southie, the etransmit txt and dwg files will be saved in the loacation specified in your etransmit configuration. The main thing is to get the batch process working...
Unfortunately I do not get those multiple etransmit files, only the open file is etransmitted. If the file is open but not selected for batch processing, then NO drawings are etransmitted. If the file is open and then selected for batch processing, then only this file will be etransmitted.
Tried all autocad versions with the same result.
Message 16 of 30
southie
in reply to: Maynard_Rowley

Try below

in an autocad session set sdi mode to 1
Close all drawings.
launch drawing as before
now launch a new drawing to get a blank screen.
launch program
select drawings by highlighting drawing name in pick box
hit OK

not familiar with etransmit but appears to be working here. Let me know when you have a chance.

Southie
Message 17 of 30
garyl
in reply to: Maynard_Rowley

I just wanted to say thanks to southie, I found his code here and it will save a lot of time since I have 1000's of files that need converted using the same lisp. I had to do a little tweaking for my pourposes but it saves tones of time.

Message 18 of 30
john.uhden
in reply to: Maynard_Rowley

I wrote a program for Philadelphia Gas Works that processed 23 actions on over 13,000 dwgs (one at a time) in a directory tree with many branches on one (1) slow computer running one (1) session of AutoCAD in about 2 hours, with zero errors.

 

I can't share all the code as it is their intellectual property, but I can share the method for finding and opening all the files.  It is 100% AutoLisp / Visual Lisp.  It is up to you (and/or the smart contributors here) to write the code for the actions you want to take on each file.  If I recall correctly, you need a unique acaddoc.lsp file.  I can show you, but it will take me some time to extract and assemble the non-proprietary code.

John F. Uhden

Message 19 of 30
mcmk8
in reply to: john.uhden

I have similar needs to plot all layouts of all dwg in selected folder, to either printers or plotter. I like the 'PurgeAuditFiles.lsp' , but not for purge and audit but for plotting/printing.

 

Beside the printing, if possible, I would like to have an option to create pdf files (using DWG to PDF.pc3) of all layouts into a single pdf (if it's possible using the .pc3). Eg. If there are 10 dwgs of multiple layouts, it would create 10 pdf of multiple pages as per dwg. Each of our dwg layouts have a PDF setup configured. If we can use 'Publish' rather than 'Dwg to PDF.pc3', that would be better.   Basically, its print or pdf all dwg in a folder. Thanks for any help.

Message 20 of 30
jeffrV7ZMK
in reply to: mcmk8

Hey there, came across this thread because I am basically working on the same thing right now. While I can't just upload the code (company property and all), I can tell you what I am more or less doing.

 

First I created a script for loading all of the file information of the DWG files I want to plot. I took the file data and created a custom DSD file (batch print a few files to see what the file structure is, then use autolisp file io to create a custom one each time).

 

Once the dsd is made, I have my autolisp function call -PUBLISH (or +PUBLISH seems to do the same), load the dsd and we're on our way!

 

NOTE: in the dsd file you will want to call the page setup (configured in the page setup manager). If the dimensions for each of the sheets is the same, then you can configure one sheet and use the psetupin command to import from the configured sheet.

 

Hope this helps!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost