明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2136|回复: 6

如何用vb快速查找到dwg里的已知名称的块blockreference

[复制链接]
发表于 2004-12-8 18:52:00 | 显示全部楼层 |阅读模式
如何用vb快速查找到(或提取)dwg里的已知名称的块blockreference
发表于 2004-12-8 18:59:00 | 显示全部楼层
同一个主题不要分开发! 下面是一段测试 Private Sub Form_Load()
On Error Resume Next
Dim oApp As Object
Dim oDoc As Object
Set oApp = GetObject(, "AutoCad.Application")
Set oDoc = oApp.ActiveDocument
Dim ss As Object
oDoc.SelectionSets("Test").Delete
Set ss = oDoc.SelectionSets.Add("Test")
Dim ft(1) As Integer, fd(1)
ft(0) = 0: fd(0) = "Insert"
ft(1) = 2: fd(1) = "1"
ss.Select 5, ft, fd
MsgBox ss.Count
End Sub
 楼主| 发表于 2004-12-8 19:40:00 | 显示全部楼层
已知块名为fa或fb或fc,如何选择
发表于 2004-12-8 19:47:00 | 显示全部楼层
ft(0) = 0: fd(0) = "Insert"
ft(1) = 2: fd(1) = "fa,fb,fc"
 楼主| 发表于 2004-12-8 20:07:00 | 显示全部楼层
Dim acadapp As AcadApplication
Dim acaddoc As AcadDocument
'初始化CAD
'On Error Resume Next
Set acadapp = GetObject(, "autocad.application.16")
If Err Then
Err.Clear
Set acadapp = CreateObject("autocad.application.16")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
Dim filepath As String
filepath = "D:\Syq901\c0101-02.dwg"
acadapp.Documents.Open (filepath)
Set acaddoc = acadapp.ActiveDocument
acadapp.Visible = False

Dim ss As AcadSelectionSet
MsgBox (acaddoc.SelectionSets.Count)
'acaddoc.SelectionSets("test").Delete ---此处报错??????
Set ss = acaddoc.SelectionSets.Add("Test")
Dim ft(1) As Integer, fd(1)
ft(0) = 0: fd(0) = "insert"
'ft(1) = 2: fd(1) = "fa,fb,fc"
ss.Select acSelectionSetAll, ft, fd
MsgBox ss.Count 结果还是ss.Count还是3000多,和没定义时一样多,选择了所有的,怎么回事?
发表于 2004-12-9 08:46:00 | 显示全部楼层
如果可以的话,贴一个样图上来看看
 楼主| 发表于 2004-12-9 08:49:00 | 显示全部楼层
换了一个文件,换了块名就可以了,这是为什么?我是cad2004查属性得到的块名。还是感谢班组的辛劳,十分感谢!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-27 22:24 , Processed in 0.165022 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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