;; Given the list (1 2 1 1 3 2 5 3 4 5 3),
;;
;; (combine (1 2 1 1 3 2 5 3 4 5 3) '> '= )
;;
;; returns ((1 1 1) (2 2) (3 3 3) (4) (5 5))
;;
;; The input list does not need to be atoms,
(defun combine (inlist is-greater is-equal / sorted current result )
(setq sorted (sort inlist is-greater))
(setq current (list (car sorted)))
(foreach item (cdr sorted)
(if (apply is-equal (list item (car current)))
(setq current (cons item current))
(progn
(setq result (cons current result))
(setq current (list item))
)
)
)
(cons current result)
)
;; can be used for list of most kinds of atoms:
(defun atomic-combine (lst)
(combine lst '> 'eq)
)
(defun sort (lst predicate)
(mapcar '(lambda (x) (nth x lst)) (vl-sort-i lst predicate))
)
;; simplified example for TEXT only (no MTEXT)
(defun C:REPORT-DUPLICATE-TEXT (/ ss items i e )
(if (setq ss (ssget '((0 . "TEXT"))))
(progn
(repeat (setq i (sslength ss))
(setq e (ssname ss (setq i (1- i))))
(setq items
(cons
(cons e (strcase (vl-string-trim " " (cdr (assoc 1 (entget e))))))
items
)
)
)
(setq items
(combine items
'(lambda (a b)
(> (cdr a) (cdr b))
)
'(lambda (a b)
(eq (cdr a) (cdr b))
)
)
)
(textscr)
(princ "\n\n")
(foreach item items
(if (> (length item) 1)
(princ
(strcat "\nFound " (itoa (length item))
" occurances of: " (cdar item)
)
)
)
)
)
)
(princ)
)
I need a code that only selects similar text without doing anything else. Just mere highlight. Is it possible?
This was very helpful. It covers most of what I need. Is it easy to write an exception in this file where I could say, exclude a string value?? I'm new to Lisp routines. I have a lot of experience with mvba, sql, just trying to learn here.
Thank you,
@cole.debolt wrote:
This was very helpful. It covers most of what I need. Is it easy to write an exception in this file where I could say, exclude a string value?? I'm new to Lisp routines. I have a lot of experience with mvba, sql, just trying to learn here.
Thank you,
You can use this filter
(ssget "_X" '((0 . "TEXT")(1 . "~BANANA")))
simply put, the tilde "~" symbol means grab everything else but.
I'm using this:
;; This AutoLISP routine examines all the user-selected TEXT and MTEXT items,
;; and draws a line on the current layer between any two that have identical
;; string values.
;; Leading and trailing blanks spaces are ignored.
;; %% modifiers, like %%u, are not ignored.
;; Upper- and lower-case differences are not ignored.
(defun c:fdt () ;;Find Duplicate Text
(prompt "Select text items to examine: ")
(setq ss (ssget '((-4 . "<OR") (0 . "TEXT") (0 . "MTEXT") (-4 . "OR>"))))
(setq n 0)
(while
(< n (sslength ss))
(setq string1 (cdr (assoc 1 (entget (ssname ss n)))))
(setq string1 (vl-string-right-trim " " (vl-string-left-trim " " string1)))
(setq m (1+ n))
(while
(< m (sslength ss))
(progn
(setq string2 (cdr (assoc 1 (entget (ssname ss m)))))
(setq string2 (vl-string-right-trim " " (vl-string-left-trim " " string2)))
(if (= string1 string2)
(progn
(setq p1 (cdr (assoc 10 (entget (ssname ss n)))))
(setq p2 (cdr (assoc 10 (entget (ssname ss m)))))
(command "line" p1 p2 "")
);progn
);if
);progn
(setq m (1+ m))
);while m
(setq n (1+ n))
);while n
);defun
(princ "Type FDT to run the Find_Dup_Text routine.")
(princ)
So can I just add what you suggested somewhere? This is pretty complex for the few I've done. lol
This will exclude the string BANANA and MANGO
(setq ss (ssget '((0 . "TEXT,MTEXT")(-4 . "<NOT") (1 . "BANANA,MANGO")(-4 . "NOT>"))))
@cole.debolt wrote:
I guess what I was asking is: Can I add this to my existing lisp above, I'm not sure where to add it. I tried it once... I'm trying to exclude an inch " symbol so it doesn't grab all my pipe sizes.
I'm not sure where to add your line in my code. I'm just guessing right now. Thank you
(defun c:fdt () ;;Find Duplicate Text (prompt "Select text items to examine: ") (setq ss (ssget '((0 . "TEXT,MTEXT")(1 . "~*\"*")))) (setq n 0) (while (< n (sslength ss)) (setq string1 (cdr (assoc 1 (entget (ssname ss n))))) (setq string1 (vl-string-right-trim " " (vl-string-left-trim " " string1))) (setq m (1+ n)) (while (< m (sslength ss)) (progn (setq string2 (cdr (assoc 1 (entget (ssname ss m))))) (setq string2 (vl-string-right-trim " " (vl-string-left-trim " " string2))) (if (= string1 string2) (progn (setq p1 (cdr (assoc 10 (entget (ssname ss n))))) (setq p2 (cdr (assoc 10 (entget (ssname ss m))))) (command "line" p1 p2 "") );progn );if );progn (setq m (1+ m)) );while m (setq n (1+ n)) );while n )
we Happy now? 🙂
Y'all better watch it with this one.
I'm glad that Joe Burke is involved.
MTEXT can contain formatting codes with plenty of numbers that can be repeated galore, and the OP is looking for duplicate numbers. So it strikes me that one must compare the content of unformatted strings to be able to focus on the remaining numeric content.
While I created the original @Anonymous function, Joe and Steve Doman took the process to a higher level, so his input here is seriously important.
At least I doubt that "\\P" or "\n" is an issue here because I would think that no numeric string would be broken over sequential lines of text, as in...
"... <blah><blah> shall be no less than 1.
35 mm."
John F. Uhden