本帖最后由 kucha007 于 2023-3-12 20:50 编辑
选择或浏览文件夹,原帖在选择盘符时会带反斜杆,而选择文件夹则不会。
在原帖的基础上做了一点改动,统一先修剪掉斜杆再添加,不选文件夹时返回当前文件的路径
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=6239&highlight=%D1%A1%D4%F1%2B%CE%C4%BC%FE%BC%D0
- (defun K:BrowPath (/ msg WinShell shFolder err path)
- (vl-load-com)
- (setq msg "请选择文件夹路径(默认为当前文件路径):")
- (setq winshell (vlax-create-object "Shell.Application"))
- (setq shFolder (vlax-invoke-method WinShell 'BrowseForFolder 0 msg 1))
- (setq err (vl-catch-all-apply
- '(lambda ()
- (setq shFolder (vlax-get-property shFolder 'self))
- (setq path (vl-string-right-trim "\\"
- (vl-string-translate "/" "\\"
- (vlax-get-property shFolder 'path)
- )
- )
- )
- )
- )
- )
- (if (vl-catch-all-error-p err)
- (getvar "dwgprefix");选择取消时,返回当前文件路径
- (strcat path "\\");选择确定时,返回所选文件夹路径
- )
- )
|