查看: 1900|回复: 2

申请编程

[复制链接]
2443725 发表于 2004-5-10 17:01 | 显示全部楼层 |阅读模式

在CAD表格中(管口表和明细表)使用时间,会出现


文字对不齐的情况,我只能先画一条垂直线,然后再


一个一个移动,很麻烦,不知道大家有没有什么程序,


可以使文字对起,谢谢大家?


见下图,


<BR>

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?[加入论坛]

x
sherman 发表于 2004-5-10 18:11 | 显示全部楼层
(defun lconerr (s)<BR>                 (if (/= s "Function cancelled")                 <BR>                                         (princ (strcat "\nError: " s)) <BR>                 )<BR>                 (setq text nil)                                                                                                                                                                         <BR>                 (setq *error* olderr)                                                                                                 <BR>                 (princ)<BR>)


(defun getde()<BR>                 (setq de (car (entsel "\n请选择对齐的目标文字&lt;所有的都向我看齐!&gt;:")))<BR>                 (if (= de nil) (getde))<BR>                 (setq el (entget de))<BR>                 (setq ty (assoc 0 el))<BR>                 (if (/= "TEXT" (cdr ty)) (getde) )<BR>)


(defun getsel()<BR>                 (setq sel nil)<BR>                 (princ "\n请选择要对齐的文字&lt;跟着共产党走!自动过滤&gt;:")<BR>                 (setq sel (ssget))<BR>)


(defun C:wzdq (/ sel e dx dy el de num n x y ty inf olderr ab ac dc db);<BR>                 (setq olderr         *error*                                                                                                 <BR>                         *error* lconerr)<BR>                 (princ "\n                                                                 Tolly 私人工作室,非常感谢您的支持!")<BR>                 (princ "\n本程序快捷键为 wzdq !\n")<BR>                 (command "redraw")<BR>                 (getde)<BR>                 (getsel)<BR>                 (initget "A X Y")                                 <BR>                 (setq key (getkword "\nA只改变对齐方式/ Y垂直方向对齐 | / &lt;X水平方向对齐 --&gt; "))<BR>                 (setq e (assoc 10 el))<BR>                 (setq dx (nth 1 e))<BR>                 (setq dy (nth 2 e))<BR>                 (setq ac (assoc 72 el))<BR>                 (setq ab (assoc 73 el))


                 (if sel <BR>                                 (progn                                                                                                                                                                         <BR>                                                         (setq num 0 n (sslength sel))<BR>                                                         (while (&lt; num n)                                                                                                                                 <BR>                                                                                         (if (= "TEXT" (cdr (assoc 0 (setq inf (entget (ssname sel num)))))) ;if text<BR>                                                                                                         (progn<BR>                                                                                                         (if (or (= key "X") (= key nil) )<BR>                                                                                                                                 (progn<BR>                                                                                                                                 (setq x (nth 1 (assoc 10 inf) )) <BR>                                                                                                                                 (setq inf (subst (list 10 x dy 0) (assoc 10 inf) inf))<BR>                                                                                                                                 (entmod inf)<BR>                                                                                                                                 );progn<BR>                                                                                                                 );if<BR>                                                                                                         (if (= key "Y")<BR>                                                                                                                                 (progn<BR>                                                                                                                                 (setq y (nth 2 (assoc 10 inf) )) <BR>                                                                                                                                 (setq inf (subst (list 10 dx y 0) (assoc 10 inf) inf))<BR>                                                                                                                                 (entmod inf)<BR>                                                                                                                                 );progn<BR>                                                                                                                 );if                         <BR>                                                                                                         (setq inf (subst ac (assoc 72 inf) inf)) <BR>                                                                                                         (setq inf (subst ab (assoc 73 inf) inf))<BR>                                                                                                         (entmod inf)<BR>                                                                                                                 );progn<BR>                                                                                         );if<BR>                                                         (setq num (1+ num))<BR>                                                         );while <BR>                                 );progn<BR>                 );if<BR>                                                                                                                                                                                                                 (if (= key "A") (princ "\n对齐方式已改变!"))<BR>                 (setq e (assoc 11 el))<BR>                 (setq dx (nth 1 e))<BR>                 (setq dy (nth 2 e))<BR>                 (if (and sel (/= 0.0 dx) (/= 0 dy))<BR>                                 (progn                                                                                                                                                                         <BR>                                                         (setq num 0 n (sslength sel))<BR>                                                         (while (&lt; num n)                                                                                                                                 <BR>                                                                                         (if (= "TEXT" (cdr (assoc 0 (setq inf (entget (ssname sel num)))))) ;if text<BR>                                                                                                         (progn<BR>                                                                                                         ;(setq inf (subst ac (assoc 72 inf) inf)) <BR>                                                                                                         ;(setq inf (subst ab (assoc 73 inf) inf))<BR>                                                                                                         ;(entmod inf)<BR>                                                                                                         (if (or (= key "X") (= key nil) )<BR>                                                                                                                                 (progn<BR>                                                                                                                                 (setq x (nth 1 (assoc 11 inf) )) <BR>                                                                                                                                 (setq inf (subst (list 11 x dy 0) (assoc 11 inf) inf))<BR>                                                                                                                                 (entmod inf)<BR>                                                                                                                                 );progn<BR>                                                                                                                 );if<BR>                                                                                                         (if (= key "Y")<BR>                                                                                                                                 (progn<BR>                                                                                                                                 (setq y (nth 2 (assoc 11 inf) )) <BR>                                                                                                                                 (setq inf (subst (list 11 dx y 0) (assoc 11 inf) inf))<BR>                                                                                                                                 (entmod inf)<BR>                                                                                                                                 );progn<BR>                                                                                                                 );if                         <BR>                                                                                                                 );progn<BR>                                                                                         );if


                                                         (setq num (1+ num))<BR>                                                         );while <BR>                                 );progn<BR>                 );if<BR>                 (setq *error* olderr)<BR>                 (princ)<BR>)<BR>(princ "\n本程序快捷键为 wzdq !\n")


       


       


备注:以上程序我是从本论坛下载的,我用了一下可以达到X与Y两个方向的对齐功能.

回复 支持 反对

使用道具 举报

 楼主| 2443725 发表于 2004-5-11 20:20 | 显示全部楼层
感谢sjyhy,可用,


呵呵,下次发程序,最好告诉我们程序的命令!


这里的命令是:ali


感谢!

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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