乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 49|回复: 1

为什么不能获取属性值?

[复制链接]

12

主题

24

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
72
发表于 2015-7-9 08:55:00 | 显示全部楼层 |阅读模式
我用.net的方法读取块里的属性
Private Function DbxGetBlocksData(btr As BlockTableRecord, doc As Document) As Dictionary(Of String, String)
        Dim dic As New Dictionary(Of String, String)
        Dim db As Database = doc.Database
        Using trans As Transaction = db.TransactionManager.StartTransaction
            For Each obj_id As ObjectId In btr
                Dim ent As Entity = trans.GetObject(obj_id, OpenMode.ForRead)
                If ent.GetType.Name = "AttributeDefinition" Then
                    Dim adf As AttributeDefinition = ent
                    dic.Add(adf.Tag, adf.TextString)
                    daf.Tag可以获取属性名称,但是daf.TextString的值始终是"",请问一下是为什么?
                End If
            Next
        End Using
        Return dic
    End Function
回复

使用道具 举报

12

主题

24

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
72
发表于 2015-7-9 10:58:00 | 显示全部楼层
搞定了,贴上来,免得以后忘了。
    Dim brf_ids As ObjectIdCollection = btr.GetBlockReferenceIds(True, False)
                Dim br As BlockReference
                For Each brf_id As ObjectId In brf_ids
                    Dim obj As Object = brf_id.GetObject(OpenMode.ForRead)
                    If obj.GetType.Name = "BlockReference" Then
                        br = obj
                        If br.Name.StartsWith("股份公司-") Then
                            For Each att_id As ObjectId In br.AttributeCollection
                                Dim att As AttributeReference = att_id.GetObject(OpenMode.ForRead)
                                If att.Tag.StartsWith("名称{") Then
                                    dObj.PaperName = att.TextString
                                End If
                                If att.Tag.StartsWith("图号{") Then
                                    dObj.PaperCode = att.TextString
                                End If
                            Next
                            Exit For
                        End If                    End If
                Next
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 12:40 , Processed in 0.642876 second(s), 56 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表