Plot Lisp for printing on variable paper length

Plot Lisp for printing on variable paper length

wulfgarcze
Participant Participant
328 Views
2 Replies
Message 1 of 3

Plot Lisp for printing on variable paper length

wulfgarcze
Participant
Participant

Hi,

I’m trying to modify my LISP that I wrote for printing drawings to PDF. The LISP works well, but there might be some errors. I tried to rewrite it for English commands. My tested LISP is in Czech. This LISP works for A3 paper size. It should read the drawing limits and save it to the _U subfolder.

However, I would like to know if the LISP can be modified for longer paper lengths. We have drawings of various lengths. The height is always 297mm, but the length varies. I don’t want to create a new paper size for each print. Is there a way to automate this?

 

(defun C:PDFA3S (/ oldCmdDia filename filepath limMin limMax)
  (setq oldCmdDia (getvar "CMDDIA"))
  ;; Enables dialog boxes for commands
  (setvar "CMDDIA" 1)  

  (setq filename (getvar "DWGNAME"))
  (setq filename (vl-filename-base filename)) ;; Removes the .dwg extension

  ;; Gets the path to the DWG file and adds the "_U" subfolder
  (setq filepath (strcat (getvar "DWGPREFIX") "_U\\"))

  ;; Creates the "_U" subfolder if it doesn't exist
  (if (not (vl-file-directory-p filepath))
    (vl-mkdir filepath)
  )

  ;; Retrieves the current drawing limits
  (setq limMin (getvar "LIMMIN"))
  (setq limMax (getvar "LIMMAX"))

  ;; Displays the current drawing limits
  (princ (strcat "\nCurrent drawing limits: " (rtos (car limMin) 2 2) ", " (rtos (cadr limMin) 2 2) " to " (rtos (car limMax) 2 2) ", " (rtos (cadr limMax) 2 2)))

  (command "PLOT" 
    "Y"                ;; enables detailed plot configuration
    "Model"            ;; layout name
    "DWG TO PDF.pc3"   ;; output device name - printer/plotter
    "ISO A3 full (297.00 x 420.00 mm)" ;; paper size
    "M"                ;; paper size in millimeters
    "L"                ;; landscape orientation
    "N"                ;; do not plot upside down
    "E"                ;; extents
    "F"                ;; fit to paper
    "0.00,0.00"        ;; offset
    "Y"                ;; use plot style
    "monochrome.ctb"   ;; monochrome
    "Y"                ;; plot object lineweights
    "V"                ;; plot with plot styles
    (strcat filepath filename ".pdf") ;; Automatically save to "_U" subfolder
    "N"                ;; do not save changes to page setup
    "Y"                ;; plot
  )

  ;; Restores the original CMDDIA value
  (setvar "CMDDIA" oldCmdDia)
  (princ)
)
0 Likes
329 Views
2 Replies
Replies (2)
Message 2 of 3

baksconstructor
Advocate
Advocate

In any case, you will need to create a non-standard paper size in the AutoCAD printer.
And it is probably better for you to use a ready-made solution than to rewrite Lisp every time.

0 Likes
Message 3 of 3

Sea-Haven
Mentor
Mentor

As suggested you need to add your paper sizes as custom sheet sizes, a side comment has been asked before, you need to update the PC3 file with your custom sizes. 

SeaHaven_0-1730244357846.png

You can add pretty easy a "Please choose size" for your lisp, which has all the correct values required for the pdf.

0 Likes