Print multiple sheets from Model Space

Print multiple sheets from Model Space

ntsaousoglou
Explorer Explorer
6,415 Views
9 Replies
Message 1 of 10

Print multiple sheets from Model Space

ntsaousoglou
Explorer
Explorer

I have created a file with multiple drawings in the model tab.
In order to print them i follow the next steps:

1.Ctrl+P
2. Previous Plot (Let’s say that i have already set my preferences)
3. Window (in order to select the area-drawing i want to plot)
4. preview (to check my selection)
5. plot

I want a faster way, cause i have to do the above steps for 120 drawings.

 

I do not know alot about lisps so if you want any additional information ask me.

 

0 Likes
6,416 Views
9 Replies
Replies (9)
Message 2 of 10

john.uhden
Mentor
Mentor

Why not learn how to use paper space with one layout tab for each sheet?  Then learn about sheet set manager and plot all your sheets in one step.  But if you prefer using R11 (or maybe that was R10), then at least save a view for each sheet in Modelspace and just plot the view.  About how many views (sheets) would you have in each drawing?

John F. Uhden

0 Likes
Message 3 of 10

patrick_35
Collaborator
Collaborator

Hi

 

An example that uses pdfcreator and in which you define the name of the cartridge

Mon_Cartouche "Cart" ; Name of cartridge

The lisp

(defun c:imp(/ bck bg def doc ent hd lay lst pdf plt sel tot kill nombl mon_impression Mon_Cartouche)
  (defun kill(qui / item meth1 meth2 obj WMI)
    (setq WMI (vlax-create-object "WbemScripting.SWbemLocator")
	  meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil)
	  meth2 (vlax-invoke meth1 'ExecQuery "Select * from Win32_Process")
    )
    (vlax-for item meth2
      (and (setq obj (vlax-get item 'CommandLine)) (vl-string-search (strcase qui) (strcase obj))
	(vlax-invoke item 'Terminate)
      )
    )
    (foreach item (list WMI meth1 meth2)
      (vlax-release-object item)
    )
  )

  (defun nombl(bl)
    (if (vlax-property-available-p bl 'effectivename)
      (vla-get-effectivename bl)
      (vla-get-name bl)
    )
  )

  (defun mon_impression(dim)
    (if (> (distance (car dim) (list (caadr dim) (cadar dim) (caddar dim)))
	   (distance (list (caadr dim) (cadar dim) (caddar dim)) (cadr dim))
	)
      (vla-put-plotrotation lay ac270degrees)
      (vla-put-plotrotation lay ac0degrees)
    )
    (vlax-invoke lay 'setwindowtoplot (list (caar dim)(cadar dim))
				      (list (caadr dim)(cadadr dim))
    )
    (vl-catch-all-apply 'vlax-invoke (list plt 'plottodevice))
  )

  (setq doc (vla-get-activedocument (vlax-get-acad-object))
	Mon_Cartouche "Cart" ; Name of cartridge
  )
  (if (setq def (getenv "Patrick_35_imp"))
    (setq def (atoi def))
    (setq def 1)
  )
  (and (ssget "x" (list (cons 0 "insert") (cons 2 (strcat "`**," Mon_Cartouche))))
    (progn
      (vlax-for ent (setq sel (vla-get-activeselectionset doc))
	(and (eq (strcase (nombl ent)) (strcase Mon_Cartouche))
	  (progn
	    (vla-getboundingbox ent 'bg 'hd)
	    (setq lst (cons (list (vlax-safearray->list bg) (vlax-safearray->list hd)) lst))
	  )
	)
      )
      (vla-delete sel)
      (cond
	((eq (logand def 1) 1)
	  (setq lst (vl-sort lst '(lambda(a B) (if (equal (cadar a) (cadar B) 0.0001)
						(< (caar a) (caar B))
						(> (cadar a) (cadar B))
					       )
				 )
		    )
	  )
	)
	((eq (logand def 2) 2)
	  (setq lst (vl-sort lst '(lambda(a B) (if (equal (caar a) (caar B) 0.0001)
						(> (cadar a) (cadar B))
						(< (caar a) (caar B))
					       )
				 )
		    )
	  )
	)
	((eq (logand def 4) 4)
	  (setq lst (vl-sort lst '(lambda(a B) (if (equal (cadar a) (cadar B) 0.0001)
						(< (caar a) (caar B))
						(< (cadar a) (cadar B))
					       )
				 )
		    )
	  )
	)
	((eq (logand def 8) 8)
	  (setq lst (vl-sort lst '(lambda(a B) (if (equal (caar a) (caar B) 0.0001)
						(< (cadar a) (cadar B))
						(< (caar a) (caar B))
					       )
				 )
		    )
	  )
	)
      )
      (and (eq (logand def 16) 0) (kill "PDFCreator.exe"))
      (if (setq pdf (vlax-get-or-create-object "PDFCreator.clsPDFCreator"))
	(progn
	  (vlax-invoke pdf 'cstart "/NoProcessingAtStartup")
	  (vlax-put pdf 'cPrinterStop :vlax-false)
	  (vlax-put pdf 'cPrinterStop :vlax-true)
	  (vlax-put pdf 'cWindowState 0)
	  (and (eq (logand def 16) 0) (vlax-invoke pdf 'cClearCache))
	  (vlax-put-property pdf 'cOption "savefilename" (vlax-make-variant (vl-filename-base (getvar "dwgname"))))
	  (setq tot (vlax-get pdf 'count))
	)
	(progn
	  (or (setq pdf2 (vlax-get-or-create-object "PDFCreatorBeta.JobQueue"))
	      (setq pdf2 (vlax-get-or-create-object "PDFCreator.JobQueue"))
	  )
	  (and	(vl-catch-all-error-p (vl-catch-all-apply 'vlax-invoke (list pdf2 'initialize)))
		(eq (logand def 16) 0)
	    (progn
	      (vlax-invoke pdf2 'releasecom)
	      (vlax-invoke pdf2 'initialize)
	    )
	  )
	  (setq tot (vlax-get pdf2 'count))
	)
      )
      (setq lay (vla-get-activelayout doc)
	    plt (vla-get-plot doc)
      )
      (vla-put-configname               lay "PDFCreator")
      (vla-refreshplotdeviceinfo        lay)
      (vla-put-canonicalmedianame       lay "A4")
      (vla-put-centerplot               lay :vlax-true)
      (vla-put-paperunits               lay acMillimeters)
      (vla-put-plothidden               lay :vlax-false)
      (vlax-invoke lay 'setwindowtoplot '(0.0 0.0) '(10.0 10.0))
      (vla-put-plotrotation             lay ac270degrees)
      (vla-put-plottype                 lay acWindow)
      (vla-put-plotviewportborders      lay :vlax-false)
      (vla-put-plotviewportsfirst       lay :vlax-true)
      (vla-put-plotwithlineweights      lay :vlax-true)
      (vla-put-plotwithplotstyles       lay :vlax-true)
      (vla-put-scalelineweights         lay :vlax-false)
      (vla-put-standardscale            lay acVpScaleToFit)
      (vla-put-stylesheet               lay "monochrome.ctb")
      (vla-put-usestandardscale         lay :vlax-true)
      (and (vl-catch-all-error-p (setq bck (vl-catch-all-apply 'getvar (list "backgroundplot")))) (setq bck nil))
      (and bck (setvar "backgroundplot" 0))
      (foreach ent lst
	(mon_impression ent)
	(cond
	  (pdf
	    (while (/= (vlax-get pdf 'cCountOfPrintjobs) (1+ tot)))
	    (setq tot (1+ tot))
	  )
	  (pdf2
	    (vlax-invoke-method pdf2 'waitforjobs (setq tot (1+ tot)) 10)
	  )
	)
      )
      (cond
	(pdf
	  (and (eq (logand def 16) 0) (vlax-invoke pdf 'cCombineAll))
	  (vlax-release-object pdf)
	)
	(pdf2
	  (and (eq (logand def 16) 0)
	    (progn
	      (vlax-invoke pdf2 'mergealljobs)
	      (and (setq fic (getfiled "Nom du PDF" (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".pdf") "PDF" 1))
		(vlax-invoke (vlax-get pdf2 'nextjob) 'convertto fic)
	      )
	      (vlax-invoke pdf2 'releasecom)
	    )
	  )
	  (vlax-release-object pdf2)
	)
      )
      (and bck (setvar "backgroundplot" bck))
    )
  )
  (princ)
)

Options

(defun c:impo(/ chx def doc)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-startundomark doc)
  (if (setq def (getenv "Patrick_35_imp"))
    (setq def (atoi def))
    (setq def 1)
  )
  (princ "\nValues for pdf printing : ")
  (princ "\n\t\t  1 : Start from the Top to Left, then towards the right")
  (princ "\n\t\t  2 : Start from the Top to Left, then to Down")
  (princ "\n\t\t  4 : Start from the Low to Left, then towards the right")
  (princ "\n\t\t  8 : Start from the Low to Left, then to up")
  (princ "\n\t\t 16 : Do not merge pdf")
  (initget 6)
  (setq chx (getint (strcat "\nPDF options <" (itoa def) "> : ")))
  (and chx (/= chx def) (vl-position (rem chx 16) '(1 2 4 8))
    (setenv "Patrick_35_imp" (itoa chx))
  )
  (vla-endundomark doc)
  (princ)
)

@+

0 Likes
Message 4 of 10

patrick_35
Collaborator
Collaborator

I forgot this routine to merge the pdf when the option bit is at 16

(defun c:impf(/ pdf2)
  (or (setq pdf2 (vlax-get-or-create-object "PDFCreatorBeta.JobQueue"))
      (setq pdf2 (vlax-get-or-create-object "PDFCreator.JobQueue"))
  )
  (and	(vl-catch-all-error-p (vl-catch-all-apply 'vlax-invoke (list pdf2 'initialize)))
	(> (vlax-get pdf2 'count) 0)
    (progn
      (vlax-invoke pdf2 'mergealljobs)
      (and (setq fic (getfiled "Nom du PDF" (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".pdf") "PDF" 1))
	(vlax-invoke (vlax-get pdf2 'nextjob) 'convertto fic)
      )
      (vlax-invoke pdf2 'releasecom)
    )
  )
  (vlax-release-object pdf2)
  (princ)
)

 

 

@+

0 Likes
Message 5 of 10

pbejse
Mentor
Mentor

@ntsaousoglou wrote:

I have created a file with multiple drawings in the model tab.
In order to print them i follow the next steps:

1.Ctrl+P
2. Previous Plot (Let’s say that i have already set my preferences)
3. Window (in order to select the area-drawing i want to plot)
4. preview (to check my selection)
5. plot

I want a faster way, cause i have to do the above steps for 120 drawings

 


[ Multiple drawing sheets ]

if you are referring to a "Drawing Sheet" within a title block as BLOCK object on Model Space then its easy, but you have to make do without the preview.

You may need to run a program that would iterate through each title block [ to consider scale of course ] . That will take care of the area-drawing selection.

 

[ Single drawing sheet ]

Assuming that is 120 drawing files and not 120 drawing sheet on a single file, If it's just one drawing area you can use publish to go through a number of files as long as you are using a saved page-setup on a file. [ if you happen to have different scales per drawing sheet otherwise one page setup will be enough ]

 

Publish = Faster

 

HTH

0 Likes
Message 6 of 10

pbejse
Mentor
Mentor

@pbejse wrote:

....You may need to run a program that would iterate through each title block [ to consider scale of course ] . That will take care of the area-drawing selection...


 

Very much like what patrick_35 posted

 

Interesting  --> (defun Kill ...-->  (kill "PDFCreator.exe")

 

pBe

0 Likes
Message 7 of 10

ntsaousoglou
Explorer
Explorer

My document looks like the picture. Many individual drawings In the model tab.

acad.PNG

 

 

0 Likes
Message 8 of 10

john.uhden
Mentor
Mentor

I know it's only a picture, but are those maybe polylines representing the sheet border and maybe on a unique layer, or maybe border blocks?  Either way I think we can help you out quite a bit.

John F. Uhden

0 Likes
Message 9 of 10

patrick_35
Collaborator
Collaborator

Hi

 


@pbejse wrote:

Interesting  --> (defun Kill ...-->  (kill "PDFCreator.exe")


 

This is the only way to close pdfcreator, kill the process.

 

With WMI, we can do several things.
An example as a gift. Autocad which says hello every launch. Lisp to be integrated at startup

 

(defun c:qui(/ meth1 meth2 ok sapi wmi)
  (or (vl-bb-ref 'Patrick_35_Hello)
    (progn
      (setq WMI   (vlax-create-object "WbemScripting.SWbemLocator")
	    meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil)
	    meth2 (vlax-invoke meth1 'ExecQuery "Select * from Win32_ComputerSystem")
	    sapi  (vlax-create-object "Sapi.SpVoice")
      )
      (and (setq ok (vlax-get (vlax-invoke meth2 'itemindex 0) 'username))
	(vlax-invoke sapi "Speak" (strcat "Hello " (vl-string-subst " " "." (substr ok (+ (vl-string-search "\\" ok) 2)))) 0)
      )
      (mapcar 'vlax-release-object (list meth2 meth1 WMI sapi))
      (vl-bb-set 'Patrick_35_Hello T)
    )
  )
  (princ)
)

(c:qui)

 Turn on the loudspeaker

 

@+

0 Likes
Message 10 of 10

patrick_35
Collaborator
Collaborator

Hi

 

If frames are blocks, the lisp I gave and made for it.

 

@+

0 Likes