Hello,
This is a routine that draws a line between duplicate text.
Would it be possible to have the line as bold red p-line so that its easier to identify.
thanks
;; 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)
Solved! Go to Solution.
Solved by Migumby. Go to Solution.
@Migumby wrote:....
This is a routine that draws a line between duplicate text.
Would it be possible to have the line as bold red p-line so that its easier to identify.
....
One way would be to change this line:
(command "line" p1 p2 "")
to this instead:
(command "_.pline" p1 "_width" somenumber "" p2 "_width" 0 "" "")
That will leave you with a current Polyline width setting [for the next Polyline you draw for some other purpose] of 0, rather than your find-it-more-easily width. If you don't mind leaving it at that non-zero width, omit the "_width" 0 "" above. You can also have the routine save the current width, whatever it is, and reset it afterwards, if you're interested.
The somenumber value could be a fixed number of your choice, or it could be calculated [for example, as a percentage of the viewing area height, or based on the drawing scale].
And after
(command "_.pline" p1 "_width" ...
as Kent Cooper suggested, add
(command "._chprop" "_L" "" "_C" "1" "")
to change pline color to red
Henrique
@hmsilva wrote:And after
(command "_.pline" p1 "_width" ...
as Kent Cooper suggested, add
(command "._chprop" "_L" "" "_C" "1" "")
to change pline color to red
Henrique
Of course -- I forgot that part. But now it occurs to me that doing it at that point in the routine means potentially [if there are many duplicates] a lot of changing Polyline width back and forth, and a lot of assigning a color override to individual Polylines separately, when much of that can be avoided. Try something like this
(defun c:fdt (/ plw col ss n m string1 string2 p1 p2) ;;Find Duplicate Text
;; should probably add error handler, but I'll leave that to you....
(prompt "Select text items to examine: ")
(setq
plw (getvar 'plinewid)
col (getvar 'cecolor)
ss (ssget '((0 . "TEXT,MTEXT"))); <-- shorter way -- (ssget) honors (wcmatch) syntax
n 0
); setq
(setvar 'plinewidth somenumber)
(setvar 'cecolor 1)
(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 "_.pline" p1 p2 "")
);progn
);if
);progn
(setq m (1+ m))
);while m
(setq n (1+ n))
);while n
(setvar 'plinewid plw)
(setvar 'cecolor col)
(princ); moved here so 'cecolor value doesn't appear on Command: line
);defun
(princ "Type FDT to run the Find_Dup_Text routine.")
(princ)
Hi Kent,
On the first post that you gave me, I couldn’t seem to get a line weight working that was anything less than zero.
I tried the second posting and I don’t see any difference.
Maybe I’m doing something wrong?
I would like the p-line to be .05 in size.
thanks for all of your help.
@Kent1Cooper wrote:
....(setvar 'plinewidth somenumber)
....
Whoops -- that should be:
(setvar 'plinewid somenumber)
Faster and cleaner. I also took the liberty of assuming you don't care about matching case. If I am wrong, just remove the (strcase and corresponding closing paren.
(defun c:FDT (/ ss i data str asso lst) (if (setq ss (ssget '((0 . "MTEXT,TEXT")))) (progn (repeat (setq i (sslength ss)) (setq data (entget (ssname ss (setq i (1- i)))) str (strcase (vl-string-right-trim " " (vl-string-left-trim " " (cdr (assoc 1 data))))) lst (if (setq asso (assoc str lst)) (subst (cons str (cons (assoc 10 data) (cdr asso))) asso lst) (cons (list str (assoc 10 data)) lst) ) ) ) (foreach item lst (if (> (length item) 2) (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length (cdr item))) '(70 . 0) '(62 . 1) ; color '(43 . 0.05) ; width ) (cdr item) ) ) ) ) ) ) (princ) )
@Kent1Cooper wrote:
...(setvar 'cecolor 1)
....
A belated further correction to the code in Post 4:
Change the above line to this:
(setvar 'cecolor "1")
It needs to be a string, since there is the possibility of its being "Bylayer" or "Byblock" or "red" or ....