明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1685|回复: 6

有关块属性的读取

[复制链接]
发表于 2004-10-14 17:03:00 | 显示全部楼层 |阅读模式
再次麻烦版主了,lzh741206


知道块名:a;块属性标记:如图号的属性标记值为:th;


如何快速找到这个块,并把图号的属性标记值为th的文字内容读出来,我用vb6.0,引用object cad 2004库,请列出源代码,谢谢!
发表于 2004-10-15 00:10:00 | 显示全部楼层

回复

依据块名作选择集; 然后用下面方法得到属性: ' Get the attributes for the block reference
Dim varAttributes As Variant
varAttributes = blockRefObj.GetAttributes

Dim strAttributes As String
Dim I As Integer
For I = LBound(varAttributes) To UBound(varAttributes)
strAttributes = strAttributes & " Tag: " & varAttributes(I).TagString & _
" Value: " & varAttributes(I).textString & " "
Next
 楼主| 发表于 2004-10-15 09:05:00 | 显示全部楼层
依据块名作选择集,怎么做,谢谢
发表于 2004-10-15 09:08:00 | 显示全部楼层
(entget(car(entsel)))


命令行键入,选择一个块看看结果
发表于 2004-10-15 09:22:00 | 显示全部楼层

回复

作选择集: Public Sub test()
' Create the selection set
Dim ssetObj As AcadSelectionSet
Set ssetObj = ThisDrawing.SelectionSets.Add("SSET") Dim mode As Integer mode = acSelectionSetAll
' Add all the Circles to the selection set that lie within the crossing of (28,17,0) and
' (-3.3, -3.6,0) by filtering from the current drawing
Dim gpCode(0 To 1) As Integer
Dim dataValue(0 To 1) As Variant
gpCode(0) = 0
dataValue(0) = "Insert"
gpCode(1) = 2
dataValue(1) = "a" '块名

Dim groupCode As Variant, dataCode As Variant
groupCode = gpCode
dataCode = dataValue

ssetObj.Select mode, , , groupCode, dataCode MsgBox ssetObj.Count
'然后你循环ssetObj中的每个块实体...
End Sub
发表于 2004-10-15 18:15:00 | 显示全部楼层
这样吧: Sub test()
Dim blks As AcadBlocks
Dim blk As AcadBlock

Set blks = ThisDrawing.Blocks

Set blk = blks.Item("a")

Dim i As Integer

For i = 0 To blk.Count - 1
Dim obj As AcadObject
Set obj = blk.Item(i)
Dim str As String
str = obj.ObjectName
If obj.ObjectName = "AcDbAttributeDefinition" Then
Dim attrObj As AcadAttribute
Set attrObj = obj
Dim tag, prompt, value As String
tag = attrObj.TagString
prompt = attrObj.PromptString
value = attrObj.TextString
MsgBox "Tag: " & tag & vbCr & "Value: " & value & vbCr & "Value: " & value & vbCr
End If
Next

End Sub 测试dwg:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2004-10-18 17:38:00 | 显示全部楼层
王咣生版主:
我能看到你的dwgtext的内容,但运行程序就是看不到我的图框里的内容,百思不得其解,麻烦你看看是怎么回事,比如我想看块tbz00的drawno标记的属性文字,总为空,读drawno这个tagstring倒是可以读到。
dwg图已发到你的邮箱里了,谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-28 00:51 , Processed in 0.163595 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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