Author Topic: Batch Import Page Setups Across Multiple Drawings  (Read 4521 times)

0 Members and 1 Guest are viewing this topic.

Dave M

  • Newt
  • Posts: 196
Batch Import Page Setups Across Multiple Drawings
« on: August 06, 2012, 11:55:48 AM »
I was wondering if anyone has a routine that will batch import (and overwrite if necessary) page setups across multiple drawings?

Thanks

Dave
Civil 3D 2018 - Microstation SS4 - Windows 10 - Dropbox

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Batch Import Page Setups Across Multiple Drawings
« Reply #1 on: August 06, 2012, 12:35:48 PM »
Basically you'll run a script through a batc-script program on multiple DWGs. The script would use the psetupin command.

As an example see my post #13 here: http://forums.augi.com/showthread.php?80461-Page-Setup-Manager

You don't need my MPageSetup routine, unless you also want to set tabs to use the newly imported PageSetups.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Dave M

  • Newt
  • Posts: 196
Re: Batch Import Page Setups Across Multiple Drawings
« Reply #2 on: August 06, 2012, 02:04:40 PM »
Irné,

I downloaded your code, and the script template, both worked great!

Dave
Civil 3D 2018 - Microstation SS4 - Windows 10 - Dropbox

ronjonp

  • Needs a day job
  • Posts: 7533
Re: Batch Import Page Setups Across Multiple Drawings
« Reply #3 on: August 06, 2012, 04:23:31 PM »
You could also try this.
It will process a directory of drawings using odbx removing all pagesetups then copy all the pagesetups found in the current drawing.

Code: [Select]
;; Copies plot configurations from the current drawing
;; to all drawings within a selected folder.
(defun c:copyplotconfigs (/ _getfolder _getplotconfigs adoc dir doc file l n odbx plt v)
  (vl-load-com)
  (defun _getfolder (message / sh folder result)
    (setq sh (vla-getinterfaceobject (vlax-get-acad-object) "Shell.Application"))
    (setq folder (vlax-invoke-method sh 'browseforfolder 0 message 0))
    (vlax-release-object sh)
    (if folder
      (progn (setq result (vlax-get-property (vlax-get-property folder 'self) 'path))
     (if (wcmatch result "*\\")
       result
       (strcat result "\\")
     )
      )
    )
  )
  (defun _getplotconfigs (doc / out)
    (vlax-for x (vla-get-plotconfigurations doc)
      (setq out (cons (cons (strcase (vla-get-name x)) x) out))
    )
  )
  (setq adoc (vla-get-activedocument (setq doc (vlax-get-acad-object))))
  (cond
    ((not (setq l (_getplotconfigs adoc)))
     (princ "\nNo plot configurations in current drawing!")
    )
    ((not (setq odbx (if (< (setq v (substr (getvar 'acadver) 1 2)) "16")
       (vla-getinterfaceobject doc "ObjectDBX.AxDbDocument")
       (vla-getinterfaceobject doc (strcat "ObjectDBX.AxDbDocument." v))
     )
  )
     )
     (princ "\nObject DBX interface not created!")
    )
    ((if
       (setq dir (_getfolder "Select directory to apply current drawing pagesetups to: "))
(foreach f (vl-directory-files dir "*.dwg" 0)
  (setq file (strcat dir f))
  (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list odbx file)))
    (princ (strcase (strcat "\nError opening: " file)))
    (progn (princ (strcat "\nOpening: " file))
   (setq plt (vla-get-plotconfigurations odbx))
   (if (not (zerop (setq n (vla-get-count plt))))
     (progn (princ (strcat "\n\t" (itoa n) " - plot configurations removed"))
    (vlax-map-collection plt 'vla-delete)
     )
   )
   (and (vlax-invoke adoc 'copyobjects (mapcar 'cdr l) plt nil)
(princ (strcat "\n\t"
       (itoa (length l))
       " - plot configurations copied from current drawing"
       )
)
   )
   (vla-saveas odbx (vla-get-name odbx))
    )
  )
)
(princ "\nBuh bye...")
     )
    )
  )
  (princ)
)
(c:copyplotconfigs)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC