找回密码
 [加入论坛]
查看: 3541|回复: 5

autocad中对齐(左、中、右对齐)文本的lisp代码

[复制链接]
2443725 发表于 2004-5-12 23:26 | 显示全部楼层 |阅读模式
<TABLE class=tf width="98%" border=0>
<TBODY>
<TR>
<TD height=30><FONT class=red_3><B>[分享]autocad中对齐(左、中、右对齐)文本的lisp代码</B></FONT></TD></TR>
<TR>
<TD class=bw><FONT class=htd>;;程序名称:对象水平对齐程序<BR>;;执行命令:ao<BR>;;程序功能:将选定的对象左对齐、右对齐或对中。<BR>;;<BR>;;<BR>(defun        c:ao        (/        selob<I>js</I>        oldcmdecho)<BR>                (setq        oldcmdecho        (getvar        <I>"</I>cmdecho<I>"</I>))<BR>                (setvar        <I>"</I>cmdecho<I>"</I>        0)<BR>                (setq        selob<I>js</I>        (ssget        <I>'</I>((0        .        <I>"</I>TEXT<I>"</I>))))<BR>                (process        selob<I>js</I>)<BR>                (setvar        <I>"</I>cmdecho<I>"</I>        oldcmdecho)<BR>                (princ)<BR>)<BR>(defun        process        (selob<I>js</I>                        /                                        amode                                        apnt        apnt_x<BR>                apnt_y                        count                                        objname                        vlaxobj        MinPoint<BR>                MaxPoint                minext                        maxext                        ext_l        ext_r<BR>                ext_m                        tpnt<BR>                                                                )<BR>                (initget        <I>"</I>L        M        R<I>"</I>)<BR>                (setq        amode        (getkword<BR>                <I>"</I><BR>选择对齐方式[左对齐(L)/居中(M)/右对齐(R)]&lt;居中&gt;:<I>"</I><BR>                                                        )<BR>                )<BR>                (if        (not        amode)<BR>                                (setq        amode        <I>"</I>M<I>"</I>)<BR>                )<BR>                (initget        1)<BR>                (setq        apnt        (getpoint        <I>"</I><BR>选择水平对齐方向的对齐点:<I>"</I>))<BR>                (setq        apnt_x        (car        apnt)<BR>        apnt_y        (cadr        apnt)<BR>                )<BR>                (vl-load-com)<BR>                (setq        count        0)<BR>                (repeat        (sslength        selob<I>js</I>)<BR>                                (setq        objname        (ssname        selob<I>js</I>        count))<BR>                                (setq        vlaxobj        (vlax-ename-&gt;vla-object        objname))<BR>                                (setq        MinPoint        (vlax-make-variant))<BR>                                (setq        MaxPoint        (vlax-make-variant))<BR>                                (vla-GetBoundingBox        vlaxobj        <I>'</I>MinPoint        <I>'</I>MaxPoint)<BR>                                (setq        minext        (vlax-safearray-&gt;list        MinPoint))<BR>                                (setq        maxext        (vlax-safearray-&gt;list        MaxPoint))<BR>                                (setq        ext_l        (car        minext))<BR>                                (setq        ext_r        (car        maxext))<BR>                                (setq        ext_m        (+        (/        (abs        (-        ext_l        ext_r))        2)        ext_l))<BR>                                (cond<BR>                                                ((=        amode        <I>"</I>L<I>"</I>)<BR>                                                        (setq        tpnt        (list        ext_l        apnt_y))<BR>                                                )<BR>                                                ((=        amode        <I>"</I>M<I>"</I>)<BR>                                                        (setq        tpnt        (list        ext_m        apnt_y))<BR>                                                )<BR>                                                ((=        amode        <I>"</I>R<I>"</I>)<BR>                                                        (setq        tpnt        (list        ext_r        apnt_y))<BR>                                                )<BR>                                )<BR>                                (if        tpnt<BR>                                                (command        <I>"</I>_move<I>"</I>        objname        <I>"</I><I>"</I>        <I>"</I>non<I>"</I>        tpnt        <I>"</I>non<I>"</I>        apnt)<BR>                                )<BR>                                (setq        count        (1+        count))<BR>                )<BR>)</FONT></TD></TR></TBODY></TABLE>
hpy 发表于 2004-5-13 04:08 | 显示全部楼层
好程序,谢谢!
回复 顶 踩

使用道具 举报

sherman 发表于 2004-5-13 17:23 | 显示全部楼层
让我试一试!
回复 顶 踩

使用道具 举报

Smile 发表于 2004-5-18 18:47 | 显示全部楼层
我也有一个,不知怎么上传!
回复 顶 踩

使用道具 举报

dblue 发表于 2004-10-24 07:30 | 显示全部楼层
我好像在明经看过
回复 顶 踩

使用道具 举报

jaffy27ly 发表于 2004-11-23 06:07 | 显示全部楼层
<>不错</P>
回复 顶 踩

使用道具 举报

您需要登录后才可以回帖 登录 | [加入论坛]

本版积分规则

手机版|化工技术网- 赠人玫瑰 手有余香 ( 苏ICP备14035884号 )

GMT+8, 2026-12-1 16:27

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表