LISP - Move center text to selected line/polyline segment and then align text to it and distance text from line given a distance value

LISP - Move center text to selected line/polyline segment and then align text to it and distance text from line given a distance value

cool.stuff
Collaborator Collaborator
282 Views
4 Replies
Message 1 of 5

LISP - Move center text to selected line/polyline segment and then align text to it and distance text from line given a distance value

cool.stuff
Collaborator
Collaborator

Hello 🙂

Does anyone have a lisp to move a selected mtext from its center and align and move it to selected line/polyline segment and distance selected text from selected line/polyline given a defined value?

 

Many many thanks 🙂

0 Likes
Accepted solutions (1)
283 Views
4 Replies
Replies (4)
Message 2 of 5

Sea-Haven
Mentor
Mentor

Post a sample dwg with before and after.

0 Likes
Message 3 of 5

cool.stuff
Collaborator
Collaborator

Thanks for the answer @Sea-Haven 🙂

Sample dwg attached

0 Likes
Message 4 of 5

Sea-Haven
Mentor
Mentor
Accepted solution

Try this

 

; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-move-center-text-to-selected-line-polyline-segment-and-then/td-p/13328372

(defun c:txt2line ( / mp ang txt ins mp)

(defun getplineseg ( / elst ename pt param preparam postparam pt1 pt2)
  (setq elst (entsel "\nSelect pline segment: "))
  (setq ename (car elst))
  (setq pt (cadr elst))
  (setq pt (vlax-curve-getClosestPointTo ename pt))
  (setq param (vlax-curve-getParamAtPoint ename pt))
  (setq preparam (fix param))
  (setq postparam (1+ preparam))
  (setq pt1 (vlax-curve-getPointAtParam ename preparam)
    pt2 (vlax-curve-getPointAtParam ename postparam))
  (setq mp (setq mp (mapcar '* (mapcar '+ pt1 pt2) '(0.5 0.5))))
  (setq ang (angle pt1 pt2))
)

(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq dist 0.1)

(getplineseg)

(setq txt (car (entsel "\nPick text ")))
(setq ins (cdr (assoc 10 (entget txt))))
(setq mp (polar mp (- ang (/ pi 2)) dist))

(command "move" txt "" ins mp)

(princ)
)
0 Likes
Message 5 of 5

cool.stuff
Collaborator
Collaborator

Works like a charm 🙂 many thanks again for helping in another problem @Sea-Haven 

0 Likes