Create Text that Aligns and Increments

Create Text that Aligns and Increments

Anonymous
Not applicable
867 Views
2 Replies
Message 1 of 3

Create Text that Aligns and Increments

Anonymous
Not applicable

So I have all these four sided polygons that I lay out in a row. And I have to label all of them with a textual prefix and then a number on the end that increments. Currently i'm just copying and pasting and editting the text. My knowledge of lisp is enough to ask what the prefix is, ask the starting number, and then use a while loop to iterate what the text should be. But the rest is over my head. I'd like to just have to select the polygon and have it automatically place the text on the bottom right corner, and also align itself if the polygon is rotated. Anybody out there bored and wanting to create something? 😃 I would be forever grateful.

 

I've attached a photo of what they look like.

0 Likes
Accepted solutions (1)
868 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution

Here is something to start with...

(vl-load-com)

(defun c:RotatedText (/ ensel pt1 pt2 par)

  (if (and (setq ensel (entsel "\nSelect polyline close to desired vertex: "))
           (= "LWPOLYLINE" (cdr (assoc 0 (entget (car ensel)))))
           (setq pt1 (vlax-curve-getclosestpointto (car ensel) (trans (cadr ensel) 1 0)))
           (setq par (vlax-curve-getparamatpoint (car ensel) pt1))
           (setq pt2 (vlax-curve-getpointatparam (car ensel) (atoi (rtos par 2 0))))
           )
    (entmakex (list (cons 0 "TEXT")
                    (cons 10 pt2)
                    (cons 11 pt2)
                    (cons 40 (getvar 'TEXTSIZE))
                    (cons 1 "TB42")
                    (cons 50 (angle pt1 pt2))
                    (cons 72 2)
                    (cons 73 1))))
  (princ)
)
Message 3 of 3

Anonymous
Not applicable

Wow awesome....works great....elegant solution. Thanks a bunch! I can add the details from here....you're awesome! 😃

0 Likes