0 Members and 1 Guest are viewing this topic.
;; 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)