明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1465|回复: 0

请各位大侠帮忙指点一下,调取.dwg文件没响应???

[复制链接]
发表于 2012-5-10 02:19:28 | 显示全部楼层 |阅读模式
各位大侠请帮忙指点一下,菜鸟新学用VB进行二次开发,照着张晋西的《VB与AutoCAD二次开发》做了一下,运行的时候为什么没响应?
Private Sub Form_Load()
Me.Label1 = "缩放"
Me.Label2 = "X轴"
Me.Label3 = "Y轴"
Me.Label4 = "Z轴"
Me.Label5 = "旋转"
Me.Label6 = "三合一(主孔)"
Me.Label7 = "三合一(预埋孔)"
Me.Label8 = "层板托(主孔)"
Me.Label9 = "层板托(副孔)"
Me.Caption = "连接类"
'VB窗体显示各种安装孔图形
Me.Picture1(0).Picture = LoadPicture(App.Path + "\五金孔位\连接类\" & "三合一(主孔).wmf")
Me.Picture1(1).Picture = LoadPicture(App.Path + "\五金孔位\连接类\" & "三合一(预埋孔).wmf")
Me.Picture1(2).Picture = LoadPicture(App.Path + "\五金孔位\连接类\" & "层板托(主孔).wmf")
Me.Picture1(3).Picture = LoadPicture(App.Path + "\五金孔位\连接类\" & "层板托(副孔).wmf")
Dim I
For I = 0 To 2
Me.Text1(I).Text = 1
Next I
Me.Text1(3).Text = 0
'连接AutoCAD
'将变量"家具五金CAD"设置为AutoCAD应用程序对象
'"家具五金CAD"已在Modue1中定义为全局变量
'注意下面错误陷阱的设立
On Error Resume Next
Set 家具五金CAD = GetObject(, "AutoCAD.Application")
If Err Then
    Err.Clear
    Set 家具五金CAD = CreateObject("AutoCAD.Application")
    If Err Then
        MsgBox ("请先安装AutoCAD2000")
        Unload Me
        Exit Sub
    End If
End If
家具五金CAD.WindowState = acMax 'AutoCAD窗体极大显示
End Sub
Private Sub Picture1_Click(Index As Integer)
On Error Resume Next
Dim blockRefObj As AcadBlockReference
Dim returnPnt As Variant
Dim insertionPnt(0 To 2) As Double
Dim FileString As String
AppActivate 家具五金CAD.Caption
'切换到AutoCAD窗体
'鼠标在AutoCAD窗体上点取输入插入点
returnPnt = 家具五金CAD.ActiveDocument.Utility.GetPoint(, vbCrLf + "插入点:")
Select Case Index
    Case 0
    FileString = "\五金孔位\连接类\三合一(主孔).dwg"
    Case 1
    FileString = "\五金孔位\连接类\三合一(预埋孔).dwg"
    Case 2
    FileString = "\五金孔位\连接类\层板托(主孔).dwg"
    Case 3
    FileString = "\五金孔位\连接类\层板托(副孔).dwg"
End Select
'插入图块
Set blockRefObj = 家具五金CAD.ActiveDocument.ModelSpace.InsertBlock_(returnPnt, App.Path & FileString, CDbl(Me.Text1(0).Text), CDbl(Me.Text1(1).Text), CDbl(Me.Text1(2).Text), CDbl(Me.Text1(3).Text) * 3.14 / 180)
AppActivate Form1.Caption
'切换到VB窗体
End Sub

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

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 13:26 , Processed in 0.508651 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表