View Full Version : Printing
Wdobbin
2022-12-12, 05:31 AM
I am trying to print to pdf, I would like to use the dwg name as the pdf name but I would like to specify a specific folder for storing it.
The below code is what I have so far. however, I can't get it to save in this location "C:\Data\PDF"
(defun c:PDF(/)
(if (setq filename (getfiled "Enter Filename" "" "pdf" 1))
(progn
(command "tilemode" "0")
(command "-plot" "No" "layout1" "*layout1*" "DWG TO PDF.pc3" C:\Data\PDF\filename "No" "Yes" ) ))
(princ) )
Thanks in advance,
NalkCZ
2022-12-12, 01:59 PM
Problems I can see:
I'm not sure about the getfiled. I personally have predetermined paths (i.e. D:\Workfolder) for all the prints so I don't get input from user. I had one LISP back in the day that would ask for folder.
Filename variable contains already everything, so you put that into the plot command. This is how to quickly fix your code:
(defun c:PDF(/)
(if (setq filename (getfiled "Enter Filename" "" "pdf" 1))
(progn
(command "tilemode" "0")
(command "-plot" "No" "layout1" "*layout1*" "DWG TO PDF.pc3" filename "No" "Yes" ) ))
(princ) )
Personally I would use detailed setup for printing and adjust further and look into how to get input from user and maybe find if there is better way to get the folder.
BTW: try these commands, they can be quite helpful when dealing with printing or other functions (not to type in names again etc.)
(setq fpath (getvar "dwgprefix"))
(setq fname (vl-filename-base (getvar "dwgname")))
BIG-AL
2022-12-19, 12:50 AM
Here is a plot to pdf. It plots multiple layouts to a PDF directory under the dwg location. It is set up for a fixed title block size and uses window to select so you may need to change the window values.
;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)
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.