• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

centering a text on a line

  • Thread starter Thread starter Alhazred
  • Start date Start date

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:
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)
)
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?
 
Look at the lisp, find 2 versions of your command, centertext is modified for how you thought it, centertext2 is for how I would do it, assuming the use of lines where to place the text.

p.s.: single and rppt functions can be useful on many occasions.

bye
 

Attachments

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top