Find coordinates of text in box.

Find coordinates of text in box.

davidlanesmith673
Enthusiast Enthusiast
639 Views
6 Replies
Message 1 of 7

Find coordinates of text in box.

davidlanesmith673
Enthusiast
Enthusiast

In my AutoLISP code I am creating a selection set with the text and the box around it shown below. I am wondering if there is a way to determine the coordinates of the text from the selection set?

davidlanesmith673_0-1624995078848.png

 

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

CodeDing
Advisor
Advisor
Accepted solution

@davidlanesmith673 ,

 

Do you know how to loop through a Selection Set to get the entity names? This sounds like what you are wanting because once you have the entity name of the TEXT object, you can get what you want from it:

(defun c:TEST ( / ss cnt e)
  (if (setq ss (ssget '((0 . "LWPOLYLINE,TEXT"))))
    (progn
      (repeat (setq cnt (sslength ss))
        (setq e (ssname ss (setq cnt (1- cnt))))
        (prompt (strcat "\nHere is the " (cdr (assoc 0 (entget e))) " entity!"))
      );repeat
    );progn
  ;else
    (prompt "\nNo LWPolylines or Text were selected.")
  );if
  (princ)
);defun

 

Does that help?

 

Best,

~DD

0 Likes
Message 3 of 7

ronjonp
Mentor
Mentor

Look into the TEXTBOX function.

0 Likes
Message 4 of 7

davidlanesmith673
Enthusiast
Enthusiast

I think so, how do you know when the entity name is for the text object, and not for the polyline?

0 Likes
Message 5 of 7

CodeDing
Advisor
Advisor
Accepted solution

@davidlanesmith673 ,

 

It would go something like this:

      .....
      (repeat (setq cnt (sslength ss))
        (setq e (ssname ss (setq cnt (1- cnt))))
        (if (eq "TEXT" (cdr (assoc 0 (entget e))))
          (prompt "\nHere is a Text entity!")
        );if
      );repeat
      .....

 

Best,

~DD

0 Likes
Message 6 of 7

davidlanesmith673
Enthusiast
Enthusiast

Yah I think I understand entities a bit better now, I figured it out now, thank you for your help!!

Message 7 of 7

Sea-Haven
Mentor
Mentor

 Another way is get selection of plines then use ssget "WP" lst '((0 . "TEXT")) so it will look inside for text can be irregular shapes as well. A common use is "room number" and "area". Using "Lwpolylines,TEXT" can find text outside of a box.

0 Likes