CAD中用LISP程序调用VBA的问题
我试图用LISP程序通过快捷键在CAD中调用VBA程序LISP程序为:
(defun c: Draw2Line()
(setvar "cmdecho" 0)
(command "-vbarun" "DrawLine.dvb!Draw2Line")
(setvar "cmdecho" 1)
(princ)
)
其中快捷键为Draw2Line
VBA程序为:
Sub Draw2Line()
Dim FromPnt As Variant
Dim MidPnt As Variant
Dim ToPnt As Variant
Dim line1 As AcadLine
Dim line2 As AcadLine
ThisDrawing.Utility.Prompt vbCr & "绘制两段线段程序" & vbCrLf
FromPnt = ThisDrawing.Utility.GetPoint(, vbCr & "指定起点:")
MidPnt = ThisDrawing.Utility.GetPoint(FromPnt, vbCr & "指定下一点:")
Set line1 = ThisDrawing.ModelSpace.AddLine(FromPnt, MidPnt)
line1.color = acRed
ToPnt = ThisDrawing.Utility.GetPoint(MidPnt, vbCr & "指定终点:")
Set line2 = ThisDrawing.ModelSpace.AddLine(MidPnt, ToPnt)
line2.color = acYellow
End Sub
可问题是当我加载以上LISP程序时,命令行就报错,说是语法错误,我不知道是哪里错了 哪位大侠能指点迷津???我不胜感激!!!!!
另外我还用另外的两个LISP程序也不行,望指出错误,谢谢!!
LISP2:
(vl-load-com)
(vl-vbaload(findfile "DrawLine.dvb"))
(defun c: Draw2Line()
(vl-vbarun "Draw2Line")
(princ)
)
LISP3:
(vl-load-com)
(defun AutoVBALoad(cmdname project macro)
(eval
(list 'defun
(read(strcat "C: " cmdname))
nil
(list'vl-vbarun
(stract project "!"
(if macro macro cmdname)
)
)
(princ)
)
)
)
(AutoVBALoad "Draw2Line" "DrawLine.dvb" "Draw2Line")
本帖最后由 sscylh 于 2012-9-26 13:53 编辑
试一下在 (command "-vbarun" "DrawLine.dvb!模块1.Draw2Line"),在文件名里面输入他的绝对地址? 喜欢中....哈哈哈?~!
http://img170.poco.cn/mypoco/myphoto/20120402/17/6459922420120402172400093.gif
按LISP语法,"defun c:"后面不能有空格 sscylh 发表于 2012-9-25 23:55 static/image/common/back.gif
试一下在 (command "-vbarun" "DrawLine.dvb!模块1.Draw2Line"),在文件名里面输入他的绝对地址?
不是的,这个程序是在THISDRAWING里面的,是绝对地址了。 DrawLine.dvb在哪里?加上路径。 woaishuijia 发表于 2012-9-27 21:45 static/image/common/back.gif
按LISP语法,"defun c:"后面不能有空格
你说的对,去掉空格之后就行了,那后面的两个调用程序的问题在哪里,你知道吗,告诉我呗,谢谢! 第一个问题都已经解决了,至于2和3问,有木有大侠能知道的,请赐教!!
页:
[1]