developing 发表于 2012-5-10 02:19:28

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

各位大侠请帮忙指点一下,菜鸟新学用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

页: [1]
查看完整版本: 请各位大侠帮忙指点一下,调取.dwg文件没响应???