Batch Plot multiple drawings in one drawing file using model space

Batch Plot multiple drawings in one drawing file using model space

hawarch
Participant Participant
1,258 Views
5 Replies
Message 1 of 6

Batch Plot multiple drawings in one drawing file using model space

hawarch
Participant
Participant

Writing lisp to plot multiple drawings located in a single file using their title block information to set the plot parameters.  The plot file will not take and bring up the "Write the plot to file [Yes No]" question followed by the dialog box prompt.  Want to plot the drawings with no interaction.  Please Help...

 

;; Auto Plot Final 24x36; 30x42; 36x48
(defun C:aplot (/ ss ans fname pt1 cki cname)
(setvar "cmdecho" 0)
(setvar "filedia" 0)
(setvar "attdia" 0)
(setvar "osmode" 0)
(setq PLD "Adobe PDF" ; << Ploting Device
PS "designjet 500.ctb" ) ; << Plot Style Table
;0 Get Sheets to Plot
(princ "\n Select Sheets to Plot or <Return> to Select All: ")
(setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
(if (= ss nil) (setq ss (ssget "_X" '((0 . "INSERT") (66 . 1)))) )
;1 get Title Block Project Info
(if ss (progn
(repeat (setq i (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i)))) ;get block
bname (vla-get-effectivename obj)) ;get block name
(if (or (= bname "00100028")(= bname (strcat (substr (getvar "dwgname") 1 4) "****"))) (progn
(setq d1 (LM:getdynpropvalue obj "Distance1") ;get distance to determine sheet size used with block
bsc (cdr (assoc 41 (entget (ssname ss i)))) ;scale
ipt (cdr (assoc 10 (entget (ssname ss i)))) ) ;insertion point
(if (setq job (LM:vl-getattributevalue obj "JOB")) ;get attribute value for job
(princ (strcat "\nPlot File: " job " "))
(setq job (getstring "\nEnter Job Number: ")) )
(if (setq shtno (LM:vl-getattributevalue obj "SHTNO")) ;get attribute value for sheet no
(princ shtno)
(setq shtno (getstring "\nEnter Sheet Number: ")) )
(setq pname (strcat job " " shtno " 00 " datetag) ;s;set plot name
plotfile (strcat (getvar "dwgprefix") "01 PDF\\" pname ".pdf") )
;plotfile (strcat (getvar "dwgprefix") "\\" pname ".pdf") )
(setq pfname (strcat (getvar "DWGPREFIX") (vl-filename-base (getvar "DWGNAME")) ".pdf"))
(redraw (ssname ss i) 3) ;highlight object plotting
;2 Plot Sheet
;(alert (strcat "Current file Plotting: " pname))

(cond
((<= d1 (* 800 bsc))
(setq pt1 (polar ipt (dtr 90) (* 30 bsc)) ;revised for 24x36 plot pt
pt12 (polar pt1 (dtr 270) (* 1190 bsc))
pt2 (polar pt12 (dtr 180) (* 1700 bsc))
PPS "ARCH D"))
((>= d1 (* 1200 bsc))
(setq pt1 (polar ipt (dtr 90) (* 30 bsc)) ;revised for 36x48 plot pt
pt12 (polar pt1 (dtr 270) (* 1740 bsc))
pt2 (polar pt12 (dtr 180) (* 2400 bsc))
PPS "ARCH E"))
(T
(setq pt1 (polar ipt (dtr 90) (* 30 bsc)) ;revised for 30x42 plot pt
pt12 (polar pt1 (dtr 270) (* 1440 bsc))
pt2 (polar pt12 (dtr 180) (* 2000 bsc))
PPS "ARCH E1")) );c
;;Start Plotting
(if (findfile plotfile)(vl-file-delete plotfile))
(princ (strcat "\nPlotting: " pfname))
(if (= (getvar "ctab") "Model")
(command ".PLOT" "Y" "Model" pld pps "I" "L" "N" "W" pt2 pt1 pltsts "C" "Y" ps "Y" "A" plotfile "N" "Y")
(command ".PLOT" "Y" (getvar "ctab") pld pps "I" "L" "N" "W" pt2 pt1 pltsts "C" "Y" ps "Y" "N" "N" "N" plotfile "N" "Y") );i
)) ;pi
)) ;rp
(alert "\nNo Selection Set Chosen to Plot") );i
(setvar "cmdecho" 1)
(setvar "filedia" 1)
(setvar "attdia" 1)
(princ)
); end aplot
0 Likes
1,259 Views
5 Replies
Replies (5)
Message 2 of 6

Sea-Haven
Mentor
Mentor

Put some test points in code this will stop and display a string value can use (alert (rtos (car pt1)2 2)) for check pt value etc 

(alert ps)

(alert pps)

Double check you plot names like "Adobe PDF" check upper lower lettering, look for spaces.

 

0 Likes
Message 3 of 6

hawarch
Participant
Participant

Thanks for the reply.  I have done all of the testing and all of the variables and points are good. Also ran a test on the repeat command and it works great.  For some reason, the plot command is not taking the plot file name.  I have tried everything that I can think of - but no luck.  The program uses the model space title block to determine the plot scale, name and plot area so that multiple drawings in a single file can be plotted.  Once fixed, I will tie this to batch file so that all of the drawings in a directory can be plotted - if I can figure this part out....

Thanks and please let me know if you can think of anything else,

Blair.

0 Likes
Message 4 of 6

Sea-Haven
Mentor
Mentor

It is more likely the need for \\ in filename

 

(setq pdfname (strcat (getvar "dwgprefix") "pdf\\" dwgname "-" (getvar "ctab")))

; check that pdf directory exists
(setq dwgpre (strcat (getvar "dwgprefix") "\pdf"))
(if (= (vl-file-directory-p dwgpre) nil)
(vl-mkdir dwgpre)
)
(setq dwgname (GETVAR "dwgname"))
(setq lendwg (strlen dwgname))
(setq dwgname (substr dwgname 1 (- lendwg 4)))
(setq pdfname (strcat dwgpre "\\" dwgname "-" (getvar "ctab") ".pdf" ))
0 Likes
Message 5 of 6

maratovich
Advisor
Advisor

Maybe this will help you: Revers - Automatic batch printing 

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

pmadhwal7
Contributor
Contributor

i was try this software but it not get proper result

0 Likes