TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: civil.eng on September 05, 2022, 02:53:02 AM

Title: Plot to PDF
Post by: civil.eng 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 ?
Title: Re: Plot to PDF
Post by: VovKa on September 05, 2022, 05:01:11 AM
https://www.theswamp.org/index.php?topic=56516.msg603190#msg603190
Title: Re: Plot to PDF
Post by: civil.eng 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
Title: Re: Plot to PDF
Post by: nekonihonjin on September 05, 2022, 11:06:33 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



perhaps
https://www.cadforum.cz/en/how-to-avoid-opening-acrobat-reader-after-publishing-dwg-to-pdf-tip8501
Title: Re: Plot to PDF
Post by: Stefan on September 06, 2022, 05:36:53 PM
...Is there any way to prevent running pdfs after creating them...
Title: Re: Plot to PDF
Post by: BIGAL 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.
Title: Re: Plot to PDF
Post by: PM 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.