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

LISP PDF export

11 REPLIES 11
Reply
Message 1 of 12
cma_PavelPrchal
7953 Views, 11 Replies

LISP PDF export

Hello everybody, 

We export a huge number of PDF drawings from AutoCAD layouts. Every PDF must be named according to a name of drawing. Function EXPORTPDF does not work that fine, because a name of each PDF is wrong (program automatically adds a name of whole AutoCAD file). 

So I tried to create a LISP that could plot every each of layout into PDF format. It works fine, but I am having trouble with ADOBE CREATOR input. I am trying to find out how to input a location for a PDF file and also a name of PDF (must be the same as the name of every layout). Right now, I have to specify it for every layout, which is not good for automatization. 🙂 

 

; PrintAll.LSP
; Routine to print all Layouts in a drawing


(defun C:PrintAll ( / layouts num)
	(setq layouts (layoutlist)) ; list all paperspace layouts in the drawing
	(setq num 0) ; zero counter
	(repeat (length layouts) ; Repeats the plot command on all layouts
		(command "._PLOT"
				"YES" ; Detailed plot configuration? Yes/<No>:
				(nth num layouts) ; Enter a layout name or [?] <Layout1>:
				"Adobe PDF" ; Enter an output device name or [?] <Default>:
				"A1" ; Enter paper size or [?] <A3>:
				"Millimeters" ; Enter paper units Inches/<Millimeters>:
				"Landscape" ; Enter drawing orientation Portrait/<Landscape>:
				"No" ; Plot upside down? Yes/<No>:
				"Layout" ; Enter plot area Display/<Extents>/Layout/View/Window:
				"1:1" ; Enter plot scale (Plotted millimeters = Drawing Units) or Fit <1:2>:
				"-0.17,-1.17" ; Enter plot offset (x,y) or <Center>:
				"Yes" ; Plot with plot styles? Yes/<No>:
				"Rozvadec_moskva.ctb" ; Enter plot style table name or [?] (enter . for none) <CCL-BW.ctb>:
				"Yes"	; Plot with lineweights? <Yes>/No:
				"Yes" ;	Scale lineweights with plot scale? Yes/<No>:
				"Yes" ; Plot paper space last? Yes/<No>:
				"No" ; Remove hidden lines? Yes/<No>:
				"No" ; Write the plot to a file? Yes/<No>:
				"No" ; Save changes to page setup? Yes/<No>:
				"Yes" ;Proceed with plot? <Yes>/No:
	 	)
		(setq num (1+ num)) ; Increment counter
	) ; end repeat
) ; end function

 I appreciate your help! And sorry for my English. 

Pavel

 

P.S.: Btw., I was wondering, that would be also fine to have a lisp that would rename all layouts according to blocks in tittleblok. Have you ever seen a routine for a similar problem? 

11 REPLIES 11
Message 2 of 12
smaher12
in reply to: cma_PavelPrchal

Message 3 of 12
hmsilva
in reply to: cma_PavelPrchal

Pavel,
I don't have in this PC a "Adobe PDF" printer, I changed the command, the printer, the paper size and the ctb, for testing.
Tests the code and see if it is what you need.

 

(defun C:test (/ layouts num)
  (setq layouts (layoutlist)); list all paperspace layouts in the drawing
  (setq num 0); zero counter
  (repeat (length layouts); Repeats the plot command on all layouts
    (command ".-PLOT"
	     "Y" ;; Detailed plot configuration? [Yes/No] <No>: y
	     (nth num layouts) ;;Enter a layout name or [?] <Test_001>:
	     "DWG To PDF.pc3" ;;Enter an output device name or [?] <DWG To PDF.pc3>:
	     "ISO A3 (297.00 x 420.00 MM)" ;;Enter paper size or [?] <ISO A3 (297.00 x 420.00 MM)>:
	     "Millimeters" ;;Enter paper units [Inches/Millimeters] <Millimeters>:
	     "Landscape" ;;Enter drawing orientation [Portrait/Landscape] <Landscape>:
	     "No" ;;Plot upside down? [Yes/No] <No>:
	     "Layout" ;;Enter plot area [Display/Extents/Layout/View/Window] <Layout>:
	     "1:1" ;;Enter plot scale (Plotted Millimeters=Drawing Units) or [Fit] <1:1>:
	     "-0.17,-1.17" ;;Enter plot offset (x,y) <0.00,0.00>:
	     "Yes" ;;Plot with plot styles? [Yes/No] <Yes>:
	     "acad.ctb" ;;Enter plot style table name or [?] (enter . for none) <acad.ctb>:
	     "Yes" ;;Plot with lineweights? [Yes/No] <Yes>:
	     "Yes" ;;Scale lineweights with plot scale? [Yes/No] <No>: y
	     "Yes" ;;Plot paper space first? [Yes/No] <No>:
	     "No" ;;Hide paperspace objects? [Yes/No] <No>:
	     (strcat (getvar "DWGPREFIX") (getvar "CTAB") ".pdf") ;; the pdf file with the layout name
	     "No" ;;Save changes to page setup [Yes/No]? <N>
	     "Yes" ;;Proceed with plot [Yes/No] <Y>:
    );; end .-plot
    (setq num (1+ num)); Increment counter
  ); end repeat
); end function

 hope that helps
Henrique

EESignature

Message 4 of 12
cma_PavelPrchal
in reply to: hmsilva

Thanks a lot. For a printer DWG To PDF.pc3 it works just fine. I tried to make it work for Adobe PDF, but I was not successfull. Never mind. 

Thank you!

Message 5 of 12
hmsilva
in reply to: cma_PavelPrchal

You're welcome, Pavel
Glad I could help

 

Henrique

 

EESignature

Message 6 of 12
camaleon2010
in reply to: hmsilva

Hi Friends.

 

I'm developing a little lisp that it can to export all layouts to pdf, only you need to assing the plot scale and layout's number. If someone know the variables that it can to give our this date it will perfect, because only we will execute the command. I add the code, thanks

 

(DEFUN C:PRTOPDF()
(initget 7 "Inches Millimeters")
(setq punits (getkword "<Inches/Millimeters>: "))
(setq count (getint "<Layout's number>: "))
(setq countE 1)
(while (< countE (+ count 1))
(command "_plot" "y" (eval countE) "DWG To PDF.pc3" "ANSI full bleed A (8.50 x 11.00 Inches)" (eval punits) "Landscape" "n" "" "" "" "" "" "" "." "" "y" "n" "n" "" "y" "y")
(setq countE (+ countE 1))
)
(prin1)
)

Message 7 of 12
HeroSy
in reply to: camaleon2010

Hi hmsilva, can you help develop this lisp, I want to plot all layouts via Printer, not pdf, I tried to change the name of device but it failed.

Message 8 of 12
hmsilva
in reply to: HeroSy


@HeroSy wrote:

Hi hmsilva, can you help develop this lisp, I want to plot all layouts via Printer, not pdf, I tried to change the name of device but it failed.


Hi HeroSy,

 

To change the code to plot to a different device, you'll need to enter at the command line the command '-plot', then 'y' and answering the prompts.

When the command finish, press F2 and copy the correct device name (.pc3), the correct paper name, and you'll neeed to follow the correct prompt sequence.

 

If you have difficulties in doing that, copy/paste the the command line prompts in your reply.

 

Hope this helps,
Henrique

EESignature

Message 9 of 12
Darren.Metayer
in reply to: hmsilva

 
Message 10 of 12
shiva.b2008
in reply to: camaleon2010

this command lisp not work
Tags (1)
Message 11 of 12
shiva.b2008
in reply to: shiva.b2008

Hell all, Please help me i want export pdf script , actuvally number of layouts there at time pdf
Tags (1)
Message 12 of 12

I strongly recommend that you use sheet set manager and publish to a .DWF file.. DWF files can be viewed in Autodesk's drawing viewer which is free. You can search for things galore, control layer visibility and even mark them up. Plus you can print DWFs to PDF with the free CutePDF app (without AutoCAD). DWF files are about 1/3 the size of PDFs. Also, I have experienced some fatal flaws in PDFs created directly from AutoCAD (like entire details missing). My clients never liked paying for missing information.

John F. Uhden

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

Post to forums  

Autodesk Design & Make Report

”Boost