用Vlisp写了一个- ;;;;文本水平对齐
- ;;;by:lihuili 2009-12-22
- (vl-load-com)
- (defun c:txt_hor_Alignment (/ Ent Obj InsPt ss TxtList item text_InsPt NewInsPt)
- (setq Ent (entsel "\n 选择要对齐的参考文本(位置不变的文本): "))
- (if (and
- Ent
- (= (value 0 (entget (car Ent))) "TEXT")
- (not (redraw (car Ent) 3))
- )
- (progn
- (setq Obj (MakeX (car Ent)))
- (if (= (vla-get-Alignment Obj) 0)
- (setq InsPt (safearray-value
- (variant-value (vla-get-InsertionPoint Obj))
- )
- )
- (setq
- InsPt (safearray-value
- (variant-value (vla-get-TextAlignmentPoint Obj))
- )
- )
- )
- (prompt "\n选择其他与参考对齐的文本(要改变位置)!")
- (if (setq ss (ssget '((0 . "TEXT"))))
- (progn
- (setq TxtList (ss->Objlist ss))
- (foreach item TxtList
- (if (= (vla-get-Alignment item) 0)
- (setq text_InsPt
- (safearray-value
- (variant-value (vla-get-InsertionPoint item))
- )
- )
- (setq text_InsPt
- (safearray-value
- (variant-value
- (vla-get-TextAlignmentPoint item)
- )
- )
- )
- )
- (setq
- InsPt (list (car text_InsPt)
- (cadr InsPt)
- (caddr InsPt)
- )
- )
- (setq NewInsPt (vlax-3d-point InsPt))
- (if (= (vla-get-Alignment item) 0)
- (vla-put-InsertionPoint item NewInsPt)
- (vla-put-TextAlignmentPoint item NewInsPt)
- )
- (redraw (car Ent) 4)
- )
- )
- )
- )
- )
- (princ)
- )
- (defun VALUE (num ent /)
- (cdr (assoc num ent))
- )
- (defun MakeX (entname)
- (vlax-ename->vla-object entname)
- )
- (defun ss->Objlist (ss / RtnList temp1)
- (while (setq temp1 (ssname ss 0))
- (setq RtnList (cons (vlax-ename->vla-object temp1) RtnList))
- (ssdel temp1 ss)
- )
- RtnList
- )
-
|