- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I'm trying to change LISP to fit my needs, but I ran into one problem. The routine does the following: using the function entsel, select a polyline and get its properties (lengths and angles of segments, as well as a layer), after which the program asks for text input and places the mtext in the middle of each segment of the polyline. I need: after placing mtext on the polyline, the command must not end; instead, a loop is started, within which it will be possible to continue selecting polylines (located only on the layer of the first picked polyline) using the entsel function, and the previously entered text should be placed on each next selected polyline. Exit the loop by press the key Esc or Enter / Space. How to do it?
(defun c:TextPline ( / obj vert lay du tt n s0 i txt p1 p2 s ang pt )
(while
(or
(not (setq obj (car (entsel "\nPick LwPolyline >"))))
(if obj
(/= (cdr (assoc 0 (entget obj))) "LWPOLYLINE")
)
)
(prompt "\nMissed or picked wrong entity type. ")
)
(setq
vert (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget obj)))
lay (vla-get-layer (vlax-ename->vla-object obj))
du (getstring t "Text above the line: ")
tt (getstring t "Text under the line: ")
n (1- (length vert))
s0 0
i 0
)
(if (= tt "")
(setq txt (strcat du "\n "))
(setq txt (strcat du "\n" tt))
)
(repeat n
(setq
p1 (nth i vert)
p2 (nth (setq i (1+ i)) vert)
s (/ (distance p1 p2) 2)
s0 (+ s0 s)
ang (angle p1 p2)
pt (vlax-curve-getPointAtDist obj s0)
s0 (+ s0 s)
)
(if (> (* pi 1.5) ang (* pi 0.5))
(setq ang (+ ang pi))
)
(entmakex
(list
(cons 0 "MTEXT")
(cons 100 "AcDbEntity")
(cons 100 "AcDbMText")
(cons 1 txt)
(cons 7 "Standard")
(cons 8 lay)
(cons 10 pt)
(cons 40 2)
(cons 50 ang)
(cons 62 256)
(cons 71 5)
(cons 72 5)
(cons 44 1.3)
)
)
)
)
;|«Visual LISP© Format Options»
(100 1 2 2 nil " " 80 60 0 0 0 nil nil nil T)
;***|;
Solved! Go to Solution.