马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
感谢CY956
LISP:四则.lsp
 - <normalfont>
- (defun C:四则 ()
- (PRINT "请选择您要操作的数字")
- (SETQ S (SSGET))
- (setq id (load_dialog "四则.dcl"))
- (if (< id 0)
- (exit)
- )
- (if (not (new_dialog "daxigua" id))
- (exit)
- )
- (setq yuyu 0.)
- (setq tyty 0)
- (setq tyty0 3) ;先赋一个初值给——按钮;
- (action_tile "jia" "(setq tyty 0)")
- (action_tile "jian" "(setq tyty 1)")
- (action_tile "cheng" "(setq tyty 2)")
- (action_tile "chu" "(setq tyty 3)")
- (action_tile "x0" "(setq tyty0 0)")
- (action_tile "x1" "(setq tyty0 1)")
- (action_tile "x2" "(setq tyty0 2)")
- (action_tile "x3" "(setq tyty0 3)")
- (action_tile "x4" "(setq tyty0 4)")
- (action_tile "shuzhi" "(setq yuyu(atof $value))")
- (action_tile "accept" "(done_dialog 1)")
- (action_tile "cancel" "(done_dialog -1)")
- (setq sdt (start_dialog))
- (unload_dialog id)
- (if (> sdt 0)
- (progn
- (setq n (sslength s))
- (setq kk 0)
- (while (< kk n)
- (setq name (ssname s kk))
- (setq a (entget name))
- (setq b (assoc '0 a))
- (setq c (cdr b))
- (if (= c "TEXT")
- (progn
- (setq v0 (atof (cdr (assoc '1 a))))
- (setq olddimzin (getvar "dimzin"))
- (setvar "dimzin" 0)
- (cond ((= 0 tyty) (setq v1 (+ v0 yuyu)))
- ((= 1 tyty) (setq v1 (- v0 yuyu)))
- ((= 2 tyty) (setq v1 (* v0 yuyu)))
- ((= 3 tyty) (setq v1 (/ v0 yuyu)))
- )
- (setq v (rtos v1 2 tyty0)) ;转换数字----字符,取多少位小数点。。
- (setq a (subst (cons 1 v) (assoc '1 a) a))
- (entmod a)
- ;;实体更新.如果不加这一行只是屏幕更新
- (entupd name)
- (setvar "dimzin" olddimzin)
- ;;屏幕更新
- )
- )
- (setq kk (1+ kk))
- )
- )
- )
- (princ)
- (princ)
- )
- dcl:四则.dcl
- daxigua:dialog{
- label="运行四则运算";//对话框标签
- initial_focus="jia";//初始的焦点.
- :radio_row{label="选择";
- :radio_button{label="+";key="jia";value=1;}
- :radio_button{label="-";key="jian";}
- :radio_button{label="*";key="cheng";}
- :radio_button{label="/";key="chu";}
- }
- :edit_box{label="数值";
- key="shuzhi";
- }
- :radio_row{label="结果保留几位小数,默认取3位";
- :radio_button{label="0";key="x0";}
- :radio_button{label="1";key="x1";}
- :radio_button{label="2";key="x2";}
- :radio_button{label="3";key="x3";value=1;}
- :radio_button{label="4";key="x4";}
- }
- ok_cancel;
- }
- </normalfont>
|