tjuzkj
发表于 2010-12-19 19:34:07
正急需中,谢谢啦!
qcw911
发表于 2010-12-20 08:58:46
nonsmall 发表于 2008-11-27 14:46 static/image/common/back.gif
(defun c:op()(setq dwg (getstring "文件名:"))(setq path "D:\\temp\\");你自己定义路径吧(if (and (/= " ...
老猫的方法一定很好
不过,怎么加上对话框,选择路径,就不用设定路径了
然后把路径注册到注册表里,
输入命令时候判断是否有路径,
有路径就不用弹出选择路径的对话框了
qcw911
发表于 2010-12-20 10:27:51
本帖最后由 qcw911 于 2010-12-20 11:09 编辑
想到了,
感谢老猫思路
特别感谢Gu_xl添加反斜杠方法
(defun c:tt()
(setq path (vl-registry-read "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\win_path" "win_path"))
(if(= nil path)
(progn
(setq path (AddBS(Get_Folder)))
(vl-registry-write "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\win_path")
(vl-registry-write "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\win_path" "win_path" path)
(setq path (vl-registry-read "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\win_path" "win_path"))
)
)
(setq dwg (getstring "請輸入文件名:"))
;;; (setq path "D:\\temp\\")
(if (and (/= "" dwg)(findfile (strcat path dwg ".dwg")))
(vla-open (vla-get-documents(vlax-get-acad-object)) (strcat path dwg ".dwg"))
(alert "沒有該文件")
)
)
(defun Get_Folder( / path_object shell)
(setq shell (Vlax-Get-Or-Create-Object "Shell.Application" ))
(if (setq path_object (vlax-invoke shell 'BrowseForFolder 0 "" 0 0))
(vlax-get (vlax-get path_object 'Self) 'Path)
)
)
;;;==================================================================
;;; (AddBS cPath) 按需添加反斜杠符到路径中。
;;;------------------------------------------------------------------
;;; 参数:
;;; cPath使用路径。
;;;------------------------------------------------------------------
;;; 返回:
;;; cPath 添加了反斜杠符的路径
;;; 示例:(setq a "C:\\MyFolder")
;;; (AddBS a) ;
;;; 返回 "C:\\MyFolder\\"
;;;==================================================================
(defun AddBS (cPath)
(if(not (= (substr cPath (strlen cPath)) "\\"))
(strcat cPath "\\")
cPath
) ;_ end of if
)
icefrog
发表于 2010-12-20 23:14:39
MARK~~~~~~~~~~~
461045462
发表于 2010-12-20 23:19:05
路过,学习了
谢谢楼上的分享
669423907
发表于 2011-6-26 21:23:56
回复 qcw911 的帖子
我想要以“Ctrl+o”的方式打开一个指定的文件夹,那要怎样的程序呢?
很希望得到大师的帮助!
mgame168
发表于 2011-6-27 04:21:41
路过,学习了
谢谢楼上的分享
先进者
发表于 2011-7-8 00:09:40
(DEFUN C:DK1 ()
(vlax-invoke
(vlax-create-object "Shell.Application")
'open
"c:\\Program Files\\Google";;文件或路径名
))
lidaxiu
发表于 2012-1-7 11:08:18
厉害,赞一个
hnzz0808
发表于 2015-12-18 09:59:33
学习学习学习!