So I decided to take a different approach and found some ODBX code and I added your code, Lee, and it's working to an extent. It's bringing in the page setup but it's not setting it as the default for each view. Any thoughts? Thanks for the help.
;; 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 "*.dwt" 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"
)
)
(applypstolayouts "My Page Setup 1")
)
(vla-saveas odbx (vla-get-name odbx))
)
)
)
(princ "\nBuh bye...")
)
)
)
(princ)
)
(defun applypstolayouts ( cfg / doc rtn )
(if
(setq rtn
(not
(vl-catch-all-error-p
(setq cfg
(vl-catch-all-apply 'vla-item
(list
(vla-get-plotconfigurations
(setq doc
(vla-get-activedocument
(vlax-get-acad-object)
)
)
)
cfg
)
)
)
)
)
)
(vlax-for lay (vla-get-layouts doc)
(if (= :vlax-false (vla-get-modeltype lay))
(vla-copyfrom lay cfg)
)
)
)
rtn
)