Neet to check tolerance strings

Neet to check tolerance strings

ec-cad
Collaborator Collaborator
289 Views
2 Replies
Message 1 of 3

Neet to check tolerance strings

ec-cad
Collaborator
Collaborator

Hi all,

Attached is a small sample Lisp (text file) with a few 'Lists of strings.

Goal is to pass each string within the List to a Function that would

check numeric content e.g. "[(120.003)]" - find the Numerals + ".",

then IF value <0.050 add that string to an output 'List.

See the notes at bottom of the .lsp for details.

 

ECCAD

0 Likes
Accepted solutions (1)
290 Views
2 Replies
Replies (2)
Message 2 of 3

Moshe-A
Mentor
Mentor
Accepted solution

@ec-cad  hi,

 

here something you can start working with 😀

(parse) function will return a list with all the reals numbers each as a string in a sub list

if a string contains 2 numbers, the sub list will have 2 items.

 

leaving you to finish it as you want.

 

enjoy

Moshe

 

(defun parse (lst-str / isNumeric _isdots ;| local functions |;)
  
 (defun _isnumber (c)
  (or
    (member c '("+" "-" "."))
    (and (>= (ascii c) 48) (<= (ascii c) 57))
  )
 ); _isnumber
   
 (setq _isdots (lambda (s) (vl-every (function (lambda (n) (= n 46))) (vl-string->list s))))

 ; here start parse
 (vl-remove-if
  'not
  (mapcar
   '(lambda (str / p ch word dot lst)
     (cond
      ((or
	 (vl-string-search "TD." str)
         (vl-string-search "T." str)
       )
       nil
      ); case
      ( t
       (setq p 1 ch (substr str p 1) word "" lst nil)
       (while (/= ch "")
	(while (_isnumber ch)
         (setq word (strcat word ch))
	 (setq p (1+ p) ch (substr str p 1))
	); while

	(if (and (/= word "")
		 (not (_isdots word))	   	 ; ignore ".."
	         (not (= (atof word) 0.0)) 	 ; ignore 0.00000
		 (not (= (rem (atof word) 1) 0)) ; not intege number
	    )
         (setq lst (cons word lst))
	); if
        (setq word "" p (1+ p) ch (substr str p 1))
       ); while
      
       (reverse lst)
      ); case
     ); cond
    ); lambda
   lst-str
  ); mapcar
 ); vl-remove-if
); parse


 

0 Likes
Message 3 of 3

ec-cad
Collaborator
Collaborator

Moshe-A,

Thanks for that one. I owe ya.

I made modifications so I can send in String & Handle, just passes 'bad_strs and handle_lst back.

I'll take those Handles, and grab the entity, draw a box around it. (looking good so far).

Here's the test code.

 

ECCAD

 

 

0 Likes