Feature Request: Batch Plot by Selected Rectangles in Layout

In many countries (especially Brazil), architects work with multiple sheets on a single layout instead of one sheet per layout.
It would be extremely useful if BricsCAD allowed automatic plotting (to PDF or printer) of multiple sheets based on selected rectangles (or named frames) in the same layout, each with automatic window extents and size detection.

This workflow is standard in architectural offices and currently not possible to automate with LISP or scripts because the -PLOT command doesn’t accept dynamic window coordinates.
Adding a function or API access for “plot by window coordinates” would make BricsCAD much more practical for architectural production.

Comments

  • You should be able to do this in .net, not trivial though

  • I don’t have any experience with .NET or any kind of programming, but if someone could create and share this tool, it would be extremely useful for the whole community — especially here in Brazil, where most architects work with multiple sheets in a single layout.

  • @le_paludo

    have a look on this thread.

  • ALANH
    edited November 12

    "This workflow is standard in architectural offices and currently not possible to automate with LISP or scripts"

    You are very wrong you can plot multiple say Title blocks in either "Model" or in a "Layout". Even multiple layouts.

    I don't have plot multiples in a layout but do have plot multiples in "Model". Here is some code for you to try.

    ; simple plot titles in model
    ; By AlanH
    (defun plotmodel ( / oldsnap ss2 n xmin xmax xymin ymax ymin index en el inspt)
    (PROMPT ".....PRINTING DRAWING TO plotter....")
    (setq oldsnap (getvar "osmode"))
    (setvar "osmode" 0)

    (setq ss2 (ssget "x" '((0 . "INSERT")(2 . "DRST")(410 . (getvar 'ctab))))) ; drsht is the name of the title block
    (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

    (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 coded for 566 high
    (setq xymax (strcat (rtos xmax 2 1) "," (rtos ymax 2 1)))

    (COMMAND "-PLOT" "Y" "" "Print as Pdf"
    "A3" "M" "LANDSCAPE" "N"
    "W" xymin xymax "1=2" "C"
    "y" "default.ctb" "Y" "" "n" "n"
    "y"
    )

    (setq index (+ index 1))

    )

    (setvar "osmode" oldsnap)
    (princ)
    )
    (plotmodel)

    Ok this will not work as need to edit code to find insertion point of block and set the correct values of XYmin and XYmax.

    If you post a sample dwg can probably do something for you. Is it only one layout or more ?

    Different versions can do use an A1 plotter, A4 or A3 laser as well.

  • "… and currently not possible to automate with LISP or scripts because the -PLOT command doesn’t accept dynamic window coordinates."

    Sure it is possible and massivelly used.

    You can use a block of fixed standard pages and with LISP 'plot' as PDF all of them at once, than use ToolKitPDF to combine resulting files into one.

    Usually you'd have some label "page … of … pages" as a block placed on a fixed spot in your template - this one can be used to calculate coordinates for "plot,window".

    This is a screen shot of my (single) paper space layout - the whole plan gets printed as pdf at once.

    All you neeed in LISP is to organize plotting sequence plus combining single PDF files created.

    Cheers

  • Interesting "ToolkitPDF", trying to find it. I use Ghostscript which can be called via lisp in my case a plot lisp, so all PDFS are made, then using the names of the pdfs they are merged into one pdf. A single menu choice.

  • It has command line features.

    (defun find-pdftk-path ( / pse tmpfile result path candidates)
    (vl-load-com)
    (defun pse (ms / end)
    ;; simple delay function (in milliseconds)
    (setq end (+ (getvar "MILLISECS") ms))
    (while (< (getvar "MILLISECS") end))
    )
    ;; temp file for command output
    (setq tmpfile (strcat (getvar 'TEMPPREFIX) "pdftk_path.txt"))

    ;; run Windows "where" command and redirect to file
    (startapp "cmd.exe"
    (strcat "/c where pdftk > "" tmpfile "" 2>nul"))

    ;; short pse to ensure file exists
    (pse 500)

    ;; read first line from temp file (if any)
    (if (findfile tmpfile)
    (progn
    (setq result (open tmpfile "r"))
    (setq path (read-line result))
    (close result)
    (vl-file-delete tmpfile)
    )
    )

    ;; fallback search in common install locations
    (if (not (and path (findfile path)))
    (foreach f
    '("C:\Program Files\PDFtk Server\bin\pdftk.exe"
    "C:\Program Files (x86)\PDFtk\bin\pdftk.exe"
    "C:\pdftk\pdftk.exe")
    (if (and (not path) (findfile f))
    (setq path f)))
    )
    path
    )

    (defun combine ( / fn pdftkCmd pdfFolder cmd )
    (wait 2) ;rm= 11-Nov-2025

    ;; folder containing PDFs (you can change this if needed)
    (setq pdfFolder "C:\PDF")

    ;; output PDF (same folder/name as DWG)
    (setq fn (strcat (getvar 'dwgprefix)
    (vl-filename-base (getvar 'dwgname))
    ".pdf"))

    ;; delete any existing combined file first
    (if (findfile fn)
    (vl-file-delete fn)
    )

    ;; full path to PDFtk
    (setq pdftkCmd "C:\Program Files (x86)\PDFtk\bin\pdftk.exe")

    ;; build command: switch to folder, merge PDFs, output combined file

    (setq cmd (strcat "/c cd /d "" pdfFolder "" && "
    """ pdftkCmd "" *.pdf cat output "" fn "" && "
    "timeout /t 1 /nobreak >nul && "
    "start "" "" fn """
    )
    )

    ;; run it silently
    (vlax-invoke
    (vlax-create-object "WScript.Shell")
    'Run
    (strcat "cmd.exe " cmd)
    0
    t
    )

    (princ "\nPDFs combined successfully.")
    (princ)
    )

    the above does what I mentioned earlier

    Cheers

  • Its_Alive
    edited November 22

    you can use Python too

    https://pypi.org/project/pypdf/

        @Ap.Command()
        def mergepdfs():
            try:
                merger = PdfWriter()
                for pdf in ["file1.pdf", "file2.pdf", "file3.pdf"]:
                    merger.append(pdf)
                merger.write("merged-pdf.pdf")
            except Exception as err:
                traceback.print_exception(err)
            finally:
                merger.close()
         
    

  • Roumen
    edited November 24

    Thanks!

    on my system this worked:

    import os
    from PyPDF2 import PdfWriter
    import traceback
    def mergepdfs():
    merger = None
    try:
    folder = r"C:\pdf"
    pdf_files = [os.path.join(folder, f) for f in os.listdir(folder) if f.lower().endswith(".pdf")]
    pdf_files.sort() # optional: sort alphabetically
    merger = PdfWriter()
    for pdf in pdf_files:
    try:
    merger.append(pdf)
    except Exception as e:
    print(f"Skipping '{pdf}' due to error: {e}")
    if pdf_files:
    merger.write(os.path.join(folder, "merged-pdf.pdf"))
    print("Merging complete! Output: merged-pdf.pdf")
    else:
    print("No PDF files found in the folder.")
    except Exception as err:
    traceback.print_exception(err)
    finally:
    if merger:
    merger.close()
    if name == "main":
    mergepdfs()