Message 1 of 3

Not applicable
10-24-2011
04:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Welcome
I have a little problem - how to get AcadBlock or AcadEntities by using transaction.
In a current open document I can do something like this:
Dim document As Document = Application.DocumentManager.MdiActiveDocument Dim AcadDrawing As AcadDocument = DirectCast(document.AcadDocument, AcadDocument) For Each block As AcadBlock In AcadDrawing.Blocks For Each ent As AcadEntity In block 'here I can access all of the entities in block Next Next
It's working fine, but when I tried open a document in backgroud I can't get the AcadBlock or AcadEntities, only a BlockTableRecord.
Dim path As String = "c:\path to dwg file" Dim db As Database = New Database(True, True) db.ReadDwgFile(path, FileOpenMode.OpenForReadAndAllShare, True, Nothing) Dim tr As Transaction = db.TransactionManager.StartTransaction() Dim blockTable As BlockTable = DirectCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable) For Each blockRecordId As ObjectId In blockTable Dim blockRecord As BlockTableRecord = DirectCast(tr.GetObject(blockRecordId, OpenMode.ForRead), BlockTableRecord)'I can't get AcadEntity or AcadBlock here :/ Next
Is there any posibility to get AcadBlocks or AcadEntities by using TransactionManager?
what's the difference between AcadBlock and BlockTableRecord?
I will be very grateful if anyone would like to help me with this problem 🙂
Solved! Go to Solution.