各位大侠,我做了一个明细表文字列居中对齐的小程序,但为什么有时候它可以在原地对齐,为什么有时候它会偏里明细表,跑到很远的地方,下面是程序帮忙看一下为什么?谢谢……- (defun c:alignM( / ent ents pt ty ss i pt2 sc pt_lst len pt3)
- (setq p1(getpoint"\n请输入最下部文字栏线的左边点:"))
- (setq p2(getpoint"\n请输入最下部文字栏线的右边点:"))
- (prompt "选择文字...")
- (setq ss (ssget '((0 . "TEXT"))))
- (setq sc 1)
- (setq i 0)
- (repeat (sslength ss)
- (setq ent (ssname ss i))
- (setq ents (entget ent))
- (setq pt2 (cdr (assoc 10 ents)))
- (setq pt2 (list (/ (+ (car p2) (car p1)) 2) (cadr pt2) (last pt2)))
- (setq pt_lst (textbox ents))
- (setq len (- (caadr pt_lst) (caar pt_lst)))
- (setq pt3 (polar pt2 (cdr (assoc 50 ents)) (* len sc)))
- (setq ents (subst (cons 11 pt2) (assoc 11 ents) ents))
- (setq ents (subst (cons 72 1) (assoc 72 ents) ents))
- (if (> len (- (car p2) (car p1)))
- (progn (setq kdbl (/ (- (car p2) (car p1)) (+ 2 len)))
- (setq ents (subst (cons 41 kdbl) (assoc 41 ents) ents))
- )
- )
- ;(setq ents (subst (cons 11 pt3) (assoc 11 ents) ents))0
- (entmod ents)
- (setq i (1+ i))
- )
- (princ)
- )
|