[求助]如何自动添加所加载的LISP程序所在目录到搜索目录下!
<p><font face="Verdana">论坛找了很久也没找到。有一种可以,但是要LSP格式才行,如果是VLX格式就不行!</font></p> 请问楼主,LSP的怎么添加呢?? 有人知道的吗?? 顶起来,同求啊。。。。。。。。。。。。。。。 本帖最后由 yxp 于 2018-5-23 16:41 编辑测试了一下,lisp 加载的办法太多,还真没有统一的办法
1 lisp文件拖入绘图区加载
2 点击菜单工具加载
3 用第三方vbs代码加载
4 直接粘贴 lisp 代码到命令行加载
第一种可以读系统变量获取加载路径;
(getvar "lastprompt")
第一、第二种可以读 注册表获取路径;
(defun Auto_get_path( / ss)
(setq reg (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\"
(getvar "CPROFILE") "\\Dialogs\\Appload")
paths (getenv "ACAD"))
(if (= "0" (vl-registry-read reg "SaveHistory"))
(progn
(vl-registry-write reg "SaveHistory" "1")
(princ "\n加载路径获取失败,请重新加载")
(princ)
)
(setq sr (strcat reg "\\History")
n (atoi (vl-registry-read sr "NumHistory"))
ss (vl-registry-read sr (strcat (itoa n) "History"))
)
)
)
第三种可以用 vbs 获取路径
Dim STR , ARR
SET ARR = WScript.Arguments
For Each S1 In ARR
STR = STR & "" & S1
Next
Set objCAD = GetObject(, "AutoCAD.Application")
If Err Then '如果AutoCAD应用程序没有启动
Err.Clear
MsgBox " 未打开CAD程序:"
Else
Set ThisDrawing = objCAD.activedocument
Set ws = CreateObject("WScript.Shell")
ws.appactivate "AutoCAD" '此处改为窗口标题固定的前缀
Set WS = Nothing
STR = replace (STR , "\" ,"/")
ThisDrawing.SendCommand ("(load """ & STR & """)" & vbCr)
Set ARR = Nothing
Set STR = Nothing
Set ThisDrawing = Nothing
Set objCAD = Nothing
End If
第四种本身就没有路径,因为它不是一个文件。
(vl-load-com)
(defun set_path (/ str n1 n2)
(while (/= 0 (getvar "cmdactive")) (command))
(princ "\n")
(setq str (getvar "lastprompt"))
(if (wcmatch (strcase str) "*(LOAD \"*")
(setq n1 (vl-string-search "(LOAD \"" str)
n2 (vl-string-search "\")" str)
str (substr str (+ n1 8) (- n2 n1 7))
)
(setq str
(vl-registry-read "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\OpenSaveMRU\\*"
(substr (vl-registry-read "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\OpenSaveMRU\\*" "MRUList") 1 1)
)
)
)
(setenv "ACAD" (strcat (getenv "ACAD") ";" (vl-filename-directory str)))
)
(set_path)
(setq set_path nil)
页:
[1]