Jamesfear,
该命令(由tp02在命令行调用)将识别当前正在运行的操作系统,获取用户的登录名,并根据操作系统版本构建路径,将其设置为系统变量*\u toolpalettepath。然后程序检查目录是否存在,如果存在,则设置变量,否则会告诉您它不存在。
- (defun c:tp02 (/)
- (vl-load-com)
- (setq windows
- (strcase
- (vl-registry-read
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
- "ProductName"
- )
- )
- )
- (setq loginname (getvar 'loginname))
- (cond
- ((wcmatch windows "*XP*")
- (progn
- (setq path (strcat "C:\\Documents and Settings\"
- loginname
- "\\Application Data\\Autodesk\\AutoCAD 2008\\R17.1\\enu\\Support\\ToolPalette"
- )
- )
- )
- )
- ((or (wcmatch windows "*VISTA*") (wcmatch windows "*7*"))
- (progn
- (setq path (strcat "C:\\Users\"
- loginname
- "\\AppData\\Roaming\\Autodesk\\AutoCAD 2008\\R17.1\\enu\\Support\\ToolPalette"
- )
- )
- )
- )
- (T (princ "\nThis version of the Operating System is not compatible with your path selections!")))
- (if (vl-file-directory-p path)
- (setvar '*_toolpalettepath (strcat path "02"))
- (princ "\nLocation of toolpalette directory does not exist:"))
- (princ))
否则,要了解“文件”选项卡的其余部分:
下面是一个解释:
- (vl-load-com) ;It is good practice to have this in your code when you are using vl, vla, vlr or vlax functions
- (setq Options_dialog (vla-get-preferences ;the vla function that grabs preferences (options) from
- (vlax-get-acad-object))) ;the Acad object (your open & active autocad session)
- (setq files (vla-get-files Options_dialog)) ;this will grab the "files tab" of the prefernces object
- (vlax-dump-object files T) ;by "dumping" the object you get all of the possible interactions
- ;you can use "(vla-get-********" much like getvar
- ;and you can use "vla-put-*******" much like setvar
- ;if you have no idea what setvar and getvar are you need to learn every system variable that Cad has to offer.
希望这能有所帮助,提示:在使用visual lisp时,只需将所有内容转储即可。
谨致问候,
马特 |