Alhazred
Guest
I am trying to write a function that let me select the ends of a line and that automatically insert a text centered on that line and at a distance fixed by it.
for now I have written this:
but it only works if the line is horizontal, while the line is tilted, the more the writing is close to the line, until it intersects.
How can I get what I need?
for now I have written this:
Code:
(defun c:centratesto( / pt1 pt2 ang ptc offs puntom)
(setq pt1 (getpoint 1))
(setq pt2 (getpoint 2))
(setq ang (angle pt1 pt2))
(setq ang (/ (* ang 180) pi) ; angle in grades
(setq ptc (/ (+car pt1) (car pt2)) 2.0) ; central point on the x axis
(setq offs (/ (+ (cadr pt1) 0.1) (+ (cadr pt2) 0.1))); central point on the axis y + 0.1 to raise the text from the line
(setq puntom (list ptc offs))
(command "_text" "_justify" "_mc" pointm 0.1 ang "text")
(princ)
)
How can I get what I need?