Hello,
I want to be able to hide plot styles on all documents in a directory.
I have lisp code that can hide plot styles on the current drawing:
Code:
(vl-load-com)
(defun showpstyle ( / DOC LAYOUTS)
(setq doc (vla-get-activedocument (vlax-get-acad-object))
layouts (vla-get-layouts doc)
); setq
(vlax-for n layouts
(vl-catch-all-apply 'vla-put-showplotstyles (list n :vlax-false))
); vlax-for
(vla-regen doc acAllViewports)
(mapcar 'vlax-release-object (list layouts doc))
(princ)
); defun
(showpstyle)
And I have code that can loop through a directory and change things on multiple drawings:
Code:
;; 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)
)
(copyplotconfigs)
I cant figure out how to combine these do hide plot styles on all drawings? Can anyone help me combine these, I dont understand lisp that well especially the vla functions.