明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1258|回复: 1

[求助]修改图号程序(尾数处理)

[复制链接]
发表于 2009-5-12 08:43:00 | 显示全部楼层 |阅读模式

此程序可以提取源文字或者属性文字内容,修改其他文字时会自动加1,常用于修改图号,可是程序的尾数处理不是很理想,下图中上部分是此程序运行的结果,下部分是理想的结果,不知哪位好心人可以帮忙修改一下。
图片内容:

程序代码:
;;数字加1;;常用于图号
(defun c:jk( )
(setq tqwz (car (nentsel "\n选起始图号:")))
(setq txt1 (entget tqwz))
(setq txt1 (cdr (assoc 1 txt1)))


(setq aa (atoi txt1))

(if (and (> aa 0 ) (= (itoa aa) txt1 ) ) (tj2 ) (tj1 ) )
(princ)
)

(defun tj1( / mm zz pp txt2 tqwz kk txt3)
(setq mm (strlen txt1))
(setq zz mm )
(while (or (> (atoi (substr txt1 zz )) 0) (= (substr txt1 zz zz ) "0" ))
(setq zz (- zz 1))
)
(setq pp (substr txt1 (+ zz 1) ))
(setq txt2 (substr txt1 1 zz ))
(setq kk (atoi pp) )
(while t
(setq tqwz (car (nentsel "\n选择目标图号:")))
(setq kk (+ kk 1 ))
(setq txt3 (strcat txt2 (itoa kk)))
(setq tqwz (entget tqwz))
(setq tqwz (subst (cons 1 txt3) (assoc 1 tqwz) tqwz) )
(entmod tqwz)
)
(princ)
)

发表于 2012-7-5 16:15:09 | 显示全部楼层
如果想减1,如何改。改那里。求教
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-7-22 01:24 , Processed in 0.182794 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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