VB也不能脱离AutoCad,下面是VB打开并获取AutoCad的Application对象的常用手段
Set AcadApp = GetObject(, "AutoCAD.Application") If Err Then Set AcadApp = CreateObject("AutoCAD.Application") AcadApp.Visible = True
不过学习这东西最好还是看帮助,有VB的底子学VBA不难
我知道在VB的环境下自动打开一个CAD,可是我在VB的环境下,对一个COMMAND1按钮的程序代码写下:
Private Sub Command1_Click() Dim acdApp As New AcadApplication acdApp.Visible = True
Dim startPoint(0 To 2) As Double, endPoint(0 To 2) As Double Dim LineObj As AcadLine startPoint(0) = 0: startPoint(1) = 0: startPoint(2) = 0 endPoint(0) = 30: endPoint(1) = 20: endPoint(2) = 0 Set LineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
End Sub
结果自动生成一个CAD窗口,并报错,大意是Set LineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)是没定义的?????
请问怎没拉???怎样自动打开CAD并画一条线啊!!!!??????