(defun EAKT_SAVECOLOR (/ altfarbe) ;sichert aktuelle Farbe aus "CECOLOR" ;Funktionswert: aktuelle Farbe (if (equal (substr (getvar "cecolor") 2 1) " ") ;Farben 1 - 9 bzw. vonlayer (setq altfarbe (substr (getvar "cecolor") 1 1)) ;Farben ab 10 bzw. vonlayer (if (equal (getvar "cecolor") "BYLAYER") (setq altfarbe "_bylayer") (setq altfarbe (getvar "cecolor")) ) ) ) (defun C:MSRattr ( / ss_obj nr ename blockname lis last_ename blocklis anz attribut_list einf einf_blo altfarbe ss1 ss2) ;Sichern aller Inhalte von allen Attributen eines Blocks ;Löschen aller Attribute ;Block löschen ;Block neu erzeugen und anhängen von neuen Attributen Stromkreis 2 bis Strimkreis 5, ;falls Attribut vorhanden war Inhalt übernehmen (princ "\nBlöcke für Neuzuordnung der Attribute wählen ") (setq altfarbe (EAKT_SAVECOLOR)) (command "._color" "_bylayer") (setq ss_obj (ssget)) (if (not ss_obj) (progn ;alle Blöcke auswählen (setq ss1 (ssget "X" (list (cons 0 "INSERT")))) ) ) (if ss_obj (progn ;alle Blöcke bearbeiten (setq nr 0) (while (setq ename (ssname ss_obj nr)) (if (= (cdr (assoc 0 (entget ename))) "INSERT") (progn (princ (strcat "\nBlock " (cdr (assoc 2 (entget ename))))) (setq blocklis (entget ename '("*") )) (setq blockname ename) (setq attribut_list nil) ; ;alle Attribute sichern ; (if (and (assoc 66 blocklis) (equal (cdr (assoc 66 blocklis)) 1)) ; (progn ; (setq lis (entget (setq ename (entnext ename)))) ; (while (not (equal (cdr (assoc 0 lis)) "SEQEND")) ; (set (read (strcat "EAKT_V:" (cdr (assoc 2 lis)))) ; (cdr (assoc 1 lis))) ; (setq attribut_list (cons (entget ename '("*")) attribut_list)) ; (setq lis (entget (setq ename (entnext ename)))) ; ) ; ) ; ) ;Block löschen (entdel blockname) ;Block neu erzeugen (if (assoc 66 blocklis) ;Element 66 vorhanden (setq blocklis (subst (cons 66 1) (assoc 66 blocklis) blocklis)) ;else ;Element 66 nicht vorhanden (progn (setq anz 0 lis nil) (while (/= (cdr (nth anz blocklis)) "AcDbBlockReference") (setq lis (cons (nth anz blocklis) lis)) (setq anz (1+ anz)) ) (setq lis (cons (nth anz blocklis) lis)) ;Element 66 an der richtigen(!) Stelle einfügen (setq lis (cons (cons 66 1) lis)) (setq anz (1+ anz)) (while (nth anz blocklis) (setq lis (cons (nth anz blocklis) lis)) (setq anz (1+ anz)) ) (setq blocklis (reverse lis)) ) ) (entmake blocklis) ;neue Attribute erzeugen (setq einf_blo (cdr (assoc 10 blocklis))) ;Einfügepunkt vom Block merken (setq einf_fak (cdr (assoc 41 blocklis))) ;Einfügefaktor vom Block merken ;neues Attribut (SETQ Txt (STRCAT "\r Name Attributdef. :")) (if (not EAKT_V:NEU1) (progn (setq einf (list (+ (car einf_blo) 0.00) (+ (cadr einf_blo) 0.75) 0)) (entmake (list (cons 0 "ATTRIB") (cons 100 "AcDbEntity") (cons 8 "-MSR");;Layer (cons 100 "AcDbText") (cons 10 einf);;Anfangspkt (cons 11 einf);;Endpunkt (cons 40 2.5);;Texthöhe (cons 1 "");;Für 4-5 Stellen (cons 50 0.0);;Winkel (cons 6 "continuous") (cons 62 1);;Farbe (cons 41 1.0);;Weite (cons 51 0);;Winkel (cons 7 "STANDARD");;Textstil (cons 100 "AcDbAttribute") (cons 2 "Größe") (cons 70 0);;vorher 8 (cons 71 0);;Text spiegeln (cons 72 1);;1=Ausrichtung ja (cons 73 0);;Text ausrichten (cons 74 4);;Ausrichtung Mitte Zentrum->Art der Ausrichtung )) ) ) ;neues Attribut (if (not EAKT_V:NEU2) (progn (setq einf (list (+ (car einf_blo) 0.00) (- (cadr einf_blo) 3.50) 0)) (entmake (list (cons 0 "ATTRIB") (cons 100 "AcDbEntity") (cons 8 "-MSR");;Layer (cons 100 "AcDbText") (cons 10 einf);;Anfangspkt (cons 11 einf);;Endpunkt (cons 40 2.5);;Texthöhe (cons 1 "");;Für 12 Stellen (cons 50 0.0);;Winkel (cons 6 "continuous") (cons 62 1);;Farbe (cons 41 0.75);;Weite (cons 51 0);;Winkel (cons 7 "STANDARD");;Textstil (cons 100 "AcDbAttribute") (cons 2 "Nummer") (cons 70 0) (cons 71 0);;Text spiegeln (cons 72 1);;Text ausrichten (cons 73 0);;Text ausrichten (cons 74 4);;Text ausrichten )) ) ) ; ;Attribut STROMKREIS 4 ; (if (not EAKT_V:STROMKREIS4) ; (progn ; (setq einf (list (+ (car einf_blo) 0) (- (cadr einf_blo) 0.85) 0)) ; (entmake (list (cons 0 "ATTRIB") ; (cons 100 "AcDbEntity") ; (cons 8 "2E_ATT_SKL-NR") ; (cons 100 "AcDbText") ; (cons 10 einf) ; (cons 40 0.1) ; (cons 1 "") ; (cons 50 0.0) ; (cons 6 "continuous") ; (cons 62 1) ; (cons 41 1.0) ; (cons 51 0.0) ; (cons 7 "STANDARD") ; (cons 100 "AcDbAttribute") ; (cons 2 "STROMKREIS4") ; (cons 70 8) ; )) ; ) ; ) ; ; ;Attribut STROMKREIS 5 ; (if (not EAKT_V:STROMKREIS5) ; (progn ; (setq einf (list (+ (car einf_blo) 0) (- (cadr einf_blo) 1.0) 0)) ; (entmake (list (cons 0 "ATTRIB") ; (cons 100 "AcDbEntity") ; (cons 8 "2E_ATT_SKL-NR") ; (cons 100 "AcDbText") ; (cons 10 einf) ; (cons 40 0.1) ; (cons 1 "") ; (cons 50 0.0) ; (cons 6 "continuous") ; (cons 62 1) ; (cons 41 1.0) ; (cons 51 0.0) ; (cons 7 "STANDARD") ; (cons 100 "AcDbAttribute") ; (cons 2 "STROMKREIS5") ; (cons 70 8) ; )) ; ) ; ) ; ;alte Attribute neu erzeugen (setq anz 0) (if attribut_list (progn (setq attribut_list (reverse attribut_list)) (while (setq lis (nth anz attribut_list)) ;Variable mit Attributsname wieder löschen (set (read (strcat "EAKT_V:" (cdr (assoc 2 lis)))) nil) ;Attribut erzeugen (entmake lis) (setq anz (1+ anz)) ) ) ) ;SEQEND erzeugen (entmake (list (cons 0 "SEQEND"))) ) ) (setq nr (1+ nr)) ) (command "._ddatte" "_last") ) ;else (alert "Kein Block vorhanden !") ) (command "._color" altfarbe) )