+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Senior Member
    Discipline
    Manufacture
    BrianTFC's Discipline Details
    Occupation
    Structral Detailer
    Discipline
    Manufacture
    Using
    AutoCAD 2017
    Join Date
    Jan 2012
    Location
    Indiana
    Posts
    158

    Default Plot to PDF and Combine into one file

    Registered forum members do not see this ad.

    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.

    Code:
    ;;;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

  2. #2
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,899

    Default

    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
    A man who never made mistakes never made anything

  3. #3
    Senior Member
    Discipline
    Manufacture
    BrianTFC's Discipline Details
    Occupation
    Structral Detailer
    Discipline
    Manufacture
    Using
    AutoCAD 2017
    Join Date
    Jan 2012
    Location
    Indiana
    Posts
    158

    Default

    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...

  4. #4
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,899

    Default

    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.
    A man who never made mistakes never made anything

  5. #5
    Super Member
    Using
    not applicable
    Join Date
    Jun 2016
    Posts
    589

    Default

    Ghostscript can be used to combine PDFs.

    Something like this should work:
    Code:
    (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 "\" \"") "\""
        )
      )
    )
    BricsCAD 16

  6. #6
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,899

    Default

    Registered forum members do not see this ad.

    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
    Code:
    (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.
    Last edited by BIGAL; 16th Aug 2016 at 12:21 pm. Reason: Tested now
    A man who never made mistakes never made anything

Similar Threads

  1. Many Lisp files combine in one Lisp file...
    By CAD USER in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 1st Dec 2015, 03:37 am
  2. Changes to plot layout and plot file for publish
    By GliderRider in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 12th Mar 2009, 09:48 pm
  3. Plot To File
    By Brunello19 in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 14th Jul 2006, 02:47 pm
  4. plot to file (as a batch file)
    By tbui63 in forum AutoCAD General
    Replies: 4
    Last Post: 26th Apr 2006, 07:30 pm
  5. plot file locations for batch plot?
    By Kate M in forum AutoCAD General
    Replies: 1
    Last Post: 29th Oct 2003, 09:43 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts