明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4643|回复: 0

Set objDbx=CreateObject("ObjectDBX.AxDbDocument.18")在VB中运行出错

[复制链接]
发表于 2011-12-13 16:19:58 | 显示全部楼层 |阅读模式
ub Command1_Click()
Dim objDbx As AXDBLib.AxDbDocument
Dim fileName As String
Dim ent() As AcadEntity
Dim lngCount As Long, i As Long
Do
Set objDbx = CreateObject("ObjectDBX.AxDbDocument.18")
ThisDrawing.SendCommand "(setvar " & """users1""" & "(getfiled " & """Select a DWG File""" & """E:/工作/全图/142-KB/""" & """dwg""" & "8)) "
fileName = ThisDrawing.GetVariable("users1")
objDbx.Open fileName
lngCount = objDbx.ModelSpace.Count
ReDim ent(lngCount - 1) As AcadEntity
For i = 0 To lngCount - 1
Set ent(i) = objDbx.ModelSpace.Item(i)
Next i
objDbx.CopyObjects ent, ThisDrawing.ModelSpace
Set objDbx = Nothing
If MsgBox("是否继续?", vbYesNo, "Microsoft Excel") = vbNo Then
Dim s
Dim t As String
Dim lay0 As AcadLayer
t = "图例"
Do
s = MsgBox("是否删除" & t & "层吗?", vbOKCancel, "提示")
If s = vbOK Then
   findlay = 0
   For Each lay0 In ThisDrawing.Layers '在所有的图层中进行循环
   If lay0.Name = t Then '如果找到图层名
     findlay = 1
     Dim L As AcadLayer
     Set L = ThisDrawing.Layers(t)
     ThisDrawing.ActiveLayer = ThisDrawing.Layers("0")
     Dim E As AcadEntity
     For Each E In ThisDrawing.ModelSpace
     If E.Layer = t Then
       E.Delete
     End If
     Next
     'L.Delete '当图层中有参照时删不掉
     ThisDrawing.Regen acActiveViewport
     Exit For
   End If
   Next lay0
   If findlay = 0 Then '没有找到图层
   MsgBox "没有找到" & t & " 图层"
   End If
   If t = "图例" Then
      t = "内图廓线"
   Else
       Exit Sub
   End If
  Else
  If t = "图例" Then
      t = "内图廓线"
   Else
       Exit Sub
   End If
  End If
  Loop
  Exit Sub
End If
Loop
End Sub
[img]file:///D:/我的文档/Tencent%20Files/974135976/Image/D(H{B)4GYI1PWP][%H1C%OY.jpg[/img]
这段程序在VBA中运行正常,但在VB中运行就出现以上错误,不知哪位高手知道这是哪里的问题?
Set objDbx = CreateObject("ObjectDBX.AxDbDocument.18")在VB中运行时出错是什么原因?
也引用了
file:///D:/我的文档/Tencent%20Files/974135976/Image/DW6WX39Y_5447CE7VYC4)KJ.jpg
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-17 19:23 , Processed in 0.163960 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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