.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
How to check BlockRefer ence
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
HI all.
So i have 3 file DWG :
3.dwg : is a plan 'archi'
2.dwg is a plan with only décoration.
1. dwg is a plan with only the water.
i have this structure in my file (1.dwg) :
1.dwg
---> 2..dwg
---------> 3.dwg (this file is a Xref of 2.dwg)
--> is the blockRefecence (XRef).
my code :
Dim CollXref As New ObjectIdCollection
Dim mydb As Database = Application.DocumentManager.MdiActiveDocument.Data base
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 & vbCritical, "ee")
Finally
myTrans.Dispose()
End Try
DocLock.Dispose()
DocLock = Nothing
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.
How i can do that ?
Solved! Go to Solution.
Re: How to check BlockRefer ence
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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:
Cheers
Gopinath
Re: How to check BlockRefer ence
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thx i have to see that
Re: How to check BlockRefer ence
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Here my code final :
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 & 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 & "Xref path name: " + bl.PathName)
CollXRef.Add(bl.ObjectId)
Exit For
End If
End If
Next
'trouvé un xref --> Adding
If CollXRef.Count > 0 Then
Try
doc.Database.BindXrefs(CollXRef, False)
Catch ex As Exception
okErr = True
MsgBox("Erreur lors de la liaison d'un Xref" & vbCrLf & "--> Essayer de lier le premier niveau", _
vbOKOnly & vbCritical, _
"Erreur Système")
Finally
tr.Commit()
End Try
End If
End Using
ed.WriteMessage(vbCrLf & "-> " & CollXRef.Count.ToString)
Loop Until (CollXRef.Count = 0) Or (okErr = True)
LockDoc.Dispose()
LockDoc = NothingIf check only one XRef. it is for the binf of only one XREF.
I have big file to bing and if i bing all in one troke, autocad crack for a 'Out of mémory'
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.

