Batch plot modelspace

Batch plot modelspace

pallen9JA6T
Enthusiast Enthusiast
3,596 Views
14 Replies
Message 1 of 15

Batch plot modelspace

pallen9JA6T
Enthusiast
Enthusiast

I'm looking for a lisp to plot multiple fabrication drawings that are setup in modelspace. The company I work for stores shop drawings and fabrication drawings all within the same file. I totally understand that layouts, and publishing are the best solution. However, some jobs have more than 200 fabrication drawings, and 200 layout tabs will really slow down a cad file. We use the layout tabs for our shop drawings. I'm looking to get a lisp that will find my titleblock "block" inside of modelspace and print the extents of each block. See example below. This is a small job and you can see how many layouts I would have. Thanks in advance for your help.

0 Likes
3,597 Views
14 Replies
Replies (14)
Message 2 of 15

maratovich
Advisor
Advisor

No problems.
This is solved with the help of an additional program.
All your questions can be done.
Try the program for printing:

Revers - Automatic batch printing a multiple format (rectangles, frames) of model space and layouts....
https://www.kdmsoft.net/revers.html
If you have any questions, please write. And attach an example dwg file.

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 3 of 15

roland.r71
Collaborator
Collaborator

@pallen9JA6T wrote:

I'm looking for a lisp to plot multiple fabrication drawings that are setup in modelspace. The company I work for stores shop drawings and fabrication drawings all within the same file. I totally understand that layouts, and publishing are the best solution. However, some jobs have more than 200 fabrication drawings, and 200 layout tabs will really slow down a cad file. We use the layout tabs for our shop drawings. I'm looking to get a lisp that will find my titleblock "block" inside of modelspace and print the extents of each block. See example below. This is a small job and you can see how many layouts I would have. Thanks in advance for your help.


Hmmm, using layout tabs has never posed a problem here. Their benefits totaly outwheight any loss in speed (which i never realy noticed anyway), imho. (like easily exporting all layouts to a single pdf)

But I understand your predicament, as its undoable to create all those layouts, afterwards. (at least, by hand. It could be automated though)

 

Perhaps it would be better to speak of "sheets" you have in modelspace, since at first I was a bit confused: Modelspace + layouts ?!?! they don't "mix". It took a look at your picture to understand what you actually mean.

 

Anyway, it is perfectly possible. (but i do not have such a lisp readily available)

-is the titleblock's name "block"?

-is it always the same name, or do you have other blocks too?

-do you wish to plot it straight to a device, or PDF's? (Note: each "sheet" would be a pdf in this case!)

-if PDF's, where should they be saved? (note: 100 dwgs, with 200 sheets average = 20000 plots!!!)

-could you share a dwg, like the one you used for the png? (it only needs the sheet blocks, no 'drawn content')

 

One way to do it:

create a lisp to ..

 - Select all titleblocks

 - Retrieve each blocks 'boundingbox'

 - Use the boundingbox points to plot by "window"

 

then:

Use a batch utility (script) -or- have another lisp to process all dwg's, with the lisp for plotting sheets.

(the lisp for processing all dwg's & for the plotting of sheets can be one and the same routine)

0 Likes
Message 4 of 15

pallen9JA6T
Enthusiast
Enthusiast

@maratovich

I already tried "Revers". I just don't find it to be very user friendly.

0 Likes
Message 5 of 15

pallen9JA6T
Enthusiast
Enthusiast

@roland.r71

Sounds like you have the idea. I've attached an example dwg.

0 Likes
Message 6 of 15

roland.r71
Collaborator
Collaborator

There is a problem with the block. All attribute tags are the same ........, however tags are supposed to be unique. Thats why everything is red. To warn about this error.

 

My guess is you wish to use the PART# value as name for the PDF, but thats a lot more complex to achieve without proper tag names. (As the prompt text is not stored with the block [edit: attribute] data)

 

This should realy be fixed first.

att-tag.jpg

0 Likes
Message 7 of 15

pallen9JA6T
Enthusiast
Enthusiast
The information in the title blocks are fields tagged to other text. I supposed I could just explode them and use find and replace to modify if necessary.
0 Likes
Message 8 of 15

roland.r71
Collaborator
Collaborator

The fields are not the problem.

Its the attribute Tag. The left column in the picture.

Each attribute Tag name should be unique / no duplicates

 

But they ALL have the same Tag: ........

 

So, in a program its impossible to retrieve the value of such Tag without knowing if its the right one. The Prompt text (2nd column) does not work for this as it is stored in a different place as the attributes (underneath the hood)

0 Likes
Message 9 of 15

roland.r71
Collaborator
Collaborator

If you correct the attribute tag's, to correspond with the prompt text, this will do the trick:

(vl-load-com)
(defun c:exPDF ( / ss ed obj i box ll ur pt1 pt2 pdffile tag val)

   (setq ss (ssget "X" (list '(0 . "INSERT")'(2 . "ACM PART TITLE"))))
   (if ss
      (progn
         (setq i 0)
         (while (< i (sslength ss))
            (setq ent (ssname ss i)
                  obj (vlax-ename->vla-object ent)
                  box (vlax-invoke-method obj 'getboundingbox 'pt1 'pt2)
                  ll  (vlax-safearray->list pt1)
                  ur  (vlax-safearray->list pt2)
            )
            (while
               (and
                  (setq ent (entnext ent))
                  (= "ATTRIB" (cdr (assoc 0 (setq edata (entget ent)))))
               )
               (setq tag (cdr (assoc 2 edata)))
               (setq val (cdr (assoc 1 edata)))
               (cond
                  ((= tag "JOB#")   (setq job val))
                  ((= tag "PART#")  (setq part val))
                  ((= tag "RELEASE")(setq rel val))
               )
            )
            (setq pdffile
               (strcat
                  (getvar "dwgprefix")
                  job "-" part "-" rel ".pdf"
               )
            )
            (command "-export" "_P" "_W" ll ur "_N" pdffile)
            (setq i (1+ i))
         )
      )
   )
   (princ)
)

It takes each block and creates a pdf using the job#-part#-release as name.

e.g.:

0000-MBA01-R1.pdf

0000-MBA02-R1.pdf

The pdf's are created at the same location as the dwg's, but you can easily change that.

0 Likes
Message 10 of 15

Sea-Haven
Mentor
Mentor


; plot all title blocks in model space ; By Alan H (PROMPT ".....PRINTING DRAWING TO plotter....") (setq oldsnap (getvar "osmode")) (setvar "osmode" 0) : Da1drsht is titel block name (setq ss2 (ssget "x" '((0 . "INSERT")(2 . "Da1drsht")(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" "" "//PRODPRN01/Design-5100" "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)

You can change the block name and change to plot to pdf, you can use Ghostscript tp join the individual pdfs back into one. See this second example

 

;Plots layouts by range
; By Alan H Feb 2014

(defun AH:pltlays ( / val1 val2 plotnames dwgname lendwg pdfname lay numlay numend dwgpre)
(SETVAR "PDMODE" 0)
(setvar "plottransparencyoverride" 2)
(setvar "fillmode" 1)
(setvar "textfill" 1)
(setq plotnames '())

; check that pdf directory exists
(setq dwgpre (strcat (getvar "dwgprefix") "\pdf"))
(if (= (vl-file-directory-p dwgpre) nil)
(vl-mkdir dwgpre)
)
(SETQ LAYOUTS (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object))))
(SETQ COUNT (- (VLA-GET-COUNT LAYOUTS) 1))

(if (not AH:getval2) (load "getvals3"))
(ah:getval2 "Enter start tab number" 6 4 "1" "Enter end tab number" 6 4 (RTOS COUNT 2 0))

(setq numlay (ATOI val1))
(setq numend (ATOI val2))

(setq len (+ (- numend numlay) 1))

(setq dwgname (GETVAR "dwgname"))
(setq lendwg (strlen dwgname))
(setq dwgname (substr dwgname 1 (- lendwg 4)))

(repeat len
(vlax-for lay LAYOUTS
(if (= numlay (vla-get-taborder lay))
  (setvar "ctab" (vla-get-name lay))
) ; if

(setq pdfname (strcat dwgpre "\\" dwgname "-" (getvar "ctab") ".pdf" ))
) ; for

(setvar "textfill" 1)
(setvar "fillmode" 1)
(setvar "PLOTTRANSPARENCYOVERRIDE" 2)
    (COMMAND "-PLOT"  "Y"  "" "dwg to Pdf"
	       "Iso full bleed A3 (420.00 x 297.00 MM)" "m" "LANDSCAPE"  "N"   "W"  "-6,-6" "807,560" "1=2"  "C"
	       "y" "Designlasercolour.ctb" "Y"	"n" "n" "n" pdfName "N" "y"
    )
    
(setq numlay (+ numlay 1))
(setq plotnames (cons pdfname plotnames))
) ; end repeat
(setq trgfile (strcat (getvar "dwgprefix") "pdf\\" dwgname "-D" val1 "-D" val2 ".pdf")) 

(setq plotnames (reverse plotnames))

(IF (= (length plotnames) 1)
(princ)
(progn
(if (not combinepdf)(load "mergepdfs"))
(combinepdf gsExe plotnames trgFile )
)
)

) ; defun

(AH:pltlays)


(princ)

 

 

0 Likes
Message 11 of 15

3arizona
Advocate
Advocate

 

@roland.r71

Did you figure out how to change the path to your PDF batch plot?  I got lisp to work but need help changing the output path

 

Thanks

 

 

 

 

(vl-load-com)
(defun c:exPDF ( / ss ed obj i box ll ur pt1 pt2 pdffile tag val)

   (setq ss (ssget "X" (list '(0 . "INSERT")'(2 . "ACM PART TITLE"))))
   (if ss
      (progn
         (setq i 0)
         (while (< i (sslength ss))
            (setq ent (ssname ss i)
                  obj (vlax-ename->vla-object ent)
                  box (vlax-invoke-method obj 'getboundingbox 'pt1 'pt2)
                  ll  (vlax-safearray->list pt1)
                  ur  (vlax-safearray->list pt2)
            )
            (while
               (and
                  (setq ent (entnext ent))
                  (= "ATTRIB" (cdr (assoc 0 (setq edata (entget ent)))))
               )
               (setq tag (cdr (assoc 2 edata)))
               (setq val (cdr (assoc 1 edata)))
               (cond
                  ((= tag "JOB#")   (setq job val))
                  ((= tag "PART#")  (setq part val))
                  ((= tag "RELEASE")(setq rel val))
               )
            )
            (setq pdffile
               (strcat
                  (getvar "dwgprefix")
                  job "-" part "-" rel ".pdf"
               )
            )
            (command "-export" "_P" "_W" ll ur "_N" pdffile)
            (setq i (1+ i))
         )
      )
   )
   (princ)
)

 

0 Likes
Message 12 of 15

maratovich
Advisor
Advisor

What file path do you need ?

 

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 13 of 15

3arizona
Advocate
Advocate

Currently pdf files are dumped to drawing location.   how can i change this to my desktop or any other folder on the C drive

0 Likes
Message 14 of 15

roland.r71
Collaborator
Collaborator

@3arizona wrote:

Currently pdf files are dumped to drawing location.   how can i change this to my desktop or any other folder on the C drive


I see.

That's easy: Check the following part in the code...

            (setq pdffile
               (strcat
                  (getvar "dwgprefix")
                  job "-" part "-" rel ".pdf"
               )
            )
 

 

This is where the output directory and filename is determined.

In this case the output directory is set by (getvar "dwgprefix") to the location of the dwg file.

Change that to anything you like.

e.g.: "C:/Users/YourName/Desktop/" (including the quotes)

Note the / (not \, or use \\ instead) and the trailing one !

 

(setq pdffile 
   (strcat 
      "C:/Users/YourName/Desktop/" ; < your path here
      job "-" part "-" rel ".pdf" ) 
)

That should do the trick.

 

...or you could replace the entire part by a routine asking the user (you) for a location.

As long as it returns a value for "pdffile".

0 Likes
Message 15 of 15

3arizona
Advocate
Advocate

Got It, Thanks!!!!

0 Likes