(setvar "cmdecho" 0)(prompt "\nDIN-Bemassung ....... ")(DEFUN g-TXK2 ( ab / tl du df fk)
 (setq du (atoi (rtos g_l 2 0)) df 0)(while (and (< df 0.05)(>= du (getvar "LUPREC")))(setq fk (* (abs ab) g_g (expt 10.0 (- du 1)))
 df (abs (- fk (fix (+ fk 0.5)))) du (- du 1)))(setq tx (rtos (abs (* ab g_g)) (getvar "LUNITS") (+ du 1) )))(prompt ".")(DEFUN C:MASSY ()(g_sv)
(g-maxy 0 ))(prompt ".")(DEFUN C:MASSX ()(g_sv)(g-maxy (* pi 0.5) ))(prompt ".")(DEFUN C:MASSA ()(g_sv)(g-maxy T ))(prompt ".")
(DEFUN g-win ( p0 p1 sg / df)(setq ang1 (angle p0 p1))(setq df (- ang1 sg))(if (and (> df (* pi 0.5))(< df (* 1.5 pi)))(setq df (+ sg pi))
 (setq df sg )) )(DEFUN g-laen (p0 e0 / p1 p2) (setq p1 (trans (cdr (assoc 10 e0)) 0 1) p2 (trans (cdr (assoc 11 e0)) 0 1))
 (if (> (distance p0 p1)(distance p1 p2))(command "NDERN" (cdr (assoc -1 e0)) "" p0)
 (if (> (distance p0 p2)(distance p1 p2))(command "NDERN" (cdr (assoc -1 e0)) "" p0)) ))(DEFUN g-maxy ( g-ma / ce sg pa p0 p1 ue 
 ab s0 n0 n1 s1 e0 e1 fx fm pm pa)(if (= 0 (getvar "handles"))(progn
(setq ce (g_in ce "\nAssoziativitt nicht mglich : (0=ein/1=ohne/2=Abbruch)" "0"))(cond((= ce "0")(command "REFERENZ" "EIN"))((= ce "1")())((quit))
))) (setq ce (getvar "clayer") sg g-ma   pa nil p0 T p1 T ue (* 2.0 g_f) ab (* 7.0 g_f))(command "LAYER" "SETZ" (nth 5 v-lay) "")
 (setq g-f2 (g_in g-f2 "\nEinzelvermassung(=0)/Basislinien(=1)/Kettenbemassung(=2):" "0") fx "0") (if (= "0" g-f2)(setq fm "\nEinzelvermassung:")
 (if (= "1" g-f2)(setq fm "\nBasislinie-") (setq fm "\nMasskette-") ) )(g_se)(while (and (/= p0 nil)(/= p1 nil)) (g_ru)
 (if (= fx "0")(setq p0 (getpoint "\n<Anfangspunkt 1.Masshilfslinie>/(Ende=Return):")))
 (if (/= p0 nil)(SETQ P1 (GETPOINT (strcat fm "<Anfangspunkt 2. Masshilfslinie>/(Ende=Return) :"))))
 (if (and (/= p0 nil)(/= p1 nil))(setq pm (getpoint "\nStandort Masslinie:"))) (if (and (/= pa nil)(= pm nil))(setq pm (polar pa s0 ab))) (setq pa pm)
 (g_se)  (if (and (/= p0 nil)(/= p1 nil)(/= pm nil)) (progn (if (= g-ma T)(setq sg (+ (angle p0 p1) (* pi 0.5))) ) (setq s0 (g-win p0 pm sg)
 n0 (polar p0 s0 (* (distance p0 pm)(cos (- s0 (angle p0 pm))))) s1 (g-win p1 pm sg) n1 (polar p1 s1 (* (distance p1 pm)(cos (- s1 (angle p1 pm))))))
(if (= fx "0")(progn (command "LINIE" (polar p0 (angle p0 n0) (* g_f (getvar "dimexo"))) (polar n0 (angle p0 n0) ue) "")(setq e0 (entget (entlast)))))
 (command "LINIE" (polar p1 (angle p1 n1) (* g_f (getvar "dimexo"))) (polar n1 (angle p1 n1) ue) "")(setq e1 (entget (entlast)))
 (if (> fx "0")(g-laen (polar n0 s0 ue) e0))(g-mali n0 n1 T T)(setq fx g-f2)(if (= fx "2")(setq p0 p1 e0 e1 ) (if (= fx "0")(setq pa nil))))))
(command "LAYER" "SETZ" ce "")(g_un)(princ))(prompt ".")(DEFUN C:MASC ( / ce p0 pm ag ab p1)(g_sv)(if (= 0 (getvar "handles"))(progn
(setq ce (g_in ce "\nAssoziativitt nicht mglich : (0=ein/1=ohne/2=Abbruch)" "0"))(cond((= ce "0")(command "REFERENZ" "EIN"))((= ce "1")())((quit))
))) (setq p0 (g_in nil "\nKreispunkt fr Masspfeil :" (list 0 0 0 512 "NAE")) pm (osnap p0 "ZEN")) (g_se)(command "LAYER" "SETZ" (nth 5 v-lay) "")
 (if (and (/= p0 nil)(/= pm nil)) (progn (setq ag (angle p0 pm) ab (distance p0 pm) p1 (polar pm ag ab)) (g-mali p0 p1 nil T) )) (g_un) (princ))
(prompt ".")(DEFUN g-mali ( p1 p0 mi tf / h1 h2 ag a9 a18 a27 ab br ho rg fi t1 i df tl a y b c dt tx e0)(command "LAYER" "SETZ" (nth 5 v-lay) "")
(g_se) (setq ag (angle p0 p1) rg (* (/ ag pi) 180.) a9 (+ ag (* pi 0.5)) a18 (+ ag pi) a27 (+ a9 pi) ab (distance p0 p1) pm (polar p0 ag (* ab 0.5))
 ho (* g_f 3.5) br (* ho 0.8) )(if (or (= tf nil)(= tf T))(progn(setq tx (g-txk2 ab))(if (= tf T)(progn
(setq t1 (getstring T (strcat "\nBemassungs-Text:" "<" tx ">")))(if (= t1 "")(setq t1 tx))(setq I (SEARC "<>" t1))  (if (> i 1)(setq i (- i 1)))
 (if (> i 0)(setq tx (strcat (substr t1 1 i) tx))(setq tx t1))))) (setq tx tf))(setq tl (strlen tx) ) (setq df (- ab (* 2. br) (* tl br)))
 (IF (> df 0)(progn(SETQ A T Y 0 B nil C nil)(COMMAND "LINIE" p0 p1 "")(if (= mi nil) (progn (setq dt (* df 0.25 g_f))
 (if (< dt (* 2 br g_f))(setq dt (* 2 br g_f))) (setq dt (- (* ab 0.5) dt (* tl br 0.5))) ) (setq dt 0.))(if (and (< ag 4.72)(> ag 1.58))
 (COMMAND "TEXT" "Z" (polar (polar pm a27 g_f) ag dt) ho (+ rg 180) tx) (COMMAND "TEXT" "Z" (polar (polar pm a9 g_f) ag dt) ho rg tx))
(entmod (subst (cons 8 (nth 6 v-lay))(assoc 8 (entget (entlast)))(entget (entlast))))(setq h2 (cdr (assoc 5 (entget (entlast))))))
 (IF (< (* tl br) (- ab br))(progn(SETQ B T Y 180 A nil C nil)(COMMAND "LINIE" (polar p0 a18 (* 1.5 br)) (polar p1 ag (* 1.5 br)) "")
(if (and (< ag 4.72)(> ag 1.58)) (COMMAND "TEXT" "Z" (polar pm a27 g_f) ho (+ rg 180) tx) (COMMAND "TEXT" "Z" (polar pm a9 g_f) ho rg tx))
(entmod (subst (cons 8 (nth 6 v-lay))(assoc 8 (entget (entlast)))(entget (entlast))))(setq h2 (cdr (assoc 5 (entget (entlast))))))(progn
(SETQ C T Y 180 A nil B nil)(if (= tl 1)(setq dum 1)(setq dum 0))(COMMAND "LINIE" (polar p1 ag (* 1.5 br)) (polar p0 a18 (* (+ tl dum) br)) "" )
(if (and (< ag 4.72)(> ag 1.58)) (COMMAND "TEXT" (polar (polar p0 a18 br) a27 g_f) ho (+ rg 180) tx)
 (COMMAND "TEXT" "R" (polar (polar p0 a18 br) a9 g_f) ho rg tx))(entmod (subst (cons 8 (nth 6 v-lay))(assoc 8 (entget (entlast)))(entget (entlast))))
(setq h2 (cdr (assoc 5 (entget (entlast))))))))(if (= (getvar "handles") 0) (COMMAND "EINFGE" (strcat pfad "din359") p0 g_f g_f (+ rg y)
 "EINFGE" (strcat pfad "din359") p1 g_f g_f (+ rg 180 y)) (progn (setvar "attdia" 0)  (COMMAND 
 "EINFGE" (strcat pfad "din358") p0 g_f g_f (+ rg y) h2 h2) (setq fi (entlast) h1 (cdr (assoc 5 (entget (entlast)))))
 (command "EINFGE" (strcat pfad "din358") p1 g_f g_f (+ rg 180 y) h1 h2) (setq h1 (cdr (assoc 5 (entget (entlast)))))
 (setq e0 (entget (entnext fi))) (entmod (subst (cons 1 h1)(assoc 1 e0) e0)) (SETVAR "attdia" 1))))(prompt ".")(princ)
