Print to PDF no Input

Print to PDF no Input

wstowe
Advocate Advocate
693 Views
3 Replies
Message 1 of 4

Print to PDF no Input

wstowe
Advocate
Advocate

Hello,

 

With the forums help, I was able to write a LISP that printed a DWG to PDF. Now I'm making trying to make it easier by no info needing to be entered. Such as file path or file name. My goal is to type command and have PDF made in folder of DWG. Below is what I have now.

(defun C:p1 ()
  (setq sav (getfiled "Save as" (strcat (getvar "dwgprefix")(vl-filename-base (getvar 'dwgname))) "pdf" 1))
  (command "-plot" "y" "" "DWG To PDF.pc3" "ANSI expand B (17.00 x 11.00 Inches)" "i" "l" "n" "w" "0,0" "34.0,22.0" "" "Center" "y" "monochrome.ctb" "y" "W" sav "N" "Y")
  (princ)
  )

 The save as window comes up with the correct file path and file name but it still requires me to select okay. How do I get it so I don't have to select okay?

 

Hint: I ultimately want to add to script so I can print all open drawings. Slowely getting there. 

0 Likes
694 Views
3 Replies
Replies (3)
Message 2 of 4

wstowe
Advocate
Advocate

Any ideas on this?

0 Likes
Message 3 of 4

dlanorh
Advisor
Advisor

Don't use "getfiled". It starts a dialog

 

Try this

 

(defun C:p1 ()
  (setq sav (strcat (getvar "dwgprefix")(vl-filename-base (getvar 'dwgname))) ".pdf")
  (command "-plot" "y" "" "DWG To PDF.pc3" "ANSI expand B (17.00 x 11.00 Inches)" "i" "l" "n" "w" "0,0" "34.0,22.0" "" "Center" "y" "monochrome.ctb" "y" "W" sav "N" "Y")
  (princ)
)

 

I am not one of the robots you're looking for

Message 4 of 4

Sea-Haven
Mentor
Mentor

This will do exactly what you want it needs the multi getvals to work or replace that part if you want with normal getint. Change the sheet size and CTB.

 

;Plots layouts by range
; By Alan H Feb 2014
(defun AH:pltlays ( / lay numlay numend)
(SETVAR "PDMODE" 0)

(setvar "fillmode" 1)
(setvar "textfill" 1)

(setq alllays (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object))))
(setq count (vla-get-count alllays))
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq vals (AH:getvalsm  (list "Enter plot range" "Enter start tab number" 6 4 "1" "Enter end tab number" 6 4 (RTOS COUNT 2 0))))

(setq numlay (atoi (nth 0 vals)))
(setq numend (atoi (nth 1 vals)))

(setq len (+ (- numend numlay) 1))

(setq dwgname (GETVAR "dwgname"))
(setq lendwg (strlen dwgname))
(setq dwgname (substr dwgname 1 (- lendwg 4)))

(repeat len
(vlax-for lay alllays
(if (= numlay (vla-get-taborder lay))
  (setvar "ctab" (vla-get-name lay))
) ; if
(setq pdfname (strcat (getvar "dwgprefix") "pdf\\" dwgname "-" (getvar "ctab")))

) ; for
(setq lay nil)
(setvar "textfill" 1)
(setvar "fillmode" 1)
    (COMMAND "-PLOT"  "Y"  "" "DWG To PDF"
	       "Iso full bleed A3 (420.00 x 297.00 MM)" "m" "LANDSCAPE"  "N"   "W"  "-6,-6" "807,560" "1=2"  "C"
	       "y" "Acad.ctb" "Y"	"n" "n" "n" pdfName "N" "y"
    )
    
(setq numlay (+ numlay 1))
) ; end repeat
) ; defun

(AH:pltlays)

 

0 Likes