Batch plot from model blocks

Batch plot from model blocks

hearnc843N533T
Participant Participant
600 Views
9 Replies
Message 1 of 10

Batch plot from model blocks

hearnc843N533T
Participant
Participant
Does anyone have a CAD lisp that would be able to batch plot multiple sheets in the model space to pdf?
 
Before I am ridiculed- Yes I know I should use layouts to batch plot, but I want to do it it from the model space, I have my reasons. My old company had a lisp that did this, it worked perfectly but I couldn't bring myself to "permanently borrow it".
 
I am very green to writing lisp/macros. I wouldn't know how to start to write my own. I have been searching google for preexisting lisp for a few days now and found ones that claim to do it, but I can't get them to work.
 
I am thinking I would create a rectangular C blocks that I would paste around each border. The lisp would find these and batch plot them from the model space. 
 
Any help would be greatly appreciated, I know I am not the only one who would like a tool like this
0 Likes
Accepted solutions (2)
601 Views
9 Replies
Replies (9)
Message 3 of 10

Sea-Haven
Mentor
Mentor
Accepted solution

A freebie. The rectang is a block. Done a few years ago a newer version would read scale of rectang block.

 

; 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" oldsnap)
(princ)

 

 Will need editing to suit what your doing. 

0 Likes
Message 4 of 10

hearnc843N533T
Participant
Participant

Thanks to both of you. The first link had a lisp that worked and the second posting lisp worked too with a few tweaks

0 Likes
Message 5 of 10

hearnc843N533T
Participant
Participant

How would I go about modifying the lisp below for ARCH C 24.00" x 18.00". I tried replacing the ISO A3 line and the line below it with inches, but that did not work? I am missing something else, but I do not know what.

 

 

(vl-load-com)
(defun c:demo (/ dwg file hnd i len llpt lst mn mx ss tab urpt)
(if (setq ss (ssget "_X" '((0 . "INSERT") (2 . "A1-"))))
(progn
(repeat (setq i (sslength ss))
(setq hnd (ssname ss (setq i (1- i)))
tab (cdr (assoc 410 (entget hnd)))
lst (cons (cons tab hnd) lst)
)
)
(setq lst (vl-sort lst '(lambda (x y) (> (car x) (car y)))))
(setq i 0)
(foreach x lst
(setq file (strcat (getvar 'DWGPREFIX)
(substr (setq dwg (getvar 'DWGNAME)) 1 (- (strlen dwg) 4))
"-"
(itoa (setq i (1+ i)))
".pdf"
)
)
(if (findfile file)
(vl-file-delete file)
)
(vla-getboundingbox (vlax-ename->vla-object (cdr x)) 'mn 'mx)
(setq llpt (vlax-safearray->list mn)
urpt (vlax-safearray->list mx)
len (distance llpt (list (car urpt) (cadr llpt)))
)
(command "-plot"
"yes"
(car x)
"DWG TO PDF.PC3"
"ISO A3 (420.00 x 297.00 MM)"
"Millimeters"
"Landscape"
"No"
"Window"
llpt
urpt
"Fit"
"Center"
"yes"
"grayscale.ctb"
"yes"
""
)
(if (/= (car x) "Model")
(command "No" "No" file "no" "Yes")
(command
file
"no"
"Yes"
)
)
)
)
)
(princ)
)

0 Likes
Message 6 of 10

paullimapa
Mentor
Mentor

If you look in your PLOT window for Printer/plotter DWG To PDF.pc3 under the Paper size drop-down list you'll see the proper paper size listing as: ARCH C (24.00 x 18.00 Inches)

This is what you have to put in and not ARCH C 24.00" x 18.00"


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

hearnc843N533T
Participant
Participant

Ok that worked, thank you, I am very new to writing lisp files. That seemed like a very silly mistake on my part.

2 more questions for you-

 

1. How would I modify the code to remove the margins and get a full bleed to the 24.00 x 18.00 inch border, see snip below

2. Do you have any good resources for learning to write lisp? There are samples here and there on youtube, but I would need something very basic that starts at the beginning.

 

Thank you very much for your help

 

hearnc843N533T_0-1695759084395.png

 

0 Likes
Message 8 of 10

paullimapa
Mentor
Mentor

Going back to the PLOT window for DWG To PDF.pc3's Paper size drop-down list, when you scroll further up on this list you'll see the full bleed versions: ARCH full bleed C (24.00 x 18.00 Inches)

paullimapa_0-1695759528029.png

As for learning lisp as a beginner everyone including me would point you to this website:

https://www.afralisp.net/ 

paullimapa_1-1695759656191.png

 

 

 


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

hearnc843N533T
Participant
Participant

thank you very much for the help! I will start there

0 Likes
Message 10 of 10

paullimapa
Mentor
Mentor

you are very welcome...cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes