明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2106|回复: 8

[已解答] 如何通过修改组码72和73修改文字的对齐点

[复制链接]
发表于 2013-11-19 21:50:39 | 显示全部楼层 |阅读模式
编了个程序,提取第一个文字的对齐方式,即组码72和73的数值,然后把其他文字的组码72和73替换,使所有文字的对齐方式与第一个一样。
以下是我编的代码。运行后,不是对齐方式的控制组码没有被修改,反而是显示内容,也就是组码1变成了组码73的数值。
求教,如何修改这个程序。

  1. (defun c:qq( / txt i dxf72 dxf73 txtent)
  2.     (setq txt (ssget "_:L" '((0 . "TEXT"))))
  3.     (setq i 0)
  4.     (repeat (setq len (sslength txt))
  5.         (setq txtent (entget (ssname txt i)))
  6.         (setq i (1+ i))
  7.         (if (not dxf72)
  8.             (setq dxf72 (rtos (cdr (assoc 72 txtent)))
  9.                 dxf73 (rtos (cdr (assoc 73 txtent)))
  10.             )
  11.             (progn
  12.                 (setq txtent (subst (cons 1 dxf72) (assoc 72 txtent) txtent))
  13.                 (setq txtent (subst (cons 1 dxf73) (assoc 73 txtent) txtent))
  14.                 (entmod  txtent)
  15.             )
  16.         )
  17.     )
  18.     (princ)
  19. )


"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2013-11-19 21:56:31 | 显示全部楼层
试试:
(cons 1 dxf72) --> (cons 72 dxf72)
(cons 1 dxf73) --> (cons 73 dxf73)
 楼主| 发表于 2013-11-19 22:23:46 | 显示全部楼层
ll_j 发表于 2013-11-19 21:56
试试:
(cons 1 dxf72) --> (cons 72 dxf72)
(cons 1 dxf73) --> (cons 73 dxf73)

这个有问题,提示:
; 错误: DXF 组不正确: (72 . "4")
发表于 2013-11-19 23:20:32 | 显示全部楼层
去掉rtos                                 
 楼主| 发表于 2013-11-19 23:35:25 | 显示全部楼层
gdslqs 发表于 2013-11-19 23:20
去掉rtos

去掉rtos的话,也是提示dxf组不正确。
发表于 2013-11-20 00:25:55 来自手机 | 显示全部楼层
是不是if 后面的dxf72 第一次的时候未定义? 用不用在if 函数前加一个 setq dxf72 …… ?
 楼主| 发表于 2013-11-20 07:28:05 | 显示全部楼层
aihuyujian 发表于 2013-11-20 00:25
是不是if 后面的dxf72 第一次的时候未定义? 用不用在if 函数前加一个 setq dxf72 …… ?

用了if not对第一次的文字组码进行了定义
发表于 2013-11-20 08:24:07 | 显示全部楼层
  1. (defun c:qq头( / txt i dxf72 dxf73 txtent)
  2. (setq txt (ssget "_:L" '((0 . "TEXT"))))
  3. (setq i 1)
  4. (setq txtent (entget(ssname txt 0)));第一个文字组码
  5. (setq dxf72 (assoc 72 txtent));第一个文字72组码
  6. (setq dxf73 (assoc 73 txtent));第一个文字73组码
  7. (repeat (setq len (sslength txt))
  8.   (setq txtent (entget (ssname txt i)))
  9.   (setq i (1+ i))
  10.   (setq txtent (subst dxf72 (assoc 72 txtent) txtent))
  11.   (entmod (subst dxf73 (assoc 73 txtent) txtent))
  12. )
  13. (princ)
  14. )
 楼主| 发表于 2013-11-20 23:10:19 | 显示全部楼层
ZZXXQQ 发表于 2013-11-20 08:24

试了下,可以。然后发现,1楼的程序,把rtos、cdr还有cons都删了就可以了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-5-26 03:07 , Processed in 0.221435 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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