;suchen einer Zeichenkette innerhalb einer anderen Zeichenkette ;wird sie gefunden, wird die Startposition zurückgegeben, anderenfalls ist der Rückgabewert nil ;---------------------------- (defun str-pos(str c / i l ls lc) (setq i 1) (setq ls(strlen str)) (setq lc(strlen c)) (setq l(1+(- ls lc))) (while(and(<= i l)(/=(substr str i lc)c)) (setq i(1+ i)) ) (if(<= i l)i) ) ;---------------------------- ;Variante die nicht zwischen Groß- und Kleinschreibung unterscheidet (defun str-ipos(str c / ) (str-pos(strcase str)(strcase c)) ) ;---------------------------- ;Zeichenkette an der angegebenen Position in einen anderen String einfügen (defun str-insert(str neu pos / ) (strcat (substr str 1(1- pos)) neu (substr str pos) ) ) ;---------------------------- ;erzeugt eine Liste mit dem Gruppencode 3, in der Wandstile deren Namen "variabel" beinhaltet durch "variabel F90" ersetzt wird ;| Beispiel alte Liste ((3 . BW Reichsklinker dunkel - tragend) (3 . MW Reichsklinker dunkel variabel - nicht tragend) (3 . MW Reichsklinker dunkel variabel - tragend) (3 . Standard)) neue Liste ((3 . BW Reichsklinker dunkel - tragend) (3 . MW Reichsklinker dunkel variabel F90 - nicht tragend) (3 . MW Reichsklinker dunkel variabel F90 - tragend) (3 . Standard)) |; (defun Rename_Wandstilname_AECDictionary ( / 3DIC lauf AnzWst first3DIC StyleNameLength startposvariabel insposvariabel newStilName) (if (and (setq dict (dictsearch (namedobjdict) "AEC_WALL_STYLES"));DICTIONARY Wandstile (setq 3DIC (vl-remove-if-not '(lambda (x) (= (car x) 3)) dict));StilName in Liste );end and (progn ; (setq lauf 0) (setq AnzWst (length 3DIC));Anzahl der Stile Stilmanager (print "Anzahl der Stile Stilmanager: ")(princ AnzWst)(terpri) ; (print "Stilnamenliste aus Stilmanager: ")(princ 3DIC)(terpri) (foreach WallStyle 3DIC ; (print "Wert foreach WallStyle: ")(princ WallStyle)(terpri) (setq first3DIC (cdr WallStyle));Stilname der StilNamenListe (setq StyleNameLength (strlen first3DIC));Anzahl Zeichen Stilname (setq startposvariabel (str-pos first3DIC "variabel"));Ermitteln der Startposition wo "variabel" im Stilname beginnt, wenn "variabel" nicht im Stilname enthalten dann nil (if (/= startposvariabel nil) (progn (setq insposvariabel (+ startposvariabel 9));Stelle hinter "variabel" + das Leerzeichen, an der "F90 " eingefügt werden soll (setq newStilName (str-insert first3DIC "F90 " insposvariabel));"F90 ",an Position insposvariabel in alten Stilnamen einfügen ;------------------------------------------ ; (setq lauf (+ lauf 1)) ; (print "bin in Schleifendurchgang ")(princ lauf)(terpri) ; (print "Stelle hinter variabel: ")(princ startposvariabel)(terpri) ; (print "alter Stilname: ")(princ first3DIC)(terpri) ; (print "neuer Stilname: ")(princ newStilName)(terpri) );end progn );end if startposvariabel not nil ;------------------------- ;begin neue StilNamenListe (if (/= NewStyleNameLst nil) (progn (if (= startposvariabel nil) (progn (setq NewStyleNameLst (append NewStyleNameLst (list (cons 3 (cdr WallStyle))))) );end progn (setq NewStyleNameLst (append NewStyleNameLst (list (cons 3 newStilName)))) );end if startposvariabel nil );end progn );end if NewStyleNameLst not nil (if (= NewStyleNameLst nil) (progn (if (= startposvariabel nil) (progn (setq NewStyleNameLst (list (cons 3 (cdr WallStyle)))) );end progn (setq NewStyleNameLst (append NewStyleNameLst (list (cons 3 newStilName)))) );end if startposvariabel nil );end progn );end if NewStyleNameLst nil ;end neue StilNamenListe ;------------------------- );end foreach );end progn );end if dict (print "neue Stilnamenliste für Stilmanager: ")(princ NewStyleNameLst)(terpri) );end defun Rename_Wandstilname_AECDictionary ;------------------------------------------ ;Benennt anhand der neuen Stilnamenliste "NewStyleNameLst" die Wandstile im Stilmanager um (defun chgWallStyleName ( / newdict) (foreach dotpair dict (if (/= (car dotpair) 3) (progn (if (/= newdict nil) (progn ; (print "dotpair: ")(princ dotpair)(terpri) (setq newdict (append newdict (list dotpair))) ) ) (if (= newdict nil) (progn ; (print "dotpair: ")(princ dotpair)(terpri) (setq newdict (list dotpair)) ) ) ) ) (if (= (car dotpair) 3) (progn ; (print "dotpair: ")(princ dotpair)(terpri) (setq newdict (append newdict (list (car NewStyleNameLst)))) (setq NewStyleNameLst (cdr NewStyleNameLst)) ) ) ) (print "alte Entityliste: ")(princ dict)(terpri) (print "neue Entityliste: ")(princ newdict)(terpri) (entmod newdict) ;--------- (setq dict nil NewStyleNameLst nil ) ;--------- );end defun chgWallStyleName ;---------------------------- (Rename_Wandstilname_AECDictionary) (chgWallStyleName) ;| (setq dict nil 3DIC nil lauf nil AnzWst nil first3DIC nil StyleNameLength nil startposvariabel nil insposvariabel nil newStilName nil NewStyleNameLst nil dict1 nil newdict nil ) |;