以下我开发的一段程序, 1)当捕捉值丢失后,手动执行BZ命令,即可恢复。 2)在没有把直记录到注册表前,会提示先保存下来,以后丢失就使用bz命令。 3)在其他程序执行之前,如果你不知道当前的值是多少,可以用(snapvalue “get”)获得您 设定的值 ;save the obsnap mode (DEFUN C:BZ (/ oce opselect) (SETQ oce (GETVAR "cmdecho")) (SETVAR "cmdecho" 0) (SETQ opselect (GETSTRING "\n输入选项 [保存捕捉设定(S) |使用保存的捕捉设定(U)]:<U>")) (PRINC " Osmode=") (IF (OR (= opselect "S") (= opselect "s")) (PROGN (PRINC (snapvalue "save"))) (PROGN (PRINC (snapvalue "get"))) ;ACAD-301:409 ) (SETVAR "cmdecho" oce) (PRINC) ) (DEFUN snapvalue (get_save / osm hkey cver cProfiles) (SETQ hkey "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD") (SETQ cver (VL-REGISTRY-READ hkey "CurVer")) ;R16.1 (SETQ hkey (STRCAT hkey "\\" cver)) ;HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\R16.1 (SETQ cver (VL-REGISTRY-READ hkey "CurVer")) ;ACAD-301:409 (SETQ hkey (STRCAT hkey "\\" cver "\\Profiles")) ;HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\R16.1\\ACAD-301:409\\Profiles (SETQ cProfiles (VL-REGISTRY-READ hkey "")) ;2014 (SETQ hkey (STRCAT hkey "\\" cProfiles "\\General")) ;HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\R16.1\\ACAD-301:409\\Profiles\\2014 (COND ((= (STRCASE get_save) "GET") (SETQ osm (VL-REGISTRY-READ hkey "Osmode1")) (IF (AND (/= osm nil) (/= osm 0)) (PROGN (VL-REGISTRY-WRITE hkey "Osmode" osm) (SETVAR "osmode" osm)) (PROGN (SETQ promptstr "\n尚未保存捕捉设定!保存当前捕捉模式?(Y/N) :<") (ALERT "Please setup the objsnap value first and save it!") (INITDIA) (COMMAND "'_+dsettings" "2" "") (SETQ sosmd (STRCASE (getuserinput sosmd promptstr "Y" "Getstring")));自定义函数,(getsuerinput old promptstring default getmodeStr) (IF (= sosmd "Y") (PROGN (SETQ osm (GETVAR "osmode")) (VL-REGISTRY-WRITE hkey "Osmode1" osm))) (PRINC)))) ((= (STRCASE get_save) "SAVE") (SETQ osm (GETVAR "osmode")) (VL-REGISTRY-WRITE hkey "Osmode1" osm)))) |