Pdf File Name issue

Pdf File Name issue

karthikeyanskm
Contributor Contributor
381 Views
2 Replies
Message 1 of 3

Pdf File Name issue

karthikeyanskm
Contributor
Contributor

Hi Team,

Presently i use the below code for plotting files in the layout.

 

;; Prints All Layout Tabs and names the new PDFs with the name of the
;; drawing followed by the layout tab name.
;;
;; Adjust the paper size and .ctb file as needed.
;;
;; The PDFs will be placed in the folder where the drawing resides
;;
(defun c:LL1 ()
(SETQ DWGPA (vl-filename-directory(GETVAR "DWGPREFIX")))
(foreach lay (layoutlist)
  (setvar 'CTab lay)
  (COMMAND "-PLOT"
"Y"
""
"GSS.pc3"
"ISO FULL BLEED A1 (594.00 x 841.00 MM)"
"Inches"
"LANDSCAPE"
"N"
"E"
"f"
"C"
"Y"
"pdf.ctb"
"Y"
"N"
"N"
"N"
""; Name of file
"N"
"y"      )
    )
)
 
Everything goes fine with this code.
 
Each time when i plot a files, the pdf generated with the file name with a - including layout name.

Presently my all dwg has only one layout. i want to modify this code to generate pdf with the file name alone. Kindly advise me. 

And also how to include scale lineweight option into this code.
0 Likes
Accepted solutions (1)
382 Views
2 Replies
  • Lisp
Replies (2)
Message 2 of 3

MrJSmith
Advocate
Advocate
Accepted solution

See if this works for you. Note: It might be best to remove the "foreach lay (layoutlist)" line and just do the first layout tab in the drawing since this modification will overwrite the PDF multiple times if there are more than 1 layout tab.

 

(defun c:LL1 ( / DWGPA)
(SETQ DWGPA (vl-filename-directory(GETVAR "DWGPREFIX")))
(setq fileName (strcat DWGPA "\\" (cadr (fnsplitl (getvar "DWGNAME"))) ".pdf"))
(foreach lay (layoutlist)
  (setvar 'CTab lay)
  (COMMAND "-PLOT"
"Y"
""
"GSS.pc3"
"ISO FULL BLEED A1 (594.00 x 841.00 MM)"
"Inches"
"LANDSCAPE"
"N"
"E"
"f"
"C"
"Y"
"pdf.ctb"
"Y"
"N"
"N"
"N"
fileName ;Name of file
"N"
"y"      )
    )
)

 

0 Likes
Message 3 of 3

Sea-Haven
Mentor
Mentor
(foreach lay (layoutlist)

(car (layoutlist)) is the 1st layout when only 1 

 

To get around the problem of 1 or more layouts a suggestion make the PLOT part of code a defun, then check (length (layoutlist)) IF its 1 then call the defun only once, if more then use (foreach lay (layoutlist) and call the plot defun.

 

I have plot range lisp that asks in a range what layouts to plot so it will do 1 -> 1 as an answer, 2nd version uses Ghostscript to join all the pdf's back into a single pdf. But keeps all the pdfs. If you want more info ask.

0 Likes