;--- Projektverwaltung Hauptprogramm ------------------------------------------- (defun pvw_main ( / a accept dcl dwgname dlg_titel dlg_val dwg_exist_dlg dwg_exist_lst dwg_new dwg_new_ok dwg_new_scr dwg_proto proj_ch proj_del proj_main proj_new proj_new_ok proj_sort proj_val write_val) ;--- schreibt Script-Datei ---------------------------------------------------- (defun dwg_new_scr (dwg_new name proto scale / file) (setq file (open (strcat (getenv "PRIVATE") "\\START.SCR") "w")) (if dwg_new (progn (if proto (progn (princ "100.0\n_.NEW\n_Y\n" file) (princ (strcat name "=" proto) file) ) (progn (princ (strcat "(s::STARTUP)\n" (rtos scale 2 0) "\n_.SAVEAS\n" name) file) (if (findfile dwgname) (princ "\n_Y" file) (princ "\n" file)) )) ;if+progn ) (progn (princ "_.NEW\n" file) (if (/= (getvar "DBMOD") 0) (princ "_Y\n" file)) (princ name file) (if proto (princ (strcat "=" proto) file)) (if (findfile name) (princ "\n_Y" file)) (if (not proto) (print scale file) (princ "\n" file)) )) ;if+progn (close file) nil ) ;defun dwg_new_scr ;--- bestehende Zeichnung über Dialogfenster öffnen ---------------------------- (defun dwg_exist_dlg ( / a dwgname dwg_lst i path proj) (setq dwgname (getfiled "bestehende Zeichnung öffnen" (nth 1 (nth pvw:curr pvw:lst)) "dwg" 0)) (if dwgname (progn (setq dwgname (substr dwgname 1 (- (strlen dwgname) 4)) path dwgname) (while (/= (substr path (strlen path)) "\\") (setq path (substr path 1 (1- (strlen path))))) (setq dwgname (substr dwgname (1+ (strlen path)))) ;--- sucht Projekt zur gewählten Zeichnung --- (setq i 0) (repeat (length pvw:lst) (if (= path (nth 1 (nth i pvw:lst))) (setq a i)) (setq i (1+ i)) ) ;repeat (if a (setq pvw:curr a proj (nth pvw:curr pvw:lst) dwg_lst (cddr proj) dwg_lst (del_lst dwgname dwg_lst) a (list (nth 0 proj) (nth 1 proj) dwgname (nth 0 dwg_lst) (nth 1 dwg_lst) (nth 2 dwg_lst)) pvw:lst (subst a proj pvw:lst)) ) ;if (done_dialog 1) (strcat path dwgname ".DWG") ) nil) ;if+progn ) ;defun dwg_exist_dlg ;--- bestehende Zeichnung aus Liste 4 Zeichnungen öffnen ----------------------- (defun dwg_exist_lst ( / a dwgname dwg_lst path proj) (setq proj (nth pvw:curr pvw:lst) path (nth 1 proj) dwgname (nth (+ 2 (atoi (get_tile "dwg"))) proj) dwg_lst (cddr proj) dwg_lst (del_lst dwgname dwg_lst) a (list (nth 0 proj) (nth 1 proj) dwgname (nth 0 dwg_lst) (nth 1 dwg_lst) (nth 2 dwg_lst)) pvw:lst (subst a proj pvw:lst)) (done_dialog 1) (strcat path dwgname ".DWG") ) ;defun dwg_exist_lst ;------------------------------------------------------------------------------- ;--- Verwaltung Projekte ------------------------------------------------------- ;------------------------------------------------------------------------------- ;--- Dialogfenster Projekte ---------------------------------------------------- (defun proj_main (dcl / tmp1 tmp2) (setq tmp1 pvw:lst tmp2 pvw:curr) (new_dialog "projekte" dcl) (dlg_titel) (proj_val) (action_tile "new" "(proj_new dcl)") (action_tile "del" "(proj_del dcl)") (action_tile "ch" "(proj_ch dcl)") (action_tile "lst" "(setq pvw:curr (atoi (get_tile \"lst\")))") (if (= (start_dialog) 0) (setq pvw:lst tmp1 pvw:curr tmp2)) (dlg_val) nil ) ;defun proj_main ;--- weist Werte im Dialogfenster Projekte zu ---------------------------------- (defun proj_val ( / ) (if pvw:lst (progn (start_list "lst") (mapcar '(lambda (x) (add_list (car x))) pvw:lst) (end_list) (set_tile "lst" (itoa pvw:curr)) ) (mapcar '(lambda (x) (mode_tile x 1)) '("del" "ch"))) nil ) ;defun proj_val ;--- Projekt löschen ----------------------------------------------------------- (defun proj_del (dcl / ) (new_dialog "del" dcl) (dlg_titel) (set_tile "text" (car (nth pvw:curr pvw:lst))) (if (= (start_dialog) 1) (setq pvw:lst (del_lst (nth pvw:curr pvw:lst) pvw:lst) pvw:curr 0)) (proj_val) nil ) ;defun proj_del ;--- Projekt ändern ------------------------------------------------------------ (defun proj_ch (dcl / alt neu proj) (setq alt (nth pvw:curr pvw:lst)) (new_dialog "new" dcl) (dlg_titel) (set_tile "proj" (nth 0 alt)) (set_tile "path" (nth 1 alt)) (action_tile "accept" "(setq neu (proj_new_ok \"ch\"))") (if (= (start_dialog) 1) (progn (setq proj (list (nth 0 neu) (nth 1 neu))) (setq i 2) (repeat 4 (if (nth i alt) (if (findfile (strcat (nth 1 neu) (nth i alt) ".DWG")) (setq proj (append proj (list (nth i alt)))) (setq proj (append proj (list (nth i neu)))) )) ;if+if (setq i (1+ i)) ) ;repeat (setq pvw:lst (subst proj alt pvw:lst)) )) ;if+progn (proj_sort) (setq pvw:curr (index_lst proj pvw:lst)) (proj_val) nil ) ;defun proj_ch ;--- Projekt hinzufügen -------------------------------------------------------- (defun proj_new (dcl / proj) (new_dialog "new" dcl) (dlg_titel) (action_tile "accept" "(setq proj (proj_new_ok \"new\"))") (if (= (start_dialog) 1) (setq pvw:curr (length pvw:lst) pvw:lst (append pvw:lst (list proj)))) (proj_sort) (setq pvw:curr (index_lst proj pvw:lst)) (proj_val) nil ) ;defun proj_new ;--- wenn DLG Projekt hinzufügen OK -------------------------------------------- (defun proj_new_ok (opt / i name path) (set_tile "error" "") (setq name (get_tile "proj") path (strcase (get_tile "path"))) (if (/= (substr path (strlen path)) "\\") (setq path (strcat path "\\"))) (if (= opt "new") (progn (setq i 0) (repeat (length pvw:lst) (if (= (nth 0 (nth i pvw:lst)) name) (set_tile "error" "Bezeichnung existiert bereits")) (if (= (nth 1 (nth i pvw:lst)) path) (set_tile "error" "Verzeichnis wurde für anderes Projekt angegeben")) (setq i (1+ i)) ) ;repeat )) ;if+progn (if (= (get_tile "error") "") (progn (done_dialog 1) (mapcar '(lambda (x) (mode_tile x 0)) '("del" "ch")) )) ;if+progn (list name path "" "" "" "") ) ;defun proj_new_ok ;--- sortiert Projekte alphabetisch -------------------------------------------- (defun proj_sort ( / i name tmp) (setq name (acad_strlsort (mapcar 'car pvw:lst))) (setq i 0) (repeat (length name) (setq a (assoc (nth i name) pvw:lst) path (nth 1 a) b nil) (if (nth 2 a) (if (findfile (strcat path (nth 2 a) ".DWG")) (setq b (append b (list (nth 2 a)))))) (if (nth 3 a) (if (findfile (strcat path (nth 3 a) ".DWG")) (setq b (append b (list (nth 3 a)))))) (if (nth 4 a) (if (findfile (strcat path (nth 4 a) ".DWG")) (setq b (append b (list (nth 4 a)))))) (if (nth 5 a) (if (findfile (strcat path (nth 5 a) ".DWG")) (setq b (append b (list (nth 5 a)))))) (repeat (- 4 (length b)) (setq b (append b '("")))) (setq tmp (append tmp (list (append (list (nth i name) path) b)))) (setq i (1+ i)) ) ;repeat (setq pvw:lst tmp) nil ) ;defun proj_sort ;------------------------------------------------------------------------------- ;--- Dialogfensterverwaltung --------------------------------------------------- ;------------------------------------------------------------------------------- ;--- schreibt Titel in Dialogfenster ------------------------------------------- (defun dlg_titel ( / ) (if (= curr_app "ARCH") (set_tile "dlg_titel" "Projektverwaltung AutoCAD r14 - Architektur")) (if (= curr_app "BEW" ) (set_tile "dlg_titel" "Projektverwaltung AutoCAD 2004")) (if (= curr_app "TIEF") (set_tile "dlg_titel" "Projektverwaltung AutoCAD r14 - Tiefbau")) (if (= curr_app "VERM") (set_tile "dlg_titel" "Projektverwaltung AutoCAD r14 - Vermessung")) nil ) ;defun dlg_titel ;--- schreibt Werte in Haupt-Dialogfenster ------------------------------------- (defun dlg_val ( / a i) (if pvw:lst (progn ;wenn Projekte vorhanden (mapcar '(lambda (x) (mode_tile x 0)) '("new" "dwg" "exist")) (setq a (nth pvw:curr pvw:lst)) (set_tile "name" (car a)) (set_tile "path" (strcat " Pfad: " (cadr a))) (start_list "dwg") (setq i 2) (repeat 4 (if (nth i a) (add_list (nth i a))) (setq i (1+ i)) ) ;repeat (end_list) ) (progn ;wenn keine Projekte vorhanden (mapcar '(lambda (x) (mode_tile x 1)) '("new" "dwg" "exist")) (set_tile "name" "keine Projekte vorhanden!!!") (set_tile "path" "") (start_list "dwg") (mapcar 'add_list '("" "" "" "")) (end_list) )) ;if+progn nil ) ;defun dlg_val ;--- schreibt aktuelle Werte in Datei ------------------------------------------ (defun write_val ( / a file i j path) (setq file (open (strcat (getenv "PRIVATE") "/" curr_app ".LST") "w")) (if file (progn (princ (strcat "(setq pvw:curr " (itoa pvw:curr) ")") file) (princ "\n(setq pvw:lst (list" file) (setq i 0) (repeat (length pvw:lst) (princ "\n (list" file) (princ (strcat " \"" (nth 0 (nth i pvw:lst)) "\"") file) (princ " \"" file) (setq path (nth 1 (nth i pvw:lst))) (while (> (setq a (pos_char path "\\")) 0) (princ (strcat (substr path 1 a) "\\") file) (setq path (substr path (1+ a))) ) ;while (princ "\"" file) (setq j 2) (repeat 4 (if (nth j (nth i pvw:lst)) (princ (strcat " \"" (nth j (nth i pvw:lst)) "\"") file) (princ " nil" file) ) ;if (setq j (1+ j)) ) ;repeat (princ ")" file) (setq i (1+ i)) ) ;repeat (princ "\n))" file) (close file) )) :if+progn nil ) ;defun write_val ;--- MAIN (pvw_main) ----------------------------------------------------------- (load (strcat (getenv "PRIVATE") curr_app ".LST")) (proj_sort) (setq nc T) (while nc (setq dcl (load_dialog "PVW")) (new_dialog "main" dcl) (dlg_titel) (dlg_val) (action_tile "end" "(done_dialog 2)") (action_tile "proj" "(proj_main dcl)") (action_tile "exist" "(setq dwgname (dwg_exist_dlg))") (action_tile "new" "(dwg_new dcl)") (action_tile "dwg" "(setq accept T)") (action_tile "nc" "(done_dialog 4)") (action_tile "accept" "(if accept (setq dwgname (dwg_exist_lst)))") (setq a (start_dialog)) (unload_dialog dcl) (if (> a 0) (write_val)) (if (= a 4) (command "NC") (setq nc nil) ) ;if ) ;while (setq file_write (open "c:\\Programme\\AutoCAD 2000i Deu\\bew_sofi_r20i\\open.scr" "w")) (write-line "_open" file_write) (write-line (strcat "\"" dwgname "\"") file_write) (close file_write) ; (if (= a 0) (if (not text_write) (s::STARTUP))) ; (if (= a 1) ; (if (= (getvar "DBMOD") 0) ; (command "_script" "open.scr") (command "_script" "c:\\Programme\\AutoCAD 2000i Deu\\bew_sofi_r20i\\open.scr") ; ) ;if ; ) ;if (if (= a 2) (if (= (getvar "DBMOD") 0) (command "_.QUIT") (command "_.QUIT" "_Y"))) (if (= a 3) (command "_.SCRIPT" (strcat (getenv "PRIVATE") "\\START"))) (prin1) ) ;defun pvw_main ;--- Abfrage Änderungen sichern ------------------------------------------------ (defun pvw_dwg_save ( / dcl file return save) (setq return T) (if (/= (getvar "DBMOD") 0) (progn (setq dcl (load_dialog "ACAD.DCL")) (if (< dcl 1) (progn (alert "kann die Dialogfensterdatei \"ACAD.DCL\" nicht finden - Abbruch") (exit))) (new_dialog "acad_dwgmod" dcl) (action_tile "save" "(done_dialog 2)") (action_tile "cancel" "(done_dialog 0)") (action_tile "discard" "(done_dialog 1)") (setq a (start_dialog)) (unload_dialog dcl) (if (= a 0) (setq return nil)) (if (= a 2) (command "_.QSAVE")) )) ;if+progn return ) ;defun pvw_dwg_save ;--- Befehlsdefinition --------------------------------------------------------- (defun c:PVW () ; (if (pvw_dwg_save) (pvw_main)) (pvw_main) (prin1) ) ;defun c:PVW