extrawurscht Posted December 29, 2010 Posted December 29, 2010 (edited) Hello, here is my second problem. in this LISP i want to renumber given cable Numbers which are in a block or text. it works, but if i not hit the attribute or text, it keeps on increasing the number. But i want only count if i hit a attribute or text. the Lisp shall count every 2 hit of a attribute, so that i have the same text at the start and the destination point. ;-------------------------------------------------------------------------- ; KNUMRENUM2 ;-------------------------------------------------------------------------- (defun c:renum2 (/ oldPref oldSuf oldKNR curText curStr numZeros) (vl-load-com) (setq snapwert (getvar "snapmode")) (setvar "snapmode" 0) (initget 6) (setq numZeros (getInt "\nAnzahl der Stellen Eingeben <4>: ")) (if(not numZeros)(setq numZeros 4)) (defun num2str (num / numStr) (setq numStr (itoa num)) (If (< (strlen numStr) numZeros) (repeat (- numZeros (strlen numStr)) (setq numStr (strcat "0" numStr)) ) ) numStr ) (if(not rnm:Pref)(setq rnm:Pref "")) (if(not rnm:Suf)(setq rnm:Suf "")) (if(not rnm:KNR)(setq rnm:KNR 1)) (setq oldPref rnm:Pref oldSuf rnm:Suf oldKNR rnm:KNR); end setq (setq rnm:Pref (getstring T (strcat "\nPrefix: <"rnm:Pref">: "))) (if(= "" rnm:Pref)(setq rnm:Pref oldPref)) (if(= " " rnm:Pref)(setq rnm:Pref "")) (setq rnm:Suf (getstring T (strcat "\nSuffix: <"rnm:Suf">: "))) (if(= "" rnm:Suf)(setq rnm:Suf oldSuf)) (if(= " " rnm:Suf)(setq rnm:Suf "")) (setq rnm:KNR (getint (strcat "\nStart-Kabelunummer <" (itoa rnm:KNR)">: "))) (if(null rnm:KNR)(setq rnm:KNR oldKNR)) (while T (setq curStr(strcat rnm:Pref(num2Str rnm:KNR)rnm:Suf)) (setq curText (car (nentsel "\nPick 1st Text: "))) (if (and curText (member(cdr(assoc 0(entget curText))) '("TEXT" "MTEXT" "ATTRIB")) ); end and (progn (vla-put-TextString (vlax-ename->vla-object curText)curStr) ; (setq rnm:KNR(1+ rnm:KNR)) ; ); end progn ; (princ "\n This is not DText or MText ") ; ); end if (setq curText (car (nentsel "\nPick 2nd Text: "))) ; (if (and curText (member(cdr(assoc 0(entget curText))) '("TEXT" "MTEXT" "ATTRIB")) ); end and ; (progn (vla-put-TextString (vlax-ename->vla-object curText)curStr) ; (setq rnm:KNR(1+ rnm:KNR)) ); end progn (princ "\n This is not DText or MText ") ); end if (setq rnm:KNR(1+ rnm:KNR)) ); end while (princ) ); end of c:renum ;-------------------------------------------------------------------------- Edited December 29, 2010 by extrawurscht Quote
Lee Mac Posted December 29, 2010 Posted December 29, 2010 ExtraWurscht, Please read this to find out how to enclose your code in code tags, you can edit your posts accordingly. Lee Quote
extrawurscht Posted December 29, 2010 Author Posted December 29, 2010 done, as desricribed in your link thx Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.