.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Difference between 2008 and 2010 Xref Code

1 REPLY 1
Reply
Message 1 of 2
BrentBurgess1980
236 Views, 1 Reply

Difference between 2008 and 2010 Xref Code

I have some code written for 2008 and it works fine to get a list of the Xref's in a drawing. Using the same code in 2010, I get an error on the "Dim btr As BlockTableRecord" line.

The message I get is

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Has anyone else experience this and if so, is there a away around it?


Dim Doc As Document = AcApp.DocumentManager.MdiActiveDocument
Dim Ed As Editor = Doc.Editor
Dim Db As Database = Doc.Database
Dim Tr As Transaction = Db.TransactionManager.StartTransaction()

Using Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument
Using Tr
Try
Dim DbXrGraph As XrefGraph = Db.GetHostDwgXrefGraph(True)
For i As Integer = 1 To DbXrGraph.NumNodes - 1
Dim XrGraphNode As XrefGraphNode = DbXrGraph.GetXrefNode(i)
If Not XrGraphNode.IsNested Then
Dim btr As BlockTableRecord = DirectCast(Tr.GetObject(XrGraphNode.BlockTableRecordId, OpenMode.ForRead), BlockTableRecord)
If btr.Name = Something Then

End If

End If
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try

End Using
End Using

Thanks in advance

Brent
1 REPLY 1
Message 2 of 2

I have figured it out. There was some code above it that was for some reason throwing it out of whack.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost