FS texts Mtexts touching a polyline

FS texts Mtexts touching a polyline

alsawadi.re
Contributor Contributor
515 Views
6 Replies
Message 1 of 7

FS texts Mtexts touching a polyline

alsawadi.re
Contributor
Contributor

Hi I need a lisp that let me pick a polyline and select all texts that touching that polyline.. It's better if it's possible to select also the texts inside blocks

0 Likes
Accepted solutions (2)
516 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution

Perhaps like this. Selecting texts inside the blocks isn't possible.

 

(defun c:FSM ( / p s)
  (c:fastsel)
  (setq s (ssget "_P" '((0 . "*TEXT"))))
  (sssetfirst nil)
  (sssetfirst nil s)
  (princ)
  )
0 Likes
Message 3 of 7

Moshe-A
Mentor
Mentor
Accepted solution

@alsawadi.re 

 

check this one

 

thank you Lee Mac for wonderful (LM:intersections) function. without it where were we? 😀

 

Moshe

 

 

(vl-load-com)

(defun c:tset (/ LM:intersections ; local function
		  pick ss0 ss1 AcDbPline AcDbText)

 ;; Intersections  -  Lee Mac
 ;; Returns a list of all points of intersection between two objects
 ;; for the given intersection mode.
 ;; ob1,ob2 - [vla] VLA-Objects
 ;;     mod - [int] acextendoption enum of intersectwith method

 (defun LM:intersections ( ob1 ob2 mod / lst rtn )
    (if (and (vlax-method-applicable-p ob1 'intersectwith)
             (vlax-method-applicable-p ob2 'intersectwith)
             (setq lst (vlax-invoke ob1 'intersectwith ob2 mod))
        )
        (repeat (/ (length lst) 3)
            (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn)
                  lst (cdddr lst)
            )
        )
    )
    (reverse rtn)
 ); LM:intersections


 ; here start (c:tset)
 (cond
  ((not
     (and
       (setq pick (entsel "\nPick a polyline: "))
       (wcmatch (cdr (assoc '0 (entget (car pick)))) "LWPOLYLINE,POLYLINE")
     )
   ); not
   (vlr-beep-reaction)
   (prompt "\nobject selected is not a polyline.")
  ); case
  ((not (setq ss0 (ssget "x" '((0 . "text,mtext") (410 . "model")))))
    (vlr-beep-reaction)
    (prompt "\ncan find any text object.")
  ); case
  ( t
   (setq AcDbPline (vlax-ename->vla-object (car pick)))
   (setq ss1 (ssadd))

   (vlax-for AcDbText (vla-get-activeSelectionSet (vla-get-activedocument (vlax-get-acad-object)))
     
    (if (LM:intersections AcDbPline AcDbText acExtendNone)
     (ssadd (vlax-vla-object->ename AcDbText) ss1)
    )
     
    (vlax-release-object AcDbText)
   ); vlax-for

   (vlax-release-object AcDbPline)

   (if (> (sslength ss1) 0)
    (sssetfirst ss1 ss1) ; vwalla, select text(s)
   )
  ); case 
 ); cond

 (princ) 
); c:tset

 

0 Likes
Message 4 of 7

Kent1Cooper
Consultant
Consultant

I suspect you will not always get the results you want if you use the FS / FASTSEL Express Tool.  It requires actual crossing of drawn content, and in some cases that will miss Text/Mtext objects that you expect it to find, affected by their specific content.  Here, FS and picking the white Polyline "sees" only the green Mtext at lower right, but not any of the others that the Polyline passes through but does not actually "hit."

Kent1Cooper_0-1667573815289.png

Kent Cooper, AIA
0 Likes
Message 5 of 7

alsawadi.re
Contributor
Contributor
I agree sir ... FS sometimes miss some large texts since the polyline will pass the gap between letters
0 Likes
Message 6 of 7

alsawadi.re
Contributor
Contributor
Thanks sir it works
0 Likes
Message 7 of 7

alsawadi.re
Contributor
Contributor
Many many thanks sir ..this is better than FS method will not ignore any text
0 Likes