Author Topic: Plot to PDF  (Read 1387 times)

0 Members and 1 Guest are viewing this topic.

civil.eng

  • Newt
  • Posts: 66
Plot to PDF
« on: September 05, 2022, 02:53:02 AM »
Hi guys,
I try to create pdf from layout based on two points (window area), I found a LeeMac's codes on a topic. It works correct but the exported pdf is blank while coordinate is correct and when I set window manually from plot dialoge the problem is solved.

Code: [Select]
(setq acdoc (vla-get-activedocument (vlax-get-acad-object))
      cplot (vla-get-activelayout acdoc)
      acplt (vla-get-plot acdoc)
)

(setq dev (vla-get-ConfigName cplot))

(setq pf1 '(0.0 68.75))
(setq pf2 '(47.5 0.0))

(vla-put-plottype cplot acwindow)

(vlax-invoke
  cplot
  'setwindowtoplot
  pf1
  pf2
)

(vla-put-CenterPlot cplot 1)

(vla-PlotToFile
  (vla-get-Plot acdoc)
  (strcat (getvar "dwgprefix")
  "test"
  ".pdf"
  )
)

Can someone tell me what the problem is with the codes ?

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Plot to PDF
« Reply #1 on: September 05, 2022, 05:01:11 AM »

civil.eng

  • Newt
  • Posts: 66
Re: Plot to PDF
« Reply #2 on: September 05, 2022, 10:37:46 AM »
https://www.theswamp.org/index.php?topic=56516.msg603190#msg603190

Thanks mate, that was great.
Is there any way to prevent running pdfs after creating them through lisp? lots of pdf is coming up on the screen during publishing

nekonihonjin

  • Newt
  • Posts: 103
Re: Plot to PDF
« Reply #3 on: September 05, 2022, 11:06:33 AM »

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: Plot to PDF
« Reply #4 on: September 06, 2022, 05:36:53 PM »
...Is there any way to prevent running pdfs after creating them...

BIGAL

  • Swamp Rat
  • Posts: 1414
  • 40 + years of using Autocad
Re: Plot to PDF
« Reply #5 on: September 06, 2022, 09:28:43 PM »
happy to discuss what I did in other post, I have done 88 layouts in one go and the pdf viewer adobe stops after about 20 but pdfs are created. Version 2 uses Ghostscript to join back into 1 pdf.
A man who never made a mistake never made anything

PM

  • Guest
Re: Plot to PDF
« Reply #6 on: September 17, 2022, 01:48:49 AM »
Hi civil.eng. If you are working with layout this code will help you.

Code - Auto/Visual Lisp: [Select]
  1. (defun C:laytopdf ( / cmd )
  2.   (setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 0)
  3.   (foreach Layout (layoutlist)
  4.  
  5.     (command "_.-PLOT"
  6.       "No"                                        ; Detailed plot configuration? [Yes/No] <No>: No
  7.       Layout                                      ; Enter a layout name or [?] <Layout1>:
  8.       ""                                          ; Enter a page setup name
  9.       "DWG To PDF.pc3"                            ; Enter an output device name or [?] <DWG To PDF.pc3>:
  10.       (strcat (getvar "DWGPREFIX") Layout ".pdf") ; Directory to save
  11.       "No"                                        ; save changes to page setup?
  12.       "YES"                                       ; proceed with plot?
  13.     ); command
  14.   ); foreach
  15.   (setvar 'cmdecho cmd)
  16.   (princ)
  17. ); defun
  18.  
  19.