Message 1 of 34

Not applicable
05-20-2020
10:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear Experts,
I am searching for a long time for this requirement.
The requirement is to select the text, which are in a particular range.
Suppose the drawing has a lot of thousands of numbers.
If the user wants to select the numbers which are between 10.5 to 25.4, then only those numbers should be selected from user selection and remaining to be unselected from user selection.
Lisp should consider the values even text has alphabets and decimals.
you can consider the below code for further editing, if possible.
(defun c:MMA (/ ss lst numlst txt2num)
(defun txt2num (txt / num)
(or (setq num (distof txt 5))
(setq num (distof txt 2))
(setq num (distof txt 1))
(setq num (distof txt 4))
(setq num (distof txt 3))
)
num
)
(prompt "\nSelect text to analize numbers.")
(if (setq ss (ssget '((0 . "TEXT,MTEXT"))))
(progn
(setq lst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
(mapcar '(lambda (x) (setq numlst (cons (txt2num (cdr (assoc 1 (entget x)))) numlst)))
lst
)
(if (setq numlst (vl-remove-if 'listp numlst))
(progn
(print "Min number ")
(princ (apply 'min numlst))
(print "Max number ")
(princ (apply 'max numlst))
(print "Average of numbers ")
(princ (/ (apply '+ numlst) (length numlst)))
)
(prompt "\nNo numberf found.")
)
)
)
(princ)
)
Advanced thank you.
Solved! Go to Solution.