<?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: How to check BlockReference in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-check-blockreference/m-p/3746721#M51803</link>
    <description>&lt;P&gt;Here my code final :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;                Dim LockDoc As DocumentLock = doc.LockDocument
                Dim OkErr as boolean = false
                Dim CollXRef As New ObjectIdCollection
                Do
                    CollXRef.Clear()
                    Dim xg As XrefGraph = db.GetHostDwgXrefGraph(True)
                    Dim root As GraphNode = xg.RootNode

                    Using tr As Transaction = db.TransactionManager.StartTransaction

                        For o = 0 To root.NumOut - 1 Step 1
                            Dim child As XrefGraphNode = CType(root.Out(o), XrefGraphNode)

                            If child.XrefStatus = XrefStatus.Resolved Then
                                Dim bl As BlockTableRecord = tr.GetObject(child.BlockTableRecordId, OpenMode.ForRead)

                                'ed.WriteMessage(vbCrLf &amp;amp; i_indent + child.Database.Filename)

                                ' Name of the Xref (found name)

                                ' You can find the original path too:
                                If bl.IsFromExternalReference = True Then
                                    ed.WriteMessage(vbCrLf &amp;amp; "Xref path name: " + bl.PathName)
                                    CollXRef.Add(bl.ObjectId)
                                    Exit For
                                End If
                            End If
                        Next

                        'trouvé un xref --&amp;gt; Adding

                        If CollXRef.Count &amp;gt; 0 Then
                            Try
                                doc.Database.BindXrefs(CollXRef, False)

                            Catch ex As Exception
                                okErr = True
                                MsgBox("Erreur lors de la liaison d'un Xref" &amp;amp; vbCrLf &amp;amp; "--&amp;gt; Essayer de lier le premier niveau", _
                                              vbOKOnly &amp;amp; vbCritical, _
                                              "Erreur Système")
                            Finally
                                tr.Commit()
                            End Try
                        End If
                    End Using
                    ed.WriteMessage(vbCrLf &amp;amp; "-&amp;gt; " &amp;amp; CollXRef.Count.ToString)
                Loop Until (CollXRef.Count = 0) Or (okErr = True)

                LockDoc.Dispose()
                LockDoc = Nothing&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;If check only one XRef. it is for the binf of only one XREF.&lt;/P&gt;&lt;P&gt;I have big file to bing and if i bing all in one troke, autocad crack for a 'Out of mémory'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't check it now (i am not on my work). So i don't know if i have resolve this case of out of memory.&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 06 Jan 2013 10:43:16 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-01-06T10:43:16Z</dc:date>
    <item>
      <title>How to check BlockReference</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-check-blockreference/m-p/3745319#M51800</link>
      <description>&lt;P&gt;HI all.&lt;BR /&gt;&lt;BR /&gt;So i have 3 file DWG :&lt;BR /&gt;&lt;BR /&gt;3.dwg : is a plan 'archi'&lt;BR /&gt;2.dwg is a plan with only décoration.&lt;BR /&gt;1. dwg is a plan with only the water.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;i have this structure in my file (1.dwg) :&lt;BR /&gt;&lt;BR /&gt;1.dwg&lt;BR /&gt;---&amp;gt; 2..dwg&lt;BR /&gt;---------&amp;gt; 3.dwg&amp;nbsp;&amp;nbsp; (this file is a Xref of 2.dwg)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--&amp;gt; is the blockRefecence (XRef).&lt;BR /&gt;&lt;BR /&gt;my code :&lt;/P&gt;&lt;PRE&gt;        Dim CollXref As New ObjectIdCollection

        Dim mydb As Database = Application.DocumentManager.MdiActiveDocument.Database 
        Dim myTrans As Transaction = mydb.TransactionManager.StartTransaction
        '
        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim DocLock As DocumentLock = doc.LockDocument

        Try
            
            Dim BlocTable As BlockTable = CType(myTrans.GetObject(mydb.BlockTableId, OpenMode.ForRead), BlockTable)
            For Each btid As ObjectId In BlocTable
                Dim DefBloc As BlockTableRecord = CType(myTrans.GetObject(btid, OpenMode.ForWrite), BlockTableRecord)
                '
                If DefBloc.IsFromExternalReference = True Then
                    If DefBloc.IsResolved = False Then
                       ....
                    Else
                        CollIdXref.Add(btid)
                    End If
                End If
            Next
            myTrans.Commit()
        Catch ex As Exception
            MsgBox(ex.Message, vbOKOnly &amp;amp; vbCritical, "ee")
        Finally
            myTrans.Dispose()
        End Try
        DocLock.Dispose()
        DocLock = Nothing

&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So i don't want to add Id of a Xref From a Xref. (In my example i want only ObjectId of the 2.dwg not 3.dwg if i launch this code on 1.dwg.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How i can do that ?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jan 2013 11:54:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-check-blockreference/m-p/3745319#M51800</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-01-03T11:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to check BlockReference</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-check-blockreference/m-p/3746494#M51801</link>
      <description>&lt;P&gt;You can use the XRef Graph to determine if an XRef is nested. Here is a blog post that shows how to use the XRefGraph type:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://adndevblog.typepad.com/autocad/2012/06/finding-all-xrefs-in-the-current-database-using-cnet.html" target="_blank"&gt;http://adndevblog.typepad.com/autocad/2012/06/finding-all-xrefs-in-the-current-database-using-cnet.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Gopinath&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2013 22:14:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-check-blockreference/m-p/3746494#M51801</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-01-04T22:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to check BlockReference</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-check-blockreference/m-p/3746581#M51802</link>
      <description>&lt;P&gt;Thx i have to see that&lt;/P&gt;</description>
      <pubDate>Sat, 05 Jan 2013 10:56:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-check-blockreference/m-p/3746581#M51802</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-01-05T10:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to check BlockReference</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-check-blockreference/m-p/3746721#M51803</link>
      <description>&lt;P&gt;Here my code final :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;                Dim LockDoc As DocumentLock = doc.LockDocument
                Dim OkErr as boolean = false
                Dim CollXRef As New ObjectIdCollection
                Do
                    CollXRef.Clear()
                    Dim xg As XrefGraph = db.GetHostDwgXrefGraph(True)
                    Dim root As GraphNode = xg.RootNode

                    Using tr As Transaction = db.TransactionManager.StartTransaction

                        For o = 0 To root.NumOut - 1 Step 1
                            Dim child As XrefGraphNode = CType(root.Out(o), XrefGraphNode)

                            If child.XrefStatus = XrefStatus.Resolved Then
                                Dim bl As BlockTableRecord = tr.GetObject(child.BlockTableRecordId, OpenMode.ForRead)

                                'ed.WriteMessage(vbCrLf &amp;amp; i_indent + child.Database.Filename)

                                ' Name of the Xref (found name)

                                ' You can find the original path too:
                                If bl.IsFromExternalReference = True Then
                                    ed.WriteMessage(vbCrLf &amp;amp; "Xref path name: " + bl.PathName)
                                    CollXRef.Add(bl.ObjectId)
                                    Exit For
                                End If
                            End If
                        Next

                        'trouvé un xref --&amp;gt; Adding

                        If CollXRef.Count &amp;gt; 0 Then
                            Try
                                doc.Database.BindXrefs(CollXRef, False)

                            Catch ex As Exception
                                okErr = True
                                MsgBox("Erreur lors de la liaison d'un Xref" &amp;amp; vbCrLf &amp;amp; "--&amp;gt; Essayer de lier le premier niveau", _
                                              vbOKOnly &amp;amp; vbCritical, _
                                              "Erreur Système")
                            Finally
                                tr.Commit()
                            End Try
                        End If
                    End Using
                    ed.WriteMessage(vbCrLf &amp;amp; "-&amp;gt; " &amp;amp; CollXRef.Count.ToString)
                Loop Until (CollXRef.Count = 0) Or (okErr = True)

                LockDoc.Dispose()
                LockDoc = Nothing&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;If check only one XRef. it is for the binf of only one XREF.&lt;/P&gt;&lt;P&gt;I have big file to bing and if i bing all in one troke, autocad crack for a 'Out of mémory'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't check it now (i am not on my work). So i don't know if i have resolve this case of out of memory.&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Jan 2013 10:43:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-check-blockreference/m-p/3746721#M51803</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-01-06T10:43:16Z</dc:date>
    </item>
  </channel>
</rss>

