明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 799|回复: 2

[已解答] 如何在增量的同时,为生成的结果都加上一个单位呢

[复制链接]
发表于 2015-7-17 10:05:14 | 显示全部楼层 |阅读模式
诚求帮助,谢谢
下面的源码的用途是:为选中内容批量增加一量值(但修改之后的数值都是没有单位的)
如何修改这个程序,使得生成的每个结果能包含后缀m
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;本程序将指定数字增加一量值
(defun c:nnnn( / sset ct num ed ent temp temp1 value)
(princ "\nDecrease the value of selected text, Version 1.0, (c) 1999 by Z.L.Wang")
(prompt "\nSelect text to change: ")
(setq sset (ssget '((0 . "TEXT"))))
(if (null sset)
(progn
(princ "\nNothing selected.")
(exit)
)
)
(setq value (getreal "请输入增量: "))
(setq ct 0)
(setq num (sslength sset))
(repeat num
(setq ent (ssname sset ct))
(setq ed(entget ent))
(setq temp (assoc 1 ed))
(setq temp1 (atof (cdr temp)))
(setq temp1 (+ temp1 value))
(setq temp (rtos temp1 2 3))
(setq ed (subst (cons 1 temp) (assoc 1 ed) ed))
(entmod ed)
(setq ct (+ 1 ct))
)
)




发表于 2015-7-17 10:23:55 | 显示全部楼层
  1. (defun c:nnnn ( / sset ct ed temp value)
  2. (princ "\nDecrease the value of selected text, Version 1.0, (c) 1999 by Z.L.Wang")
  3. (prompt "\nSelect text to change: ")
  4. (if (and (setq sset (ssget '((0 . "TEXT"))))
  5.          (setq value (getreal "请输入增量: "))) (progn
  6.   (setq ct 0)
  7.   (repeat (sslength sset)
  8.     (setq ed (entget (ssname sset ct)))
  9.     (setq temp (atof (cdr (assoc 1 ed))))
  10.     (setq temp (strcat (rtos (+ temp value) 2 3) "m"))
  11.     (entmod (subst (cons 1 temp) (assoc 1 ed) ed))
  12.     (setq ct (1+ ct))
  13.   )
  14. )
  15.   (princ "\nNothing selected.")
  16. )
  17. )

评分

参与人数 1明经币 +1 收起 理由
qq284417238 + 1 很给力!

查看全部评分

 楼主| 发表于 2015-7-17 10:29:01 | 显示全部楼层
ZZXXQQ 发表于 2015-7-17 10:23

谢谢帮忙,已经完美解决我的问题了。非常感谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-21 15:21 , Processed in 0.160063 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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