本帖最后由 fangmin723 于 2018-10-18 09:06 编辑
CAD-lisp之多选项命令嵌套和设置储存
;程序效果:
;有三个命令ML1、ML2、ML3,
;只通过一个命令ML来《选择性》调用这三个命令。
;输入ML命令后,会有一个设置S可随时选择ML是执行的那个命令,
;并具有记忆不用每次输入ML都要设置
(setq input (getint (strcat "\n请选择执行命令[ML1(1)/ML2(2)/ML3(3)]默认:<" (rtos configuration) ">" )))
- (defun c:ml(/ c:ml1 c:ml2 c:ml3 configuration file input path str)
- (defun c:ml1()
- (print "c:ml1")
- )
- (defun c:ml2()
- (print "c:ml2")
- )
- (defun c:ml3()
- (print "c:ml3")
- )
- (setvar "CMDECHO" 0)
- (setq path (strcat (vlax-get-property (vlax-get-acad-object) 'path) "\\Support\\configuration.ini"))
- (if (findfile path)
- (progn
- (if (/= (setq str (vl-string-trim " " (read-line (setq file (open path "r"))))) "")
- (progn
- (setq configuration (atoi str))
- (close file)
- )
- )
- )
- (setq configuration 1)
- )
- (if (setq input (getint (strcat "\n请选择执行命令[ML1(1)/ML2(2)/ML3(3)]默认:<" (rtos configuration) ">" )))
- (progn
- (setq configuration input file (open path "w"))
- (write-line (rtos configuration) file)
- (close file)
- )
- )
- (cond
- ((= configuration 1) (c:ML1))
- ((= configuration 2) (c:ML2))
- ((= configuration 3) (c:ML3))
- (T (princ "\n无效关键字!"))
- )
- (prin1)
- )
|