Jump to content

Recommended Posts

Posted

All,

 

I need some help with this PDF plot lisp that was created at work, this lisp was created to take material list sheets PDF them and drop them into the source folder with the sheet name as the file name. I was wondering if someone could help figure out how to combine the pages together to create one file once they are converted to PDF all as one step.

 

;;;This is the lisp routine to Plot the material list to individual PDF files with the job name and the page number
;;;as is does in the Plot Material List button.
;;; plotpdf.lsp
(defun c:PlotPDF (/ ob ss bn mn mx)
     (vl-load-com)
   (setq cnt 0)
   (setq dir(getvar "dwgprefix"))
           (if (and (progn
                (initget "B")
          (setq ob (entsel "\nSelect Block/B for blockname: "))
               (cond 
               ((eq ob "B")
                   (setq bn (getstring "\nEtner Block Name: "))
                   )
               ((and (eq (type ob) 'LIST)
              (vlax-method-applicable-p (vlax-ename->vla-object (car ob)) 'getboundingbox))
                     (setq bn (cdr (assoc 2 (entget (car ob))))))))
 (tblsearch "BLOCK" bn)
               bn     
               (setq ss  (ssget "_X" (list '(0 . "INSERT")'(410 . "Model")(cons 2 bn))))
                     )
                   
               
(progn 
         (vla-zoomextents (vlax-get-acad-object))
       (repeat (setq i (sslength ss))
 (setq ML "Material-List")
 (setq cnt (1+ cnt))
 
 (vla-getboundingbox (vlax-ename->vla-object (ssname ss (setq i (1- i)))) 'mn'mx)
     (command "plot" "yes" "model" "DWG To PDF.pc3" "ANSI A (8.50 x 11.00 Inches)"
         "inches" "LANDSCAPE" "no" "Window"
         (trans (vlax-safearray->list mn) 0 1)
         (trans (vlax-safearray->list mx) 0 1)
         "fit" "center" "yes" "acad.ctb"  "yes" "As Displayed" (strcat dir "ML-" (itoa cnt) "-"(getvar "dwgname")) "no" "yes" "yes" "yes")
               (command ".delay" "750")
   )
             )
              (princ "\nNo Blocks Selected: ")
         )(princ)
     )

 

Thanks,

Brian

Posted

Adobe acrobat thats what we have access to it has COMBINE as a option. Takes maybe 2 minutes or less to make 1 pdf with all in. 88 sheets = 15Mb.

 

There are posts about PDF's creators Bluebeam etc which appear to have this ability, I am sure others will post

Posted

thanks for the reply BIGAL, I guess the big question is..can it be done thru lisp? if AutoCAD isn't capable of combining them that's fine just let me know...8)

Posted

Theres is posts about using Publish and making 1 pdf pretty sure you have to have the right pdf creator I dont think Dwg to pdf works.

Posted

Ghostscript can be used to combine PDFs.

 

Something like this should work:

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

; (CombinePdf 
;   "C:\\Program Files\\gs\\gs8.61\\bin\\gswin32c.exe"
;   '("D:\\Tmp\\A.pdf" "D:\\Tmp\\B.pdf")
;   "D:\\Tmp\\Total.pdf"
; )
; Note: Existing trgFile will be overwritten.
(defun CombinePdf (gsExe srcFileLst trgFile)
 (startapp
   (strcat
     gsExe " "
     "-dBATCH -dNOPAUSE -dQUIET -sDEVICE=pdfwrite "
     "-sOutputFile=\"" trgFile "\" "
     "\"" (KGA_String_Join srcFileLst "\" \"") "\""
   )
 )
)

Posted (edited)

Nice idea Roy_043 will have a play the srcfilelst can be made pretty easy as as you plot each pdf you add it to the list. and then run as per your code.

 

in the code above

(setq pdfname (strcat dir "ML-" (itoa cnt) "-"(getvar "dwgname")))
(setq srcfilelst (cons pdfname scrfilelst))

 

Seems to work pretty good may do it for say more than 4 pdf's will have a chat with the guys and gal.

Edited by BIGAL
Tested now

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...