;TextAlign 文本对齐 ,适用曲线LINE,ARC,CIRCLE,ELLIPSE
(defun C:mini_text_align (/ old_cmd old_osmode ang elist ename pt sscur sstxt ang_sharp) 

    (defun ang_sharp ( ang )
        (setq ang (mai_trans_ang ang 0 1))
        (if (> (* 1.5 pi) ang (* 0.5 pi)) (- ang pi) ang)
        (mai_trans_ang ang 1 0)
    )
    
    (mini_start nil)
    (mai_last_com "mini_text_align")
    (setq old_osmode (getvar "osmode"))
    (setvar "osmode" 512)
    ;;(angtos (jw-angle-curvept (car (entsel)) (getpoint)) 0 )
    (setq sstxt (mai_select_first '((0 . "*TEXT")) "选需要文字齐线的文字:" "没有选择文字物体."))
    (and (setq pt (getpoint "\n点取需要对齐的曲线或直线上一点<退出>:"))
         (setq ename (ssget pt '((0 . "*LINE,ARC,CIRCLE,ELLIPSE"))))
    )
    (or ename (exit))
    (setq ename (ssname ename 0)
          ang (ang_sharp (angle '(0 0 0) (vlax-curve-getfirstderiv ename (vlax-curve-getparamatpoint ename (trans pt 1 0)))))
    )
    (foreach ename (mai_ssget_2_list sstxt)
        (setq elist (entget ename)
              elist (subst (cons 50 ang) (assoc 50 elist) elist)
        )
        (entmod elist)
    )
    (mai_end)
) 
