找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 489|回复: 1

[原创]:希望工具箱能增加数字批量处理的功能,我编了一个,老大不许笑我!

[复制链接]
发表于 2003-5-5 15:42:27 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
这是一个对选中数字进行四则运算的小LISP,希望工具箱能增加类示的一些功能!

  1. (defun c:ops (/ a b c x y nd ss index index1 sm el txt)
  2.   (alert "{y}=a*expt({x} b)+c")
  3.   (setq a (getreal "\na=?"))
  4.   (if (= nil a)
  5.     (setq a 1)
  6.   )
  7.   (setq b (getreal "\nb=?"))
  8.   (if (= nil b)
  9.     (setq b 1)
  10.   )
  11.   (setq c (getreal "\nc=?"))
  12.   (if (= nil c)
  13.     (setq c 0)
  14.   )
  15.   (setq nd (getint "\nnd=?"))
  16.   (if (= nil nd)
  17.     (setq nd 0)
  18.   )
  19.   (setq        ss (ssget)
  20.         index 0
  21.         index1 0
  22.         sm 0
  23.   )
  24.   (repeat (sslength ss)
  25.     (setq el        (entget (ssname ss index))
  26.           index        (1+ index)
  27.     )
  28.     (if        (= "TEXT" (cdr (assoc 0 el)))
  29.       (progn
  30.         (setq txt (cdr (assoc 1 el)))
  31.         (setq x (atof txt))
  32.         (setq y (+ (* a (expt x b)) c))
  33.         (setq txt (rtos y 2 nd))
  34.         (setq el (subst (cons 1 txt) (assoc 1 el) el))
  35.         (entmod el)
  36.       )                                        ;end pro
  37.     )                                        ;end if
  38.   )                                        ;end repeat
  39.   (princ)
  40. )
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2003-5-13 16:05:35 | 显示全部楼层
对所选之数字进行加减乘除

  1. ;This procedure chang many mumber;
  2. (DEFUN C:cct()
  3.   (setq oldcmd(getvar "CMDECHO"))
  4.   (SETVAR "CMDECHO" 0)
  5.   (setq ysh (getstring "\n选择运算符号(1减,2乘,3除)<加>:"))
  6.   (if (= ysh "1") (prompt"\n嗨,朋友,你选择了减号(-)")
  7.       (if (= ysh "2") (prompt"\n嗨,朋友,你选择了乘号(*)")
  8.           (if (= ysh "3") (prompt"\n嗨,朋友,你选择了除号(/)")
  9.               (prompt"\n嗨,朋友,你选择了加号(+)")
  10.            )
  11.       )
  12.    )
  13.   (initget (+ 1 4))
  14.   (setq JD (getint "\n请输入精度:"))        
  15.   (initget (+ 1 2))
  16.   (setq ysyz  (getdist "-----接下去-----请输入运算因子:"))
  17.   (prompt"\n选择需修改的文字:")
  18.   (setq object-s(ssget '((-4 . "<oR")
  19.                          (0 . "text")
  20.                          (0 . "MTEXT")
  21.                          (-4 . "OR>")))
  22.         ent-num(sslength object-s)
  23.         cx 0)
  24.   (while(< cx ent-num)
  25.     (setq objectx(ssname object-s cx)
  26.           ed(entget objectx)
  27.           et(assoc 1 ed)
  28.           ete(cdr et))
  29.     (if (= (substr ete 1 3) "%%p") (setq ete (substr ete 4)))
  30.     (setq len (strlen ete)
  31.           ccx 1
  32.           asc1 0)
  33.     (while (<= ccx len)
  34.           (setq a (ascii (substr ete ccx)))
  35.           (if  (or (< a 42) (> a 57))
  36.               (setq asc1 1)) ;if
  37.           (setq ccx (+ ccx 1)));while内
  38.     (if (= asc1 0 )
  39.         (progn (setq ett (atof ete))
  40.                (if (and(/= ysh "1")(/= ysh "2")(/= ysh "3"))
  41.                    (setq ett (+ ett ysyz)))
  42.                (if (= ysh "1")
  43.                    (setq ett (- ett ysyz)))
  44.                (if (= ysh "2")
  45.                    (setq ett (* ett ysyz)))
  46.                (if (= ysh "3")
  47.                    (setq ett (/ ett ysyz)))
  48.                (setq ete (rtos ett 2 JD);此处决定答案的小数点位数
  49.                      et (cons 1 ete )
  50.                      ed (subst et (assoc 1 ed) ed))
  51.                (entmod ed)));if
  52.     (setq cx(+ cx 1)));while外
  53.   (setvar"cmdecho"oldcmd)
  54.   (Princ cx)
  55.   (prompt "  objects are changed")
  56.   (princ)
  57.   );DEFUN\The procedure chang text\;
  58. ;-----------------------------------------------
  59. (prompt "You are successful load cct.lsp")
  60. (prompt "\n")
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-5-6 02:12 , Processed in 0.191696 second(s), 34 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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