- 积分
- 106
- 明经币
- 个
- 注册时间
- 2012-9-25
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
我试图用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")
|
|