try this
(defun C:TEST (/ page_setup config l) (vl-load-com) (or acDoc (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))) (princ "\n************************************\n") (if (and (> (vla-get-Count (setq page_setup (vla-get-plotconfigurations acDoc))) 0) (vlax-for a page_setup (princ (strcat "\n" (car (setq l (cons (vla-get-name a) l)))))) (not (textscr)) (member (setq config (getstring "\nSelect page setup: ")) l) ) (vlax-for layout (vla-get-layouts acDoc) (if (not (eq (strcase (vla-get-name layout)) "MODEL")) (vla-copyfrom layout (vla-item page_setup config)) ) ) ) ;;; (vla-regen acDoc acAllViewPorts) (graphscr) (princ) )
I use the attached lisp file downloaded from theswamp.
Here is another variation, using my List Box function:
(defun c:ps2lay ( / col doc itm lst ) (setq doc (vla-get-activedocument (vlax-get-acad-object)) col (vla-get-plotconfigurations doc) ) (cond ( (zerop (vla-get-count col)) (princ "\nNo Page Setups found.") ) ( (null (setq itm (LM:listbox "Select Page Setup to Apply" (progn (vlax-for x col (setq lst (cons (vla-get-name x) lst))) (acad_strlsort lst) ) 0 ) ) ) (princ "\n*Cancel*") ) ( (setq itm (vla-item col (car itm))) (vlax-for x (vla-get-layouts doc) (if (/= "MODEL" (strcase (vla-get-name x))) (vla-copyfrom x itm) ) ) ) ) (princ) ) ;; List Box - Lee Mac ;; Displays a DCL list box allowing the user to make a selection from the supplied data. ;; msg - [str] Dialog label ;; lst - [lst] List of strings to display ;; bit - [int] 1=allow multiple; 2=return indexes ;; Returns: [lst] List of selected items/indexes, else nil (defun LM:listbox ( msg lst bit / dch des tmp rtn ) (cond ( (not (and (setq tmp (vl-filename-mktemp nil nil ".dcl")) (setq des (open tmp "w")) (write-line (strcat "listbox:dialog{label=\"" msg "\";spacer;:list_box{key=\"list\";multiple_select=" (if (= 1 (logand 1 bit)) "true" "false") ";width=50;height=15;}spacer;ok_cancel;}" ) des ) (not (close des)) (< 0 (setq dch (load_dialog tmp))) (new_dialog "listbox" dch) ) ) (prompt "\nError Loading List Box Dialog.") ) ( t (start_list "list") (foreach itm lst (add_list itm)) (end_list) (setq rtn (set_tile "list" "0")) (action_tile "list" "(setq rtn $value)") (setq rtn (if (= 1 (start_dialog)) (if (= 2 (logand 2 bit)) (read (strcat "(" rtn ")")) (mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" rtn ")"))) ) ) ) ) ) (if (< 0 dch) (unload_dialog dch) ) (if (and tmp (setq tmp (findfile tmp))) (vl-file-delete tmp) ) rtn ) (vl-load-com) (princ)
@dominic.staehli wrote:
It loaded fine but I couldn't get past this dialog;
Replace (getstring "\nSelect page setup: ") with (getstring T "\nSelect page setup: ").
You have to manualy enter the name of page setup, exactly like it apears in list, so Lee's dialog box is more friendly.