(defun ai_abort (app msg) (defun-q *error* (s) (if old_error (setq *error* old_error)) (princ) ) (if msg (alert (strcat " Anwendungsfehler: " app " \n\n " msg " \n" ) ) ) (exit) ) ;;; Check to see if AI_UTILS is loaded, If not, try to find it, ;;; and then try to load it. ;;; ;;; If it can't be found or it can't be loaded, then abort the ;;; loading of this file immediately, preserving the (autoload) ;;; stub function. (cond ( (and ai_dcl (listp ai_dcl))) ; it's already loaded. ( (not (findfile "ai_utils.lsp")) ; find it (ai_abort "DDINSERT" (strcat "Kann AI_UTILS.LSP datei nicht finden." "\n Bitte im Support Verzeichnis nachschauen."))) ( (eq "failed" (load "ai_utils" "failed")) ; load it (ai_abort "DDINSERT" "Kann AI_UTILS.LSP nicht laden.")) ) (if (not (ai_acadapp)) ; defined in AI_UTILS.LSP (ai_abort "DDINSERT" nil) ; a Nil supresses ) ; ai_abort's alert box dialog. ;;; ==================== end load-time operations =========================== (defun c:ddnum ( / w e li ap_size res ip modes moder cdxt_error st_mod potlo potlo0 _numsv _numsh _numi nstyle_act ngetindex ins_datei list_blocks do_selection bl_name check_i pat_match check_name textopt insopt att_pos swahl tkreis tbox telip toval tdrei shght htht swidht width nset_tile_style slist sname tstyle act_textopt act_insopt ) (defun modes (a) (setq mlst '()) (repeat (length a) (setq mlst (append mlst (LIST (LIST (car a) (getvar (car a)))))) (setq a (cdr a))) ) (defun moder () (repeat (length mlst) (SETVAR (caar mlst) (cadar mlst)) (setq mlst (cdr mlst)) ) ) (defun ddnum_insert (w / ) (setq e w) (while (car w) (if (and (findfile (car w)) (not (tblsearch "BLOCK" (substr (car w) 1 (- (strlen (car w)) 4)))) ) (progn (command "_insert" (car w)) (command) ) ) (setq w (cdr w)) ) ) ;---------------------------------------------------------- (modes '("textstyle" "textsize" "ucsicon" "gridmode" "pickbox")) ;bet”lti a blockokat (ddnum_insert '("DDC-BOX.DWG" "NUMCEL.DWG" "DCSPOS.DWG" "RNR.DWG")) ;a1 a2 globalis (if (or (not a1) (not a2)) (setq a1 "1" a2 "0")) (if (not numi) (setq numi "100")) ;kezdeti ertek (if (not a3) (setq a3 "1")) ;text/attribut - default INSERT (if (not numsv) (setq numsv "")) ;string elol (if (not numsh) (setq numsh "")) ;string hatul (if (not attpos) (setq attpos "1")) (if (not inc) (setq inc "1")) (if (not _bw) (setq _bw "1")) (if (not cstil)(setq cstil (getvar "textstyle"))) (if (not csize)(setq csize (getvar "textsize"))) (if (not wsize)(setq wsize 1.0)) (if (not _sklfkt) (setq _sklfkt "1")) (setq numi_s 0) ;---------------------------------------------------------- (defun att_list ( / ali) (setq ali '()) (if (and blk_name1 (member blk_name1 table_list) ) (progn (set_tile "error" "") (setq v (tblsearch "BLOCK" blk_name1)) (setq e (cdr (assoc -2 v))) (while e (if (= "ATTDEF" (cdr (assoc 0 (entget e)))) (setq ali (cons (cdr (assoc 2 (entget e))) ali)) ) (setq e (entnext e)) ) (if (> (1+ (atoi attpos)) (length ali)) (progn (setq attpos "0") (set_tile "stnum_attpos" attpos) ) ) (if (not ali) (set_tile "error" "Kein Attribut in Block")) ) (progn (set_tile "error" "Kein Blockname") (setq _bw "1") (set_tile "bwahl" _bw) ) ) (setq ali (reverse ali)) (start_list "attlist" 3) (mapcar 'add_list ali) (end_list) (set_tile "attlist" attpos) ) ;---------------------------------------------------------- (defun cdxt_error (s) (moder) (if (/= s "Funktion abgebrochen.") (princ (strcat "\nFehler: " s)) ) (if olderr (setq *error* olderr)) (princ) ) ;-------------------------------------------------------- ;---------------------------------------------------------- ;_e entity name ;_ww lista az uj ertekekkel (defun st_mod (_e _ww / d) (if (and (= "INSERT" (cdr (assoc 0 (entget _e)))) (= 1 (cdr (assoc 66 (entget _e)))) ) (progn (while (and (car _ww) (/= "SEQEND" (cdr (assoc 0 (entget _e))))) (setq d (entget (entnext _e))) (setq d (subst (cons 1 (car _ww)) (assoc 1 d) d)) (if (/= "" (car _ww)) (entmod d)) (setq _e (entnext _e)) (setq _ww (cdr _ww)) ) ) ) ) ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;a stringet kipotolja a megadott hosszra (defun potlo (_c _w / n w ) (if (>= (setq n (strlen _w)) _c) (substr _w 1 _c) (repeat (- _c n) (setq _w (strcat _w " "))) ) ) ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;a stringet kipotolja a megadott hosszra (defun potlo0 (_c _w / n w ) (if (/= 0 _c) (progn (if (>= (setq n (strlen _w)) _c) (substr _w 1 _c) (repeat (- _c n) (setq _w (strcat "0" _w))) ) ) _w ) ) ;.......................................................... (defun _numsv (_w1) (set_tile "stnum_tp1" (strcat _w1 (potlo0 numi_s numi) numsh)) (setq numsv (get_tile "stnum_vorn")) ) (defun _numsh (_w1) (set_tile "stnum_tp1" (strcat numsv (potlo0 numi_s numi) _w1)) (setq numsh (get_tile "stnum_hinten")) ) (defun _numi (_w1) (set_tile "stnum_tp1" (strcat numsv _w1 numsh)) (setq numi (get_tile "stnum_start")) (if (= "0" (substr numi 1 1)) (setq numi_s (strlen numi)) (setq numi_s 0) ) (if (and (/= "0" numi) (= 0 (atoi numi))) (progn (set_tile "error" "Startnummer muss Ganzzahl sein!") (mode_tile "accept" 1) (mode_tile "stnum_start" 2) ) (mode_tile "accept" 0) ) ) ;.......................................................... ;; ;; Style setting for Attributes and Text. Reads symbol table for popup list ;; box. ;; (defun nset_tile_style (/ sname style-idx) (setq slist (list (cdr (assoc 2 (tblnext "STYLE" T))))) (while (setq sname (cdr (assoc 2 (tblnext "STYLE")))) (if (/= sname "") (setq slist (cons sname slist))) ) (setq slist (acad_strlsort slist)) ; alphabetize style list (start_list "style") (mapcar 'add_list slist) (end_list) (setq tstyle cstil) (setq style-idx (ngetindex tstyle slist)) (set_tile "style" (itoa style-idx)) ) ;; Style action. Reset widget values to style defaults ;; (defun nstyle_act (index / style-list) (mode_tile "csize" 0) (setq style-idx (atoi index)) (setq tstyle (nth style-idx slist)) (setq cstil tstyle) (setq style-idx (itoa style-idx)) (set_tile "style" style-idx) (setq style-list (tblsearch "style" tstyle)) (setq shght (cdr (assoc 40 style-list))) (setq swidth (cdr (assoc 41 style-list))) (if (/= shght 0) (progn (setq hght shght) (set_tile "csize" (rtos hght)) ;(set_tile "wsize" (rtos hght)) (mode_tile "csize" 1) ) ) (if (/= swidth 0) (progn (setq width swidth) ;(set_tile "csize" (rtos hght)) (set_tile "wsize" (rtos hght)) (mode_tile "wsize" 1) ) ) ) ;; If an item is a member of the list, then return its index number, else ;; return nil. ;; (defun ngetindex (item itemlist / m n) (setq n (length itemlist)) (if (> (setq m (length (member item itemlist))) 0) (- n m) nil ) ) ;................................................................ (defun textopt ( / w) (if (not (new_dialog "textopt" dcl_id)) (exit)) (setq shght (cdr (assoc 40 (tblsearch "style" cstil)))) (if (not swidth) (setq swidth (cdr (assoc 41 (tblsearch "style" cstil))))) (if (/= shght 0) (progn (setq hght shght ) (set_tile "csize" (rtos hght)) (mode_tile "csize" 1) ) (mode_tile "csize" 0) ) (if (/= swidth 1.0) (progn (setq width swidth) (set_tile "wsize" (rtos width)) ;(mode_tile "wsize" 1) ) (mode_tile "wsize" 0) ) (nset_tile_style) (cond ((= "tkreis" _tk) (set_tile "tkreis" "1")) ((= "tbox" _tk) (set_tile "tbox" "1")) ((= "telip" _tk) (set_tile "telip" "1")) ((= "toval" _tk) (set_tile "toval" "1")) ((= "tdrei" _tk) (set_tile "tdrei" "1")) (t (set_tile "tkein" "1")) ) (cond ((= "1" _tw) (set_tile "twahl" "1"))) (set_tile "csize" (rtos csize)) (action_tile "tkreis" "(setq _tk \"tkreis\")") (action_tile "tbox" "(setq _tk \"tbox\")") (action_tile "telip" "(setq _tk \"telip\")") (action_tile "toval" "(setq _tk \"toval\")") (action_tile "tdrei" "(setq _tk \"tdrei\")") (action_tile "tkein" "(setq _tk nil)") (action_tile "twahl" "(setq _tw $value)") (action_tile "cancel" "(done_dialog)") (action_tile "style" "(nstyle_act $value)") (action_tile "csize" "(setq csize (atof $value))") (action_tile "wsize" "(setq wsize (atof $value))") (action_tile "accept" "(done_dialog)") (setq what_new (start_dialog)) (setvar "textstyle" cstil) (setvar "textsize" csize) (setq swidth wsize) ) ;.......................................................... (defun insopt ( / ins_datei) (setq table_list (ai_table "block" 14)) ; no anonymous, Xrefs or ;......................................................... ;................................................ (defun list_blocks() (setq bl_match '()) (if (not (new_dialog "list_blocks" dcl_id)) (exit)) (if (not pat) (setq pat "*")) (set_tile "pattern" pat) (pat_match pat) (action_tile "bl_match" "(bl_name)") (action_tile "pattern" "(pat_match (setq pat (strcase $value)))") (action_tile "selection" "(do_selection)") ;(action_tile "block_select" "(done_dialog 62)") (action_tile "accept" "(if (check_i)(progn (done_dialog 1)(att_list)))") (action_tile "cancel" "(setq blk_name1 nil)(done_dialog 0)") (setq what_new (start_dialog)) (cond ((= 1 what_new) (set_tile "bname" blk_name1))) ) ;; ;; If a name is typed, check to see if block with that name exists in the ;; drawing. ;; (defun do_selection() (set_tile "bl_match" "") (setq blk_name1 (strcase $value)) (check_i) ) ;; ;; Display the selected block name in the edit box. ;; (defun bl_name() (set_tile "error" "") (set_tile "selection" (setq blk_name1 (nth (atoi $value) bl_match))) ) ;; ;; Confirms that a block with the entered name exists in the drawing. ;; (defun check_i() (if (member blk_name1 table_list) (progn (set_tile "error" "") T ) (progn (set_tile "error" "Ungueltiger Blockname.") (mode_tile "selection" 2) nil ) ) ) ;; ;; This function displays the block list based on the pattern. ;; (defun pat_match (pat) (setq bl_match '()) (foreach n table_list (if (wcmatch n pat) (setq bl_match (cons n bl_match)) ) ) (if (>= (getvar "maxsort") (length bl_match)) ; Alphabetise if greater (if bl_match (setq bl_match (acad_strlsort bl_match))) ; than maxsort. ) (start_list "bl_match") (mapcar 'add_list bl_match) (end_list) ) ;; ;; This function checks the validity of the Block name. If legitimate, the ;; Block name is returned, nil otherwise. ;; (defun check_name(name) (if (not (or (not name) (= "" name) (wcmatch name "*[]`#`@`.`?`*`~`[`,`'!%^&()+={}|`\\:;\"<>/]*") ) ) name ) ) ;; ;................................................ (defun att_pos (w) (setq attpos w) (set_tile "attlist" attpos) ) ;................................................ (defun bwahl (w) (setq _bw w) (cond ((= "1" _bw) (set_tile "bwahl" "1") (mode_tile "sklfkt" 1) (mode_tile "bname" 1) (mode_tile "list_blocks" 1) (mode_tile "attlist" 1) ) ((= "0" _bw) (set_tile "bwahl" "0") (mode_tile "sklfkt" 0) (mode_tile "bname" 0) (mode_tile "list_blocks" 0) (mode_tile "attlist" 0) ) ) ) ;................................................ (if (not blk_name1)(setq blk_name1 "")) (if (not _bw) (setq _bw "1")) (if (not (new_dialog "insopt" dcl_id)) (exit)) ;(setq what_new 10) ;(while (> what_new 9) (bwahl _bw) (att_list) (set_tile "bname" blk_name1) (set_tile "stnum_attpos" attpos) (set_tile "attlist" attpos) (set_tile "sklfkt" _sklfkt) (action_tile "bname" "(setq blk_name1 (strcase $value))(att_list)") (action_tile "list_blocks" "(list_blocks)") (action_tile "attlist" "(set_tile \"stnum_attpos\" \(setq attpos $value\))") (action_tile "bwahl" "(bwahl $value)") (action_tile "stnum_attpos" "(att_pos $value)") (action_tile "sklfkt" "(setq _sklfkt $value)") (action_tile "cancel" "(done_dialog)") (action_tile "accept" "(done_dialog)") (setq what_new (start_dialog)) ;(print what_new) ;) ;(cond ((= what_new 62) (done_dialog))) ) ;.......................................................... ;_w1 point ;_w2 string (defun tkreis (_w1 _w2 _w3 / kor w tb ll ur ab e ww) (if (not _w1) (progn (setvar "ucsicon" 0) (command "_ucs" "_E" _w3) (setq tb (textbox (entget _w3)) ll (car tb) ur (cadr tb) ab (distance ll ur) _w1 (trans (polar ll (angle ll ur) (/ ab 2.0)) 1 0) ) (command "_ucs" "_w") ) ) (setq w csize) (if (/= shght 0) (setq w shght)) (if (/= swidth 0) (setq ww swidth)) (if (>= (strlen _w2) 3) (setq kor (* ww (strlen _w2) w 0.5)) (setq kor (* w 1.2))) (command "_circle" _w1 kor) ) ;.......................................................... ;_W1 point ;_w2 ename (defun tbox (_w1 _w2 / tb ll ur ul lr) (setvar "ucsicon" 0) (command "_ucs" "_e" _w2) (setq tb (textbox (entget _w2)) ll (car tb) ur (cadr tb) ul (list (car ll) (cadr ur)) lr (list (car ur) (cadr ll)) ) (if (not _w1) (setq _w1 (trans (polar ll (angle ll ur) (/ (distance ll ur) 2.0)) 1 0))) (command "_pline" ll "_w" 0 0 lr ur ul "_c") (command "_ucs" "_p") (command "_scale" "_l" "" _w1 1.5) (redraw _w2) ) ;.......................................................... ;_W1 point ;_w2 ename (defun toval (_w1 _w2 / tb ll ur ul lr) (setvar "ucsicon" 0) (command "_ucs" "_e" _w2) (setq tb (textbox (entget _w2)) ll (car tb) ur (cadr tb) ul (list (car ll) (cadr ur)) lr (list (car ur) (cadr ll)) ) (if (not _w1) (setq _w1 (trans (polar ll (angle ll ur) (/ (distance ll ur) 2.0)) 1 0))) (command "_pline" ll "_w" 0 0 lr "_a" ur "_l" ul "_a" ll "") (command "_ucs" "_p") (command "_scale" "_l" "" _w1 1.5) (redraw _w2) ) ;.......................................................... (defun pitagc_a ( _w1 _w2 / ) (expt (- (* _w1 _w1) (* _w2 _w2)) 0.5) ) (defun tdrei (_w1 _w2 / tb ll ur ul lr p3 os) (setvar "ucsicon" 0) (setq os (getvar "osmode")) (setvar "osmode" 0) (command "_ucs" "_e" _w2) (setq tb (textbox (entget _w2)) ll (car tb) ur (cadr tb) ul (list (car ll) (cadr ur)) lr (list (car ur) (cadr ll)) ) (setq p3 (polar (polar ll 0 (/ (distance ll lr) 2.0)) (/ pi 2.0) (pitagc_a (distance ll lr)(/ (distance ll lr) 2.0)))) (if (not _w1) (setq _w1 (trans (polar ll (angle ll ur) (/ (distance ll ur) 2.0)) 1 0))) ;(command "_pline" ll "_w" 0 0 lr p3 "_c") (command "_pline" ll "_w" 0 0 lr p3 "_c") ;(print (list tb ll lr _w1)) (command "_ucs" "_p") (command "_scale" "_l" "" _w1 2.2) (setvar "osmode" os) (redraw _w2) ) ;.......................................................... (defun act_textopt () (setq a3 "0") (mode_tile "num_textopt" 0) (mode_tile "num_insopt" 1) ;(mode_tile "stnum_attpos" 1) ) (defun act_insopt () (setq a3 "1") (mode_tile "num_insopt" 0) (mode_tile "num_textopt" 1) ;(mode_tile "stnum_attpos" 0) ) ;.......................................................... ;_W1 point ;_w2 ename (defun telip (_w1 _w2 / w tb ll ab w1 w2 w3) (setq w csize) (if (/= shght 0) (setq w shght)) (setvar "ucsicon" 0) (command "_ucs" "_e" _w2) (setq tb (textbox (entget _w2)) ll (car tb) ur (cadr tb) ab (distance ll ur) w1 (polar ll (angle ll ur) (/ ab 2.0)) w2 (polar w1 0 (* 0.8 ab)) w3 (polar w1 (/ pi 2.0) (/ ab 3.0)) ) (if (< (* 1.5 (distance w1 w3)) w) (setq w3 (polar w1 (/ pi 2.0) w) w2 (polar w1 0 (* 1.2 ab)) ) ) (command "_ellipse" "_c" w1 w2 w3) (command "_ucs" "_p") ) ;.......................................................... (if (< (setq dcl_id (load_dialog "ddnum.dcl")) 0) (exit)) ;hibakezeles (setq olderr *error* *error* cdxt_error ) (setq what_new 101) (while (< 100 what_new) (if (not (new_dialog "ddnum" dcl_id)) (exit)) (mode_tile "stnum_start" 2) (cond ((= "1" a1) (set_tile "st_weiter" a1)) ((= "1" a2) (set_tile "st_undo" a2)) (T (set_tile "st_konst" "1")) ) ;;(set_tile "stnum_attpos" attpos) (set_tile "stnum_inc" inc) (if (= a3 "1") (progn (set_tile "st_attr" "1") (mode_tile "num_textopt" 1) ) (progn (set_tile "st_text" "1") (mode_tile "num_insopt" 1) (mode_tile "stnum_attpos" 1) ) ) (set_tile "stnum_vorn" numsv) (set_tile "stnum_hinten" numsh) (if (= (type numi) 'INT) (setq numi (itoa numi))) (set_tile "stnum_start" (potlo0 numi_s numi)) (set_tile "stnum_tp1" (strcat numsv (potlo0 numi_s numi) numsh)) (action_tile "st_attr" "(act_insopt)") (action_tile "st_text" "(act_textopt)") ;(action_tile "stnum_attpos" "(setq attpos $VALUE)") (action_tile "num_textopt" "(textopt)") (action_tile "num_insopt" "(insopt)") (action_tile "stnum_inc" "(setq inc $VALUE)") (action_tile "stnum_vorn" "(_numsv $VALUE)") (action_tile "stnum_hinten" "(_numsh $VALUE)") (action_tile "stnum_start" "(_numi $VALUE)") (action_tile "num_start" "(done_dialog 101)") (action_tile "cancel" "(done_dialog 5)") (action_tile "help" "(acad_helpdlg \"shilfe.hlp\" \"DDNUM\")") (action_tile "st_weiter" "(setq a1 $value a2 \"0\")") (action_tile "st_undo" "(setq a2 $value a1 \"0\")") (action_tile "st_konst" "(setq a1 nil a2 nil)") (setq what_new (start_dialog)) (cond ((= what_new 101) (cond ((and (= _bw "1")(= a3 "1")) (setq w (atoi numi)) (cond ((not attpos) (setq attpos "2"))) (setq li nil) (setq li (repeat (atoi attpos) (setq li (cons "" li)))) (setq _pckbox (getvar "pickbox")) (setvar "pickbox" 8) (while (setq e (entsel (strcat "\nNUMMER: " numsv (potlo0 numi_s (itoa w)) numsh " Objekt waehlen oder ENTER: "))) (st_mod (car e) (reverse (cons (strcat numsv (potlo0 numi_s (itoa w)) numsh) li))) (entupd (car e)) (cond ((= "1" a1) (setq w (+ w (atoi inc)))) ((= "1" a2) (setq w (- w (atoi inc)))) ) (setq numi w) ) (setvar "pickbox" _pckbox) (if (= (type numi) 'INT) (setq numi (itoa numi))) ) ((and (= _bw "0")(= a3 "1")) ;insertalni is kell (setq w (atoi numi)) (cond ((not attpos) (setq attpos "2"))) (setq li nil) (setq li (repeat (atoi attpos) (setq li (cons "" li)))) (setq _pckbox (getvar "attreq")) (setvar "attreq" 0) (while (setq ip (getpoint (strcat "\nNUMMER: " numsv (potlo0 numi_s (itoa w)) numsh " Einfuegepunkt oder ENTER: "))) (command "_insert" blk_name1 ip _sklfkt "" "") (setq e (entlast)) (st_mod e (reverse (cons (strcat numsv (potlo0 numi_s (itoa w)) numsh) li))) (entupd e) (cond ((= "1" a1) (setq w (+ w (atoi inc)))) ((= "1" a2) (setq w (- w (atoi inc)))) ) (setq numi w) ) (setvar "attreq" _pckbox) (if (= (type numi) 'INT) (setq numi (itoa numi))) ) ((= a3 "0") (setq w (atoi numi)) ; stilus fix h (setq style-list (tblsearch "style" cstil)) (setq shght (cdr (assoc 40 style-list))) (if (not swidth) (setq swidth (cdr (assoc 41 style-list)))) (cond ((= "1" _tw) (while (setq e (car (entsel (strcat "\nNUMMER: " numsv (potlo0 numi_s (itoa w)) numsh " Text waehlen oder ENTER: ")))) (setq res (strcat numsv (potlo0 numi_s (itoa w)) numsh)) (if (= "TEXT" (cdr (assoc 0 (entget e)))) (progn (setq d (entget e)) (setq d (subst (cons 1 res) (assoc 1 d) d)) (entmod d) (cond ((= _tk "tkreis") (tkreis nil res e)) ((= _tk "tbox") (tbox nil e)) ((= _tk "telip") (telip nil e)) ((= _tk "toval") (toval nil e)) ((= _tk "tdrei") (tdrei nil e)) ) (cond ((= "1" a1) (setq w (+ w (atoi inc)))) ((= "1" a2) (setq w (- w (atoi inc)))) ) (setq numi w) ) (princ "\Das ist kein TEXT Element.") ) ) ) (t (while (setq e (getpoint (strcat "\nNUMMER: " numsv (potlo0 numi_s (itoa w)) numsh " Mittelpunkt: "))) (setq res (strcat numsv (potlo0 numi_s (itoa w)) numsh)) (setvar "textstyle" cstil) (if (= shght 0) (command "_text" "_m" e csize "0" res) (command "_text" "_m" e "0" res) ) (if (/= swidth 1.0) (progn (setq s1 (entlast)) (setq d1 (entget s1)) (setq d1 (subst (cons 41 swidth) (assoc 41 d1) d1)) (entmod d1) (entupd s1) ) ) (cond ((= _tk "tkreis") (tkreis e res nil)) ((= _tk "tbox") (tbox e (entlast))) ((= _tk "telip") (telip e (entlast))) ((= _tk "toval") (toval e (entlast))) ((= _tk "tdrei") (tdrei e (entlast))) ) (cond ((= "1" a1) (setq w (+ w (atoi inc)))) ((= "1" a2) (setq w (- w (atoi inc)))) ) (setq numi w) ) ) ) (if (= (type numi) 'INT) (setq numi (itoa numi))) ) ) ) ((= what_new 102)(textopt)) );cond a3=1 ) (moder) (princ) )