[求助]属性块文字的居中对齐
<p>请问一下,怎样实现属性块中文字的居中对齐?</p><p>我之前找了一个,但好像实现不了,有这方面的源码的发一下好吗?</p><p>谢谢了!!!</p>(setq alatt_al "M") ;控制对齐方式的全局变量
(defun alatt (/ ss ent na tmp al e72 e66 attent n att attpt)
(initget "L R M ")
(if (setq tmp
(getkword
(strcat "\n请选择对齐方式[左(L)/中(M)/右(R)]<" alatt_al ">")
)
)
(setq alatt_al tmp)
) ;_IF
(cond ((= alatt_al "L") (setq e72 0))
((= alatt_al "M") (setq e72 1))
((= alatt_al "R") (setq e72 2))
) ;将对齐方式转换成对齐的组码值
(setq ss (ssget '((0 . "INSERT"))))
(if ss
(progn
(setq n 0)
(repeat (sslength ss)
(setq na(ssname ss n)
att na
ent (entget na)
n (1+ n)
)
(if (and (setq e66 (assoc 66 ent)) (= (cdr e66) 1)) ;判断是否为属性块
(while
(and
(setq att (entnext att))
(/= (cdr (assoc 0 (setq attent (entget att)))) "SEQEND")
)
(setq attpt (alatt-startPt attent)) ;获得文字的插入点
(setq attent (subst (cons 10 attpt) (assoc 10 attent) attent)
attent (subst (cons 11 attpt) (assoc 11 attent) attent)
)
(if (assoc 72 attent)
(setq attent (subst (cons 72 e72) (assoc 72 attent) attent)
)
(setq attent (REVERSE attent)
attent (cons (cons 72 e72) attent)
attent (REVERSE attent)
)
)
(entmod attent)
(entupd na)
) ;遍历属性块的属性图元,进行对齐操作
) ;_IF
) ;_REPEAT
)
) ;_IF
(princ)
) ;_END_DEFUN
;;;判断当前文字的对齐方式,返回文字的插入点
(defun alatt-startPt (ent / rel e72 e74)
(setq e72 (assoc 72 ent)
e74 (assoc 74 ent)
)
(if (or (and e72 (/= (cdr e72) 0))
(and e74 (/= (cdr e74) 0))
)
(setq rel (cdr (assoc 11 ent)))
(setq rel (cdr (assoc 10 ent)))
)
rel
)
确实有用,好东西谢谢了。
页:
[1]