用VB做AutoCAD二次开发,程序运行时出现实时错误424,要求对象!但是这个不涉及对控件问题呀,请问怎么回事
DimobjCylinderAsAcad3DSolidDimptCen(0To2)AsDoubleptCen(0)=0:ptCen(1)=0:ptCen(2)=0Seto...
Dim objCylinder As Acad3DSolid
Dim ptCen(0 To 2) As Double
ptCen(0) = 0: ptCen(1) = 0: ptCen(2) = 0
Set objCylinder = Acaddoc.ModelSpace.AddCylinder(ptCen, 40, 300)
报错的是这一行“Set objCylinder = Acaddoc.ModelSpace.AddCylinder(ptCen, 40, 300)” 展开
Dim ptCen(0 To 2) As Double
ptCen(0) = 0: ptCen(1) = 0: ptCen(2) = 0
Set objCylinder = Acaddoc.ModelSpace.AddCylinder(ptCen, 40, 300)
报错的是这一行“Set objCylinder = Acaddoc.ModelSpace.AddCylinder(ptCen, 40, 300)” 展开
展开全部
可能是 Acaddoc 没定义吧
Public Acaddoc As AcadApplication
Public ThisDrawing As AcadDocument
Public Acaddoc As AcadApplication
Public ThisDrawing As AcadDocument
更多追问追答
追问
定义了也不行。感觉问题是出在ptCen,因为运行时鼠标指这(ptCen,40,300)时ptCen没有赋值。还是这句报错,现在是“实时错误91”,对象变量或with块变量未设置。
追答
Public Acaddoc As AcadApplication
Public ThisDrawing As AcadDocument
Private Sub Command1_Click()
Me.Hide
Dim objCylinder As Acad3DSolid
Dim ptCen(0 To 2) As Double
ptCen(0) = 0: ptCen(1) = 0: ptCen(2) = 0
Set objCylinder = ThisDrawing.ModelSpace.AddCylinder(ptCen, 40, 300)
End Sub
Private Sub Form_Load()
RunAutoCAD
End Sub
Public Sub RunAutoCAD() '连接AutoCAD
On Error Resume Next
Set Acaddoc = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set Acaddoc = GetObject(, "AutoCAD.Application")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
Set Acaddoc = GetObject(, "AutoCAD.Application")
Set ThisDrawing = Acaddoc .ActiveDocument
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询