有多种方法可以实现这一点,例如使用GetField函数,但只是为了好玩:
以下是预定义位置的示例宏:
**注意-在宏中使用单正斜杠“/”作为双反斜杠“\\”将导致暂停用户输入。
- ^C^C^P(_OpenHere "T:/Checker");._open;^P
。。。以及支持的“_OpenHere”LISP子函数:
此子函数接受单个参数,将文件路径作为字符串,并在更新定义打开对话框起点的名称恰当的“InitialDirectory”注册表项之前验证文件路径是否为有效位置。该代码还解释了产品密钥的2013年之前和之后的LISP函数。
- (vl-load-com)
- (defun _OpenHere (filePath / key)
- (if vlax-user-product-key ; If using 2013
- (setq key (vlax-user-product-key)) ; Then, use new lisp function
- (setq key (vlax-product-key)) ; Else, use legacy function
- )
- ;; More info here:
- ;; http://www.cadtutor.net/forum/showthread.php?70845-AutoLISP-API-Changes-for-AutoCAD-2013-Updated
- (if (setq
- filePath (vl-string-translate
- "\"
- "/"
- (findfile (vl-string-right-trim
- "/"
- (vl-string-right-trim "\" filePath)
- )
- )
- )
- )
- (vl-registry-write
- (strcat
- "HKEY_CURRENT_USER\"
- key
- "\\Profiles\"
- (vla-get-activeprofile
- (vla-get-profiles
- (vla-get-preferences (vlax-get-acad-object))
- )
- )
- "\\Dialogs\\OpenSaveAnavDialogs"
- )
- "InitialDirectory"
- filePath
- )
- )
- (princ)
- )
HTH |