Search the Community
Showing results for tags 'switch back'.
-
Script. Save, Open, Close, Switch back to original DWG
svorgodne posted a topic in AutoLISP, Visual LISP & DCL
I am creating a copy from a drawing with Autolisp and creating a script which will be dettaching all xrefs on the copy. After saving the copy, the last command of the script is "close", then I would like to go back to the original drawing from where the copy was made from. This is not happening if there are some other drawings opened, then it makes active the last opened drawing. I need an automatic process since I will not be the final user and they might get confused. Here it is the code: (defun run (/ mc_scr) (setq switch_dwg (strcat (getvar 'dwgprefix) (getvar 'dwgname) ) ) (setq mc_scr (open (strcat (getenv "temp") "\\mc.scr") "w")) (foreach mem0 (list "open" (strcat "\"" new_c "\"") "(setq opn_dwg_lst nil)" "(vlax-for" " x" " (vla-get-documents" " (vlax-get-acad-object)" " )" " (setq opn_dwg_lst (cons x opn_dwg_lst))" ")" "-xref" "d" "*" "-purge" "a" "*" "n" "_ucs" "_w" "_plan" "_w" "_zoom" "_e" "(foreach SYM_MEM opn_dwg_lst" " (if " " (=" " (strcat" " \"A\"" " (substr" " (getvar \"dwgname\")" " 2" " )" " )" " (vla-get-name SYM_MEM)" " )" " (setq SYM_A SYM_MEM)" " )" ")" "qsave" "close" "(vla-activate SYM_A)" ) (write-line mem0 mc_scr) ) (close mc_scr) ) (defun mc (/ new_c mc) (setvar 'CMDECHO 0) (if (= (substr (getvar 'dwgname) 1 2 ) "A_" ) (progn (command "qsave") (setq new_c (strcat (getvar 'dwgprefix) (vl-string-subst "B_" "A_" (getvar 'dwgname)) ) ) (cond ( (/= (findfile new_c) nil) (command "save" new_c "y") (run) ) (T (command "save" new_c) (run) ) ) (command "script" (strcat (getenv "temp") "\\mc.scr")) ) ) (setvar 'CMDECHO 1) (princ) ) (mc) Any clue? thanks in advance Svorgodne