Plot to PDF with script and LISP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So here's my challenge. I have a script that opens each drawing and does the following:
- goes to my PDF layout "B-SIZE PDF"
- opens the veiwport and does a zoom all
- goes back to paperspace and does a zoom all
- saves and closes the drawing.
Once it has done this to all 15 drawings, then it runs the .dsd which plots all the PDF's to a specific folder and overrides the current PDF.
This takes a long time, fails if someone has one of the drawings open, and is not really efficient. My original thought was to create a LISP to open each drawing in readonly if it is already open. Then go to the PDF layout preform the zoom all's and plot the PDF to the specific folder. I dont need to save these drawings just plot to pdf to a specific folder.
What I have learned is that once I open the drawing using vla-open I cant switch to the PDF layout in the drawing i just opened. it will only switch to the pdf layout in the drawing that i started the LISP in.
So with this i was thinking that i could use a script and two LISP's. The script would call the open dwg LISP then it could call the PDF plot LISP that would preform the zoom all's and plot the PDF to a specific folder. I dont have much experience with LISP or scripts so i have been struggling to do this. I have spent the last few days searching forms and trying different things but I'm coming up short. Any help would be appreciated. I have attached an example drawing and below is the codes that i have so far.
Open drawing LISP
; File name: Open dwg
; Created by: Ryan Fahrenkrug
; Date: 3/17/20
; Description: Opens a .dwg that is specified in the script
(defun c:dwgOpen ( Arg1 / acad ActDoc layouts)
(vl-load-com)
(vla-activate
(vla-open
(vla-get-documents
(vlax-get-acad-object)
)
Arg1
:vlax-false
)
)
(princ)
)
PDF Plot LISP
; File name: PDF Plot
; Created by: Ryan Fahrenkrug
; Date: 3/18/20
; Description: Plots the B-Size PDF layout
(defun c:PDFplot (/ doc currentPlot plotFileName)
(vl-load-com)
(setq doc (vla-get-activeDocument (vlax-get-acad-object)))
(vla-put-configName (vla-get-activeLayout doc) "DWG To PDF.pc3")
(setq currentPlot (vla-get-Plot doc)
plotFileName "PDF Test")
(vla-plotToFile currentPlot plotFileName)
(princ)
)
I havent made a script file yet since i havent gotten the pdf plot lisp to do what i want.