dreams Posted June 25, 2014 Share Posted June 25, 2014 I would like to need a lisp for Alert/warning. Please see the following text format (2x6 #6 X 20'-0" EF). This lisp will need to Alert when the last two letters are EF and The prefix of first two letter is not 2x. I couldn't able to check every time in cad file where is got missing text (2x) when EF comes in the last. Note:If the last two letters are EF, The prefix of first two letters must be 2x. Can some one help me for this lisp? That would be much appreciated. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 25, 2014 Share Posted June 25, 2014 This ? (setq txt "2x6 #6 X 20'-0\" EF") (if (and (eq (substr txt 1 2) "2x") (eq (substr txt (1- (strlen txt)) 2) "EF") ) (alert "Chars found in the text string") (alert "Could not find the correct in that text string !") ) Quote Link to comment Share on other sites More sharing options...
dreams Posted June 25, 2014 Author Share Posted June 25, 2014 Hi Tharwat..Thanks for your help..but the text format will be varied at many locations. Example 2x6 #6 X 20'-0" EF the text which are highlighted within blue color will be varied... Also, I would like to add two more texts EF, T&B, EW but the text prefix 2x will be constant. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 25, 2014 Share Posted June 25, 2014 (edited) Try this . (defun c:Test (/ l sad ss) ;; Tharwat 25.June.2014 ;; (setq l (mapcar 'vl-string->list '("EF" "T&B" "EW"))) (if (setq sad (ssadd) ss (ssget "_:L" '((0 . "TEXT"))) ) ((lambda (i / sn s txt st) (while (setq sn (ssname ss (setq i (1+ i)))) (if (or (member (vl-string->list (setq st (substr (setq txt (cdr (assoc 1 (entget sn)))) (1- (strlen txt)) 2 ) ) ) l ) (member (vl-string->list (substr txt (- (strlen txt) 2) 3)) l ) ) (ssadd sn sad) ) ) ) -1 ) ) (sssetfirst nil sad) (princ) ) Edited June 25, 2014 by Tharwat Quote Link to comment Share on other sites More sharing options...
dreams Posted June 25, 2014 Author Share Posted June 25, 2014 Hi Tharwat, Thanks for your try..but its not working...The Alert would come when the texts EF (or) T&B (or) EW in the last letters but 2x is not available in the prefix... Quote Link to comment Share on other sites More sharing options...
dreams Posted June 25, 2014 Author Share Posted June 25, 2014 For your reference, I have listed below sample texts... 2x6 #6 X 20'-0" H EF 6 #6 X 8'-4" T&B 6 #5 X 9'-0" EW 6 #4 X 20'-0 H EF The lisp will find out the above blue colored text only which has no text (2x) prefix...I hope now you can understand what i am expecting...sorry for the confusion. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 25, 2014 Share Posted June 25, 2014 I need to know the beginning and end chars to match . The routine that posted earlier is for single texts and not Mtext , this is for your information . Quote Link to comment Share on other sites More sharing options...
dreams Posted June 25, 2014 Author Share Posted June 25, 2014 Hi Tharwat, The beginning chars will be varied (like numbers 1 to 300) and the end chars are constant which are from the following three EF (or) T&B (or) EW All are single text only..not Mtext. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 25, 2014 Share Posted June 25, 2014 Okay , bear with me . So these five strings in RED would be constant the end of each single string that you want to highlight on selection ? And what about the beginning ? Is not it required ? Quote Link to comment Share on other sites More sharing options...
dreams Posted June 25, 2014 Author Share Posted June 25, 2014 Yes correct...The beginning text will be varying like numbers which is not required now. but the lisp need to check whether the text (2x) is there in the prefix or not. If it is not the lisp will alert like "text (2x) is missing" Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 25, 2014 Share Posted June 25, 2014 I updated the codes above post No# 4 , hope it would meets your requirements . Quote Link to comment Share on other sites More sharing options...
dreams Posted June 25, 2014 Author Share Posted June 25, 2014 Hi tharwat..Thanks..Its not working correctly. It is selecting the text which are the end text EF, T&B, EW. but I need to find out where the beginning text (2x) not there or missing. Have you got my point? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 25, 2014 Share Posted June 25, 2014 Yes correct...The beginning text will be varying like numbers which is not required now. but I need to find out where the beginning text (2x) not there or missing. Have you got my point? What is this contradiction ? Quote Link to comment Share on other sites More sharing options...
dreams Posted June 25, 2014 Author Share Posted June 25, 2014 Yes correct...The beginning text will be varying like numbers which is not required now. I meant beginning text is 6 #6 X 20'-0" H EF which is not required now.. Sorry for the confusion... Quote Link to comment Share on other sites More sharing options...
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.