<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get block reference information error in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811861#M50441</link>
    <description>&lt;P&gt;&lt;SPAN style="font-size: 11px; line-height: 14px;"&gt;Are there any way to get value of AttributeDefinitions.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11px;"&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Mar 2013 06:47:02 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-03-22T06:47:02Z</dc:date>
    <item>
      <title>Get block reference information error</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3810922#M50433</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get a block reference (has attribute) from other drawing as code follow:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Sub GetBlock_Info()
        Dim blockName As String = "test"
        Try
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim doclock As DocumentLock = doc.LockDocument()
            Dim ed As Editor = doc.Editor

            Dim ofd As New OpenFileDialog("Select Drawing", Nothing, "dwg; dwt", "ATS detai drawing", Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.DoNotTransferRemoteFiles)
            Dim dr As System.Windows.Forms.DialogResult = ofd.ShowDialog()
            If dr &amp;lt;&amp;gt; System.Windows.Forms.DialogResult.OK Then
                Return
            End If
            Dim filePath As String = ofd.Filename
            'Using doclock
            Using OpenDb As New Database
                OpenDb.ReadDwgFile(filePath, System.IO.FileShare.ReadWrite, True, "")

                Using opentrans As Transaction = OpenDb.TransactionManager.StartTransaction()
                    Dim openBT As BlockTable = DirectCast(opentrans.GetObject(OpenDb.BlockTableId, OpenMode.ForRead), BlockTable)
                    If openBT.Has(blockName) Then

                        Dim openbtrec As BlockTableRecord = openBT(blockName).GetObject(OpenMode.ForRead)

                        Dim openbref As New BlockReference(New Point3d(0, 0, 0), openbtrec.ObjectId)

                        If openbtrec.HasAttributeDefinitions Then

                            Dim attCol As AttributeCollection = openbref.AttributeCollection
                     
                            For Each attId As ObjectId In attCol
                                Dim attRef As AttributeReference = DirectCast(opentrans.GetObject(attId, OpenMode.ForRead), AttributeReference)

                                MsgBox(attRef.TextString)
                                
                            Next
                        End If
                    End If
                    opentrans.Commit()
                    opentrans.Dispose()
                End Using
            End Using
       Catch ex As Autodesk.AutoCAD.Runtime.Exception
        End Try
    End Sub&lt;/PRE&gt;&lt;P&gt;Block "test" contains some attributes but the code can not get them.&lt;/P&gt;&lt;P&gt;Hope for help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 11:15:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3810922#M50433</guid>
      <dc:creator>ditran7577</dc:creator>
      <dc:date>2013-03-21T11:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Get block reference information error</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3810959#M50434</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1128366"&gt;@ditran7577&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;...Block "test" contains some attributes but the code can not get them...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is why you do not add attributes after inserting of block: &lt;A href="http://adndevblog.typepad.com/autocad/2012/06/inserting-a-block-with-attributes-to-modelspace.html" target="_self"&gt;Inserting a block with attributes to modelspace &lt;/A&gt;&lt;/P&gt;
&lt;P&gt;You have to iterate block definition to find all non-constant AttributeDefinitions and adding corresponding AttributeReferences to &lt;EM&gt;openbref.AttributeCollection&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 11:57:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3810959#M50434</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-03-21T11:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: Get block reference information error</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811027#M50435</link>
      <description>&lt;P&gt;I have just get information from attribute of that block. I do not want to add it into model space. How to?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 12:56:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811027#M50435</guid>
      <dc:creator>ditran7577</dc:creator>
      <dc:date>2013-03-21T12:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get block reference information error</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811059#M50436</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1128366"&gt;@ditran7577&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have just get information from attribute of that block. I do not want to add it into model space. How to?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think you do not understand me. Reread my post and my link again. &lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 13:26:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811059#M50436</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-03-21T13:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Get block reference information error</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811383#M50437</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Was i&lt;/SPAN&gt;t an impossibility?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 17:03:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811383#M50437</guid>
      <dc:creator>ditran7577</dc:creator>
      <dc:date>2013-03-21T17:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Get block reference information error</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811395#M50438</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1128366"&gt;@ditran7577&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Was i&lt;/SPAN&gt;t an impossibility?&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you create BlockReference with code and do not add AttributeReferences to BlockReference.AttributeCollection - then there are no AttributeReference within BlockReference. So in this case you can only get AttributeDefinitions from BlockTableRecord.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 17:10:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811395#M50438</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-03-21T17:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Get block reference information error</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811778#M50439</link>
      <description>&lt;P&gt;But I want to read the block only. I don't creat or insert it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2013 00:52:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811778#M50439</guid>
      <dc:creator>ditran7577</dc:creator>
      <dc:date>2013-03-22T00:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Get block reference information error</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811853#M50440</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1128366"&gt;@ditran7577&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;But I want to read the block only. I don't creat or insert it.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Repeat:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;So in this case you can only get AttributeDefinitions from BlockTableRecord.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2013 06:29:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811853#M50440</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-03-22T06:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Get block reference information error</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811861#M50441</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 11px; line-height: 14px;"&gt;Are there any way to get value of AttributeDefinitions.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11px;"&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2013 06:47:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811861#M50441</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-03-22T06:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Get block reference information error</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811865#M50442</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN style="font-size: 11px; line-height: 14px;"&gt;Are there any way to get value of AttributeDefinitions.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11px;"&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Of course!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE style="font-family: Consolas; font-size: 10; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;Dim&lt;/SPAN&gt;&amp;nbsp;DB&amp;nbsp;&lt;SPAN style="color: blue;"&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;Database&lt;/SPAN&gt;&amp;nbsp;=&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;HostApplicationServices&lt;/SPAN&gt;.WorkingDatabase
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;Dim&lt;/SPAN&gt;&amp;nbsp;ed&amp;nbsp;&lt;SPAN style="color: blue;"&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;Editor&lt;/SPAN&gt;&amp;nbsp;=&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;Application&lt;/SPAN&gt;.DocumentManager.MdiActiveDocument.Editor
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;Dim&lt;/SPAN&gt;&amp;nbsp;trans&amp;nbsp;&lt;SPAN style="color: blue;"&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;Transaction&lt;/SPAN&gt;&amp;nbsp;=&amp;nbsp;DB.TransactionManager.StartTransaction
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;Using&lt;/SPAN&gt;&amp;nbsp;trans
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;Dim&lt;/SPAN&gt;&amp;nbsp;id&amp;nbsp;&lt;SPAN style="color: blue;"&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;ObjectId&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: green;"&gt;'&amp;nbsp;id&amp;nbsp;of&amp;nbsp;our&amp;nbsp;BlockTableRecord - in your's case is openBT(blockName)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: blue;"&gt;Dim&lt;/SPAN&gt;&amp;nbsp;btAttRec&amp;nbsp;&lt;SPAN style="color: blue;"&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;BlockTableRecord&lt;/SPAN&gt;&amp;nbsp;=&amp;nbsp;trans.GetObject(id,&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;OpenMode&lt;/SPAN&gt;.ForRead)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;Dim&lt;/SPAN&gt;&amp;nbsp;idAtt&amp;nbsp;&lt;SPAN style="color: blue;"&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;ObjectId&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;For&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;Each&lt;/SPAN&gt;&amp;nbsp;idAtt&amp;nbsp;&lt;SPAN style="color: blue;"&gt;In&lt;/SPAN&gt;&amp;nbsp;btAttRec
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;Dim&lt;/SPAN&gt;&amp;nbsp;ent&amp;nbsp;&lt;SPAN style="color: blue;"&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;Entity&lt;/SPAN&gt;&amp;nbsp;=&amp;nbsp;trans.GetObject(idAtt,&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;OpenMode&lt;/SPAN&gt;.ForRead)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;If&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;TypeOf&lt;/SPAN&gt;&amp;nbsp;ent&amp;nbsp;&lt;SPAN style="color: blue;"&gt;Is&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;AttributeDefinition&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;Then&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;Dim&lt;/SPAN&gt;&amp;nbsp;attDef&amp;nbsp;&lt;SPAN style="color: blue;"&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;AttributeDefinition&lt;/SPAN&gt;&amp;nbsp;=&amp;nbsp;&lt;SPAN style="color: blue;"&gt;CType&lt;/SPAN&gt;(ent,&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;AttributeDefinition&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ed.WriteMessage(vbCrLf&amp;nbsp;+&amp;nbsp;&lt;SPAN style="color: #a31515;"&gt;"attdef.TextString&amp;nbsp;=&amp;nbsp;{0}"&lt;/SPAN&gt;,&amp;nbsp;attDef.TextString)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ed.WriteMessage(vbCrLf&amp;nbsp;+&amp;nbsp;&lt;SPAN style="color: #a31515;"&gt;"attdef.Tag&amp;nbsp;=&amp;nbsp;{0}"&lt;/SPAN&gt;,&amp;nbsp;attDef.Tag)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;End&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;If&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;Next&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;trans.Commit()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;End&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: blue;"&gt;Using&lt;/SPAN&gt;
&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Mar 2013 07:16:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811865#M50442</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-03-22T07:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Get block reference information error</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811943#M50443</link>
      <description>&lt;P&gt;AttDef.textstring ="" although AttributeDefinition has value. What happen?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2013 09:46:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811943#M50443</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-03-22T09:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: Get block reference information error</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811948#M50444</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;AttDef.textstring ="" although AttributeDefinition has value. What happen?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I do not know what happen. Maybe you&amp;nbsp;again confused AttributeDefinition in BlockTableRecord and AttributeReference in inserted BlockReference.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Please attach dwg-file with block and explain what do you mean.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2013 09:54:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811948#M50444</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-03-22T09:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Get block reference information error</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811956#M50445</link>
      <description>&lt;PRE&gt; &amp;lt;CommandMethod("test")&amp;gt; _
    Public Sub test()
        Dim blockName As String = "blank_sheet"
        Dim ofd As New OpenFileDialog("CAD FILE", Nothing, "dwg; dwt", "CAD FILE", Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.DoNotTransferRemoteFiles)
        Dim dr As System.Windows.Forms.DialogResult = ofd.ShowDialog()
        If dr &amp;lt;&amp;gt; System.Windows.Forms.DialogResult.OK Then
            Return
        End If
        Dim sourcefile As String = ofd.Filename

        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim doclock As DocumentLock = doc.LockDocument()
        Dim ed As Editor = doc.Editor
        Dim acCurDb As Database = doc.Database

        Using doclock
            Using OpenDb As New Database(False, True)
                OpenDb.ReadDwgFile(sourcefile, System.IO.FileShare.ReadWrite, True, "")
                Using opentrans As Transaction = OpenDb.TransactionManager.StartTransaction()
                    Dim openBT As BlockTable = DirectCast(opentrans.GetObject(OpenDb.BlockTableId, OpenMode.ForRead), BlockTable)
                    If openBT.Has(blockName) Then
                        Dim id As ObjectId = openBT(blockName)
                        Dim btAttRec As BlockTableRecord = opentrans.GetObject(id, OpenMode.ForRead)
                        Dim idAtt As ObjectId
                        For Each idAtt In btAttRec
                            Dim ent As Entity = opentrans.GetObject(idAtt, OpenMode.ForRead)
                            If TypeOf ent Is AttributeDefinition Then
                                Dim attDef As AttributeDefinition = CType(ent, AttributeDefinition)
                                ed.WriteMessage(vbCrLf + "attdef.TextString = {0}", attDef.TextString)
                                ed.WriteMessage(vbCrLf + "attdef.Tag = {0}", attDef.Tag)
                            End If
                        Next
                    Else
                        opentrans.Commit()
                        Exit Sub
                    End If
                    opentrans.Commit()
                End Using
            End Using
        End Using

    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2013 10:18:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811956#M50445</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-03-22T10:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: Get block reference information error</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811994#M50446</link>
      <description>&lt;P&gt;I was right and you confuse BlockTableRecord and BlockReference, AttributeDefinition and AttributeReference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this code (no error checking done):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;CommandMethod("test")&amp;gt; _
Public Sub test()
  Dim blockName As String = "blank_sheet"
  Dim ofd As New Autodesk.AutoCAD.Windows.OpenFileDialog( _
   "CAD FILE", Nothing, "dwg; dwt", "CAD FILE", _
   Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.DoNotTransferRemoteFiles)
  Dim dr As System.Windows.Forms.DialogResult = ofd.ShowDialog()
  If dr &amp;lt;&amp;gt; System.Windows.Forms.DialogResult.OK Then
    Return
  End If
  Dim sourcefile As String = ofd.Filename

  Dim doc As Document = _
   Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument()
  Dim doclock As DocumentLock = doc.LockDocument()
  Dim ed As Editor = doc.Editor
  Dim acCurDb As Database = doc.Database

  Using doclock
    Using OpenDb As New Database(False, True)
      OpenDb.ReadDwgFile(sourcefile, System.IO.FileShare.ReadWrite, True, "")
      Using opentrans As Transaction = OpenDb.TransactionManager.StartTransaction()
        Dim openBT As BlockTable = _
         DirectCast(opentrans.GetObject(OpenDb.BlockTableId, OpenMode.ForRead), BlockTable)
        If openBT.Has(blockName) Then
          Dim id As ObjectId = openBT(blockName)
          Dim btAttRec As BlockTableRecord = opentrans.GetObject(id, OpenMode.ForRead)
&lt;EM&gt;&lt;STRONG&gt;          For Each idBref As ObjectId In btAttRec.GetBlockReferenceIds(True, True)
            Dim bRef As BlockReference = opentrans.GetObject(idBref, OpenMode.ForRead)
            For Each idAttRef In bRef.AttributeCollection
              Dim attRef As AttributeReference = opentrans.GetObject(idAttRef, OpenMode.ForRead)
              ed.WriteMessage(vbCrLf + "attRef.Tag = {0}", attRef.Tag)
              ed.WriteMessage(vbCrLf + "attRef.TextString = {0}", attRef.TextString)
            Next
          Next&lt;/STRONG&gt;&lt;/EM&gt;
        End If
        opentrans.Commit()
      End Using
    End Using
  End Using
End Sub
&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Mar 2013 11:15:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3811994#M50446</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-03-22T11:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Get block reference information error</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3813489#M50447</link>
      <description>&lt;P&gt;Oh. Thanks so much.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2013 06:45:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-block-reference-information-error/m-p/3813489#M50447</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-03-25T06:45:04Z</dc:date>
    </item>
  </channel>
</rss>

