Batch plot to pdf combine

Batch plot to pdf combine

Gaganpatel
Collaborator Collaborator
599 Views
10 Replies
Message 1 of 11

Batch plot to pdf combine

Gaganpatel
Collaborator
Collaborator

 

Dear Sir,

 

I want to batch plot to pdf combine & print to printer two option lisp programming.

Please any body help me. see the attached sample  template.

0 Likes
600 Views
10 Replies
Replies (10)
Message 2 of 11

Sea-Haven
Mentor
Mentor

Yes is the answer, Google "plot all layouts in model space Autocad lisp"

 

You will need to edit this to suit your needs, its to a printer a similar approach for PDF's. Joining pdf's into one pdf a extra step but can be done. It is simple at moment no real way of checking print order but that could be added by reading a attribute value like a sheet number.

 

 

; plot all title blocks in model space
; By Alan H 

 (PROMPT ".....PRINTING DRAWING TO plotter....")
(setq oldsnap (getvar "osmode"))
(setvar "osmode" 0)
 
(setq ss2 (ssget "x" '((0 . "INSERT")(2 . "Your block name")(410 . "Model"))))
(setq n (sslength ss2))

(setq index 0)
(repeat n
    (setq en (ssname ss2 index))
    (setq el (entget en))
    (setq inspt (assoc 10 el)) ; insertion pt this is lower left for this code

   (setq xmin (- (cadr inspt) 6.0))
   (setq ymin (- (caddr inspt) 6.0))
   (setq xymin (strcat (rtos xmin 2 1) "," (rtos ymin 2 1)))

   (setq xmax (+ xmin 813.0)) ; hard coded for 813 wide 6mm offset
   (setq ymax (+ ymin 566.0)) ;hard code for 566 high
   (setq xymax (strcat (rtos xmax 2 1) "," (rtos ymax 2 1)))


  (COMMAND "-PLOT"  "Y"     "" "your printer name"
	       "A3"	"M"     "LANDSCAPE"   "N"
	       "W"	  xymin   xymax "1=2"  "C"
	       "y"	  "Designlaser.ctb"      "Y"   ""	"n"   "n"
	       "y"	
    )
   
  (setq index (+ index 1))

)

(setvar "osmode

 

 

Also Google Plotting by Maratovich has a great package.

0 Likes
Message 3 of 11

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

how to use this programming with command.

  PDF create A4 Paper & Print A4 Paper

i don't no lisp programming, please give complete lisp file.

 

0 Likes
Message 4 of 11

Sea-Haven
Mentor
Mentor

It should do "A4" big hint ! Which appears to be your size, I did say you need to change values in the code.

 

For A4 start with 1=1 not 1=2. 

Your length is 267 your height is 188 the 6 offset is ok. Look at the values in the code for the title block size its A1 at the moment.

"Designlaser.ctb" use "Acad.ctb" or your ctb

"Your printer name" you should copy from a normal plot screen as it must match exactly.

 

If you want pdf's as well then duplicate the plot part but with correct setting for PDF, note you need a pdfname like D01 D02 etc again probably needs some way of reading a title name via an attribute. You have an attribute drg_no that could be used for PDF name.

 

Get the printing to work 1st.

 

Again this is sample code for an A1 title block. SO see prior comments.

 

 

(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"
    )

 

 

 

The reason code is free is that sometimes the end user needs to change a few values to make it work. Helps in starting to learn lisp.

 

 

 

0 Likes
Message 5 of 11

Gaganpatel
Collaborator
Collaborator

Any body please help

0 Likes
Message 6 of 11

paullimapa
Mentor
Mentor

Read up on this thread which provides code and method to plot and merge pdfs

https://www.cadtutor.net/forum/topic/55152-lisp-to-joincombine-pdf-files/


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 7 of 11

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

I don't no deeply lisp programming.

 Any body please help

0 Likes
Message 8 of 11

paullimapa
Mentor
Mentor

Best you hire an expert to follow the link I provided in my reply since it’ll not only require some lisp knowledge but also additional program installation since AutoCAD does not offer a feature to combine separate PDFs into a single file. 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 9 of 11

Sea-Haven
Mentor
Mentor

Ok this merges pdf's. 

 

;MergePdfs
;Merges multiple pdf (or eps) files into one
;Requires the installation of Ghostscript 

; make a batch file ?
;gs -sDEVICE=pdfwrite \
;    -dNOPAUSE -dBATCH -dSAFER \
;    -sOutputFile=combined.pdf \
;    first.pdf \
;    second.pdf \
;    third.pdf [...]

;Ghostscript (http://www.ghostscript.com/) can be used to combine PDFs.

; Something like this should work: by Roy_043

(defun KGA_String_Join (strLst delim)
(if strLst
(apply
'strcat
(cons
(car strLst)
(mapcar '(lambda (a) (strcat delim a)) (cdr strLst))
)
)
""
)
)

; (CombinePdf 
;  (setq gsexe "C:\\Program Files\\gs\\gs9.19\\bin\\gswin64c.exe")

(setq gsexe "P:\\gs\\gs9.19\\bin\\gswin64c.exe")

; (setq srcFilelst  '("D:\\Tmp\\A.pdf" "D:\\Tmp\\B.pdf"))
; (setq trgfile "C:\\Acadtemp\\Total.pdf")
; 
; Note: Existing trgFile will be overwritten.
(defun CombinePdf (gsExe srcFileLst trgFile)
(startapp 
(strcat
gsExe " "
"-sDEVICE=pdfwrite -dBATCH -dNOPAUSE -dQUIET -dAutoRotatePages=/None"
"-sOutputFile=\"" trgFile "\" "
"\"" (KGA_String_Join srcFileLst "\" \"") "\""
)
)
)

 

Were I worked we used this method for years, via a plot range of layouts to pdf lisp.

 

I have added to my To do list as I have to edit the code to suit your title block size. I will add where to get a copy of ghostscript from as it is often updated.

0 Likes
Message 10 of 11

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

Thanks for replay

how to use ???? , Please send complete lisp file request you.

0 Likes
Message 11 of 11

Sea-Haven
Mentor
Mentor

Its on my To do list when I can get time to code, if you want to pay me will do straight away. Remember you are asking for something for free. 88 layouts all done in one go watch it blink as it made all 88 pdfs then made a single 88 page pdf. 

0 Likes