Jump to content

Need help -Alert/Warning lisp


dreams

Recommended Posts

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.

Link to comment
Share on other sites

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 !")
)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by Tharwat
Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 .

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...