用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)”
展开
 我来答
pmqbwd
2012-05-14 · 超过20用户采纳过TA的回答
知道答主
回答量:97
采纳率:50%
帮助的人:28.6万
展开全部
可能是 Acaddoc 没定义吧
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
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式