I have no problem with routines finding overlapping entities, but I like to be given the opportunity to choose what to do with them.
This works a little differently than your functional specification.
It checks the active layout to see if there are any overlapping text.
It creates a previous selection set with any duplicate text entities and tells you how many it found.
You can decide what to do with them.
P=
Code:
;______________________________________________________________________________________________________________
;
; Overlaptext finds and creates a selection set of overlapping text entities
; Written by: Peter Jamtgaard copyright 2015
;______________________________________________________________________________________________________________
(defun C:OverLapText (/ lstSelections lstOfSublists lstOverlaps lstSublist1 lstSublist2 ssSelections strHandle)
(if (setq ssSelections (ssget "x" (list (cons 0 "text")(cons 410 (getvar "ctab")))))
(and
(setq lstSelections (SelectionSetToList ssSelections))
(setq lstSelections (mapcar 'vlax-ename->vla-object lstSelections))
(setq lstOfSublists (mapcar 'PropertyMatchList lstSelections))
(foreach lstSublist1 lstOfSublists
(setq lstOfSublists (vl-remove lstSublist1 lstOfSublists))
(foreach lstSublist2 lstOfSublists
(and (/= (car lstSublist1)(car lstSublist2))
(apply 'and (mapcar 'equal (cdr lstSublist1)(cdr lstSublist2)))
(setq strHandle2 (car lstSublist2))
(not (member strHandle2 lstOverlaps))
(setq lstOverlaps (cons strHandle2 lstOverlaps))
)
)
)
)
)
(if lstOverlaps
(progn
(listtoselectionset (mapcar 'handent lstOverlaps))
(princ (strcat "\n" (itoa (sslength (ssget "p")))))
(princ " pieces of Overlapping text are in previous selection set! ")
(prin1)
)
)
)
;______________________________________________________________________________________________________________
; Convert a list of entities to a selection set
;______________________________________________________________________________________________________________
(defun ListToSelectionSet (lstENames / entItem ssSelections)
(setq ssSelections (ssadd))
(foreach entItem lstENames (ssadd entItem ssSelections))
(command "select" ssSelections "")
)
;______________________________________________________________________________________________________________
; Convert a selection set to a list of entities
;______________________________________________________________________________________________________________
(defun SelectionSetToList (ssSelections / entSelection intCount objSelection lstReturn)
(repeat (setq intCount (sslength ssSelections))
(setq intCount (1- intCount))
(setq entSelection (ssname ssSelections intCount))
(setq lstReturn (cons entSelection lstReturn))
)
lstReturn
)
;______________________________________________________________________________________________________________
; Function to create a list of properties for a vla-object
;______________________________________________________________________________________________________________
(defun PropertyMatchList (objSelection)
(mapcar '(lambda (x)(vlax-get objSelection X))
(list 'handle 'textstring 'insertionpoint 'layer 'height 'stylename); <- This is where you can change the properties
)
)
(vl-load-com)
;______________________________________________________________________________________________________________