Well, your code is prompting for the selection of a circle, not text, so how should it recognise the texts?
If I'm understanding right, you prefer the same texts in the same unique layer with the linetype "CONTINUOUS". If that's the case, you can simply put it in, for example, "PLTRACE-kill1" layer or something like that.
In my case...
(defun c:textcircle ( / circles dets ent i pl ss texts txt unique)
(defun unique (lst / rtn)
(while lst
(setq rtn (cons (car lst) rtn)
lst (vl-remove (car lst) lst)
)
)
(reverse rtn)
)
(if (setq ss (ssget '((0 . "CIRCLE,TEXT,MTEXT"))))
(progn
(repeat (setq i (sslength ss))
(if (eq (cdr (assoc 0 (entget (setq ent (ssname ss (setq i (1- i))))))) "CIRCLE")
(setq circles (cons ent circles))
(setq texts (cons ent texts))
)
)
(foreach x circles
(if
(setq txt
(car (vl-member-if
'(lambda (y)
(equal
(cdr (assoc 10 (entget x)))
(cdr (assoc 11 (entget y)))
1e-8
)
)
texts
)
)
)
(setq dets (cons (cons (cdr (assoc 1 (entget txt))) x) dets))
)
)
(foreach x (unique (mapcar 'car dets))
(if (> (length (setq pl (vl-remove-if-not '(lambda (y) (eq x (car y))) dets))) 1) ; If statement added to escape one-vertex segments
(entmake
(append
'(
(0 . "LWPOLYLINE")
(100 . "AcDbEntity")
(100 . "AcDbPolyline")
(6 . "Continuous") ; <--- Adjusted linetype to Continuous
)
(list
(cons 90 (length pl))
(cons 8 (strcat "TEXTCIRCLE-" x)) ; <--- Line added, put in layer "TEXTCIRCLE-" followed by the text name.
)
(apply 'append
(mapcar '(lambda (y)
(list
(assoc 10 (entget (cdr y)))
'(40 . 0)
'(41 . 0)
'(42 . 0)
'(91 . 0)
)
)
pl
)
)
)
)
) ; Close if
)
)
)
)