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

LISP to Automate DWG to PDF

26 REPLIES 26
SOLVED
Reply
Message 1 of 27
Anonymous
12781 Views, 26 Replies

LISP to Automate DWG to PDF

Hello All,

 

I'm new to AutoCAD, LISP, and this forum. I'm hoping someone out there can help me out. 

 

I'm trying to write multiple DWG's to PDF using DWG to PDF.PC3.  I would like it to autosave and not prompt me to save each PDF.  I can have up to 150+ PDF's.

 

I have done a lot of searching on this forum and others and have come up with a start. Here is what I have so far that does not work.  Any ideas on how to fix? Any help would be much appreciated.

 

(setvar "cmdecho" 1)

(Command "-plot")
(Command "yes")
         (Command "")   
         (Command "DWG TO PDF.PC3")  
         (Command "ARCH D (36.00 x 24.00 Inches)")
         (Command "Inches")
         (Command "Landscape")
         (Command "yes")
         (Command "Extents")
         (Command "1:1")
         (Command ".113427,.113168")
         (Command "yes")
         (Command "OMS.ctb")
         (Command "yes")
         (Command "no")
         (Command "no")
         (Command "Yes")
         (Command "No")
         (Command "no")
         (Command "yes")

(ade_errclear)
(setvar "cmdecho" 1)
(setvar "filedia" 1)
(princ)
)

26 REPLIES 26
Message 21 of 27
Anonymous
in reply to: serkancavuslar

I hate to bring a old post back up but I am stuck. I can not get the LISP to remove the .DWG before the .PDF. It always comes out as Test.DWG.PDF. 

Any help would be great. 

(defun c:plotPdfPreTar(/ FileName)
    (setq FileName(strcat (getvar 'DWGPREFIX) (substr (setq dwg (getvar 'DWGNAME)) 1 (- (strlen dwg) 4)) ".pdf"))
  

(command "_plot" "n" "" "" "" (strcat "C:\\CADD\\" FileName) "" "y")
)
Message 22 of 27
Anonymous
in reply to: hmsilva

Help me out, i need a program to print multiple layouts to a single pdf, except the model tab.

Message 23 of 27
maratovich
in reply to: Anonymous

Use the Publish command.
If your print is not set then use this : Revers - Automatic batch printing
Give us an example of your file, then we can give an exact answer.

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
Message 24 of 27
wstowe
in reply to: hmsilva

Hello @hmsilva 

 

I was able to use your code to get PDF made without an user input. Thanks!

 

As I'm going through this and refining my lisp, I keep adding to it and making it more user friendly and gaining more knowledge each step. If you  don't mind, or someone else, could you describe what's going on in yours section. 

 

The first section of code is what I had. The second is yours. I replaced my code with yours and it worked great. I understand the order of mine but not yours. From what I understood the "1" at the end of my code has be last for it to work. However on yours, ".pdf" is last.

 

I'm going basing the order it must be by this info from Autodesk

http://docs.autodesk.com/ACD/2013/ENU/index.html?url=files/GUID-AD65DF88-5218-4655-B877-B4D33B9FB6D1...

(setq sav (getfiled "Save as" (strcat (getvar "dwgprefix")(vl-filename-base (getvar 'dwgname))) "pdf" 1))

(setq file (strcat (getvar 'DWGPREFIX) (substr (setq dwg (getvar 'DWGNAME)) 1 (- (strlen dwg) 4)) ".pdf"))


Thanks!

 

Message 25 of 27
diagodose2009
in reply to: hmsilva

 

Can you extend your command -with this  FmtStr? Tha magic Trick is (car (list ****

 

if (nam)
{ command("-PLOT",
car(list("y","\nDetailed plot configuration? [Yes/No] <No>:")), 
car(list("" ,"\nEnter a layout name or [?] <Layout1>:")),
car(list(kScreenDevice,"Enter an output device name or [?] <None>: ")),
car(list("A4","\nEnter paper size or [?] <A3>:")),
car(list("m","\nEnter paper units [inches/Millimeters] <Inches>: m")),
car(list("l","\nEnter drawing orientation [Portrait/Landscape] <Landscape>:")),
car(list("no","\nPlot upside down? [Yes/No] <No>:")),
car(list(""e","\nEnter plot area [Display/Extents/Limits/View/Window] <Layout>: e)),
car(list("f","\nEnter plot scale (Plotted Millimeters=Drawing Units) or [Fit] <1:1>: f")),
car(list("0,0","\nEnter plot offset (x,y) or [Center] <0.00,0.00>:)),
car(list("yes","\nPlot with plot styles? [Yes/No] <Yes>:")),
car(list(pstyle,"\nEnter plot style table name or [?] (enter . for none) <>: ")),
car(list("yes","\nPlot with lineweights? [Yes/No] <Yes>:")),
car(list("","\nScale lineweights with plot scale? [Yes/No] <No>:")),
car(list("","\nPlot paper space first? [Yes/No] <No>:")),
car(list("","\nHide paperspace objects? [Yes/No] <No>:")),
car(list("","\nWrite the plot to a file [Yes/No] <N>:")),
car(list("","Save changes to page setup [Yes/No]? <N>")),
car(list("y","\nProceed with plot [Yes/No] <Y>:")));
};

 

Message 26 of 27
Sea-Haven
in reply to: diagodose2009

Why ?

 

Plot pdfrange just enter start layout number last lastout number watch the pdf get made. 

 

I have a couple of plot pdf so why ask questions take the mistakes out of the end users hands they just want press button and it comes out

 

Message 27 of 27
serkancavuslar
in reply to: Sea-Haven

AutoCAD LT and Quick Plot

 

Serkan ÇAVUŞLAR
CplCAD / Türkiye
Tags (1)

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report