qq284417238 发表于 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))
)
)




ZZXXQQ 发表于 2015-7-17 10:23:55

(defun c:nnnn ( / sset ct ed temp value)
(princ "\nDecrease the value of selected text, Version 1.0, (c) 1999 by Z.L.Wang")
(prompt "\nSelect text to change: ")
(if (and (setq sset (ssget '((0 . "TEXT"))))
         (setq value (getreal "请输入增量: "))) (progn
(setq ct 0)
(repeat (sslength sset)
    (setq ed (entget (ssname sset ct)))
    (setq temp (atof (cdr (assoc 1 ed))))
    (setq temp (strcat (rtos (+ temp value) 2 3) "m"))
    (entmod (subst (cons 1 temp) (assoc 1 ed) ed))
    (setq ct (1+ ct))
)
)
(princ "\nNothing selected.")
)
)

qq284417238 发表于 2015-7-17 10:29:01

ZZXXQQ 发表于 2015-7-17 10:23 static/image/common/back.gif


谢谢帮忙,已经完美解决我的问题了。非常感谢
页: [1]
查看完整版本: 如何在增量的同时,为生成的结果都加上一个单位呢