mstb Posted March 16, 2020 Posted March 16, 2020 Hello every one I have some text in model space like this 45#55 63#16 28#69 ofcource %%c replace # (I cant find %%c on my keyboard) (setq txt 45#55) ;; for example (setq m (strlen txt)) (setq d1 "") (setq d2 "") (setq i 0) (setq j 1) (repeat m (setq i (1+ i)) (setq let (substr txt i 1)) (if (/= let "#") (cond ((= j 1) (setq d1 (strcat d1 let))) ((= j 2) (setq d2 (strcat d2 let))) ) (cond ((= let "#") (setq j 2))) ) when I use %%c replace # It doesn't work Thanks all Quote
BIGAL Posted March 16, 2020 Posted March 16, 2020 (edited) Its a alt+number that's some home work for you ² damm metres squared ° ± ³ I will get there soon. It depends on the font. Its like the "any" key to quote Homer Simpson, hint its bottom left. Big hint Use Mtext insert symbol. Edited March 16, 2020 by BIGAL Quote
mstb Posted March 16, 2020 Author Posted March 16, 2020 excuse me my english is too bad IT's not my problem . my problem is not typing . my problem is that .this lisp dosent work with delimeted %%c because that's more than one character thanks Quote
Jonathan Handojo Posted March 16, 2020 Posted March 16, 2020 I'm still not understanding what you're trying to achieve. It looks to me like you want to get the prefix and suffix, given the delimiter at the middle. Because you're using (substr txt i 1) and %%c is three characters long, it's no wonder you couldn't get a match. I suggest you look at Lee Mac's String to List routine with a delimiter. You should get a list of strings with the delimiter. Or you can use mine if you'd like to escape some delimiters by adding an escape character just before the delimiter character. ;; JH:str->lst-escape_delimiter --> Jonathan Handojo ;; Parses a string to a list with a supplied delimiter, excluding delimiters with an escape character ;; str - string to parse ;; del - delimiter character ;; esc - escape character placed before the delimiter ;; Example call: ;; _$ (JH:str->lst-escape_delimiter "1,2,3`,4`,5,67,89`,100`,101" "," "`") ;; ("1" "2" "3,4,5" "67" "89,100,101") (defun JH:str->lst-escape_delimiter (str del esc / nstr sstr final put) (setq put "") (while (setq nstr (vl-string-search del str)) (cond ((vl-catch-all-error-p (vl-catch-all-apply 'substr (list (setq sstr (substr str 1 nstr)) (strlen sstr) ) ) ) (setq final (cons put final) put "" ) ) ((eq (substr (setq sstr (substr str 1 nstr)) (strlen sstr)) esc) (setq put (strcat put (substr sstr 1 (1- (strlen sstr))) del)) ) ( (setq final (cons (strcat put (substr sstr 1 (strlen sstr))) final) put "" ) ) ) (setq str (substr str (+ 1 nstr (strlen del)))) ) (reverse (cons (strcat put str) final)) ) Quote
mstb Posted March 16, 2020 Author Posted March 16, 2020 thanks but I mean..... please look at my picture 0000.bmp Quote
devitg Posted March 16, 2020 Posted March 16, 2020 Please upload your sample dwg , so we can check how the diameter sign is done. Quote
mstb Posted March 16, 2020 Author Posted March 16, 2020 (edited) (defun c:s () (setq ss (ssget '((0 . "TEXT")))) (setq n (sslength ss)) (setq k -1) (repeat n (setq k (1+ k)) (setq s (ssname ss k)) (setq en (entget s)) (setq txt (cdr (assoc 1 en))) (setq m (strlen txt)) (setq d1 "") (setq d2 "") (setq d3 "") (setq d4 "") (setq d5 "") (setq i 0) (setq j 1) (repeat m (setq i (1+ i)) (setq let (substr txt i 1)) (if (/= let "%%C");;;;;;;;;;;;;;;;;;;;;;;;;;here is my problem (cond ((= j 1) (setq d1 (strcat d1 let))) ((= j 2) (setq d2 (strcat d2 let))) ((= j 3) (setq d3 (strcat d3 let))) ((= j 4) (setq d4 (strcat d4 let))) ((= j 5) (setq d5 (strcat d5 let))) ) (setq j (1+ j)) ) ) (setq li (append li (list (list d1 d2 d3 d4 d5)))) ) ) It doesn't work. for %%c (diameter sign) Why ? It doesn't work with (diameter sign) delimited Edited March 16, 2020 by mstb Quote
rlx Posted March 16, 2020 Posted March 16, 2020 (defun split ( s / i) (vl-load-com) (cond ((setq i (vl-string-search "%%" s)) (princ (strcat "\ntxt1 = " (substr s 1 i) "\ntxt2 = " (substr s (+ i 4))))) ((setq i (vl-string-search "#" s)) (princ (strcat "\ntxt1 = " (substr s 1 i) "\ntxt2 = " (substr s (+ i 2))))) (t (princ "\nNo # or %%c found")) ) (princ) ) (defun c:tst ( / ) (princ "\n\ntesting : 123%%c456\n") (split "123%%c456") (princ "\n\ntesting : 78#90\n") (split "78#90") (princ) ) Quote
Jonathan Handojo Posted March 16, 2020 Posted March 16, 2020 (edited) Try doing (JH:str->lst-escape_delimiter txt "%%c" ""). You'll get all your delimited values in a list, so you don't need to bother with d1 d2... So just do: (repeat (sslength ss) (setq s (ssname ss (setq k (1+ k)) txt (cdr (assoc 1 (entget s))) lst (JH:str->lst-escape_delimiter txt "%%c" "") ) ; ..... the rest of your code here Edited March 16, 2020 by Jonathan Handojo Quote
dlanorh Posted March 16, 2020 Posted March 16, 2020 (edited) 4 hours ago, mstb said: (defun c:s () (setq ss (ssget '((0 . "TEXT")))) (setq n (sslength ss)) (setq k -1) (repeat n (setq k (1+ k)) (setq s (ssname ss k)) (setq en (entget s)) (setq txt (cdr (assoc 1 en))) (setq m (strlen txt)) (setq d1 "") (setq d2 "") (setq d3 "") (setq d4 "") (setq d5 "") (setq i 0) (setq j 1) (repeat m (setq i (1+ i)) (setq let (substr txt i 1)) (if (/= let (chr 216));;;;;;;;;;;;;;;;;;;;;;;;;;here is my problem (cond ((= j 1) (setq d1 (strcat d1 let))) ((= j 2) (setq d2 (strcat d2 let))) ((= j 3) (setq d3 (strcat d3 let))) ((= j 4) (setq d4 (strcat d4 let))) ((= j 5) (setq d5 (strcat d5 let))) ) (setq j (1+ j)) ) ) (setq li (append li (list (list d1 d2 d3 d4 d5)))) ) ) It doesn't work. for %%c (diameter sign) Why ? It doesn't work with (diameter sign) delimited Try using (chr 216) instead of "%%c". See above code. %%c is a way of generating the diameter sign inside a text or mtext, command. It is not the actual sign. Edited March 16, 2020 by dlanorh Quote
mstb Posted March 16, 2020 Author Posted March 16, 2020 Thank you very much Thank you very much all 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.