乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 67|回复: 1

在visualbasic中对autocad进行二次开发碰到的问题!(急)

[复制链接]

6

主题

13

帖子

1

银币

初来乍到

Rank: 1

铜币
37
发表于 2003-4-27 14:36:00 | 显示全部楼层 |阅读模式
在visualbasic中编程,碰到了一个问题:运行到类似Set boxobj = acadApp.ActiveDocument.ModelSpace.AddBox(boxcenter, boxlength, boxwidth, boxheight)的语句,就会出现:
       实时错误‘424’
       要求对象
       结束(E)      调试(D)         帮助(H)
因为没有安装msdn,所以就不知道问题出在哪里了 !请好心的您解决我这个问题吧!!
不甚感激!!!

具体程序如下:
Private Sub Form_Load()
    On Error Resume Next
   
    '与通信
    Dim acadApp As AcadApplication
    Set acadApp = GetObject _
                  (, "AutoCAD.Application")
    If Err Then
        Err.Clear
        Set acadApp = CreateObject _
                  ("AutoCAD.Application")
        If Err Then
            MsgBox Err.Description
            Exit Sub
        End If
    End If
   
    '连接autocad,并使其画图
    Dim acadDoc As AcadDocument
    Set acadDoc = acadApp.ActiveDocument
   End Sub
Private Sub Command1_Click()
Dim boxobj As Acad3DSolid
Dim boxlength As Double, boxwidth As Double, boxheight As Double
Dim boxcenter(0 To 2) As Double
boxcenter(0) = 5#: boxcenter(1) = 5#: boxcenter(2) = 0
boxlength = 10#: boxwidth = 7: boxheight = 10#
Set boxobj = acadApp.ActiveDocument.ModelSpace.AddBox(boxcenter, boxlength, boxwidth, boxheight)
boxobj.Color = acBlue
Dim cylinderobj As Acad3DSolid
Dim cylindercenter(0 To 2) As Double
Dim cylinderradius As Double
Dim cylinderheight As Double
cylindercenter(0) = 0#: cylindercenter(1) = 0#: cylindercenter(2) = 0#
cylinderradius = 5#
cylinderheight = 20#
Set cylinderobj = acadApp.activedocement.ModelSpace.AddCylinder(cylindercenter, cylinderradius, cylinderheight)
cylinderobj.Color = acBlue
boxobj.Boolean acIntersection, cylinderobj
boxobj.Color = acRed
Dim newdirection(0 To 2) As Double
newdirection(0) = -1: newdirection(1) = -1: newdirection(2) = 1
acadApp.ActiveDocument.ActiveViewport.Direction = newdirection
acadApp.ActiveDocument.Preferences.ContourLinesPerSurface = 20
ZoomExtents
acadApp.ActiveDocument.Regen True
End Sub
回复

使用道具 举报

158

主题

2315

帖子

10

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2951
发表于 2003-4-27 18:41:00 | 显示全部楼层
Dim acadApp As AcadApplication

Dim acadDoc As AcadDocument
应该放到声明段,而不应该放到
Private Sub Form_Load()
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 13:46 , Processed in 0.574025 second(s), 56 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表