明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1746|回复: 2

这段程序如何改为后期邦定

[复制链接]
发表于 2011-12-21 08:58:16 | 显示全部楼层 |阅读模式
Public Sub TXPJ()
On Error GoTo e1
Set acadApp = GetObject(, "AutoCAD.Application")
Set ThisDrawing = acadApp.ActiveDocument
Dim objDBX As Object
Dim fileName As String
Dim ent() As Object
Dim lngCount As Long, i As Long
Dim GetInterfaceObject As Object
Do
Set objDBX = GetInterfaceObject("ObjectDBX.AxDbDocument.tt")
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 Object
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 Object
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 Object
     Set l = ThisDrawing.Layers(t)
     ThisDrawing.ActiveLayer = ThisDrawing.Layers("0")
     Dim e As Object
     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
e1:
Exit Sub
End Sub
这段图形拼接程序如何改为后期邦定?请高手帮忙修改一下!!!
 楼主| 发表于 2011-12-21 09:13:43 | 显示全部楼层
Set objDBX = GetInterfaceObject("ObjectDBX.AxDbDocument.18")
发表于 2011-12-21 09:24:37 | 显示全部楼层
楼上的是不是发错地方了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-23 04:21 , Processed in 0.167553 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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