对所选之数字进行加减乘除
- ;This procedure chang many mumber;
- (DEFUN C:cct()
- (setq oldcmd(getvar "CMDECHO"))
- (SETVAR "CMDECHO" 0)
- (setq ysh (getstring "\n选择运算符号(1减,2乘,3除)<加>:"))
- (if (= ysh "1") (prompt"\n嗨,朋友,你选择了减号(-)")
- (if (= ysh "2") (prompt"\n嗨,朋友,你选择了乘号(*)")
- (if (= ysh "3") (prompt"\n嗨,朋友,你选择了除号(/)")
- (prompt"\n嗨,朋友,你选择了加号(+)")
- )
- )
- )
- (initget (+ 1 4))
- (setq JD (getint "\n请输入精度:"))
- (initget (+ 1 2))
- (setq ysyz (getdist "-----接下去-----请输入运算因子:"))
- (prompt"\n选择需修改的文字:")
- (setq object-s(ssget '((-4 . "<oR")
- (0 . "text")
- (0 . "MTEXT")
- (-4 . "OR>")))
- ent-num(sslength object-s)
- cx 0)
- (while(< cx ent-num)
- (setq objectx(ssname object-s cx)
- ed(entget objectx)
- et(assoc 1 ed)
- ete(cdr et))
- (if (= (substr ete 1 3) "%%p") (setq ete (substr ete 4)))
- (setq len (strlen ete)
- ccx 1
- asc1 0)
- (while (<= ccx len)
- (setq a (ascii (substr ete ccx)))
- (if (or (< a 42) (> a 57))
- (setq asc1 1)) ;if
- (setq ccx (+ ccx 1)));while内
- (if (= asc1 0 )
- (progn (setq ett (atof ete))
- (if (and(/= ysh "1")(/= ysh "2")(/= ysh "3"))
- (setq ett (+ ett ysyz)))
- (if (= ysh "1")
- (setq ett (- ett ysyz)))
- (if (= ysh "2")
- (setq ett (* ett ysyz)))
- (if (= ysh "3")
- (setq ett (/ ett ysyz)))
- (setq ete (rtos ett 2 JD);此处决定答案的小数点位数
- et (cons 1 ete )
- ed (subst et (assoc 1 ed) ed))
- (entmod ed)));if
- (setq cx(+ cx 1)));while外
- (setvar"cmdecho"oldcmd)
- (Princ cx)
- (prompt " objects are changed")
- (princ)
- );DEFUN\The procedure chang text\;
- ;-----------------------------------------------
- (prompt "You are successful load cct.lsp")
- (prompt "\n")
|