;;;Elise Moss ;;;www.mossdesigns.com ;;;July 2007 ;;;This routine searches a drawing for any text entities to ;;;find a text segment, and the program will draw a line from 0,0 to the insertion point of the actual text strings. (defun c:tseg () ; ask the user for the text string (setq text-segment (getstring "\nWhat text should we search for? ")) ; first we need to select all the text in the drawing (setq ss-txt (ssget "x" (list (cons 0 "TEXT")))) ; now let's see how many text entities we collected (setq ss-txt-no (sslength ss-txt)) ; now we have to look at each text item and search for the 002 string ; so we initiate a counter (setq counter 0) ; loop thru the collection (while (< counter ss-txt-no) ;get the next item in the collection (setq text-item (ssname ss-txt counter)) ; get the text entity data (setq text-data (entget text-item)) ; get the text value (setq text-value (cdr (assoc 1 text-data))) ; now does that text-value have the text segment in it (setq flag (vl-string-search text-segment text-value)) (if (= flag nil) ; then no match and go to the next item (setq counter (+ counter 1)) ) ; the value in flag indicates the position of the text pattern (if (/= flag nil) (progn ; then we need to get the insertion point of the text so we can draw our line (setq ins-pt (cdr (assoc 10 text-data))) ; then we need to draw the line from 0, 0 to that point (command "line" "0,0" ins-pt "") ; then we go on to the next text object (setq counter (+ counter 1)) ) ;end progn ) ;end if ) ;end while ; let the person know he's done (alert "All Done!") ) ;end defun