Message 1 of 10

Not applicable
10-06-2010
01:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have been diving as deeply as I can into objectarx and .net over the last few weeks, and I ran into another "That didn't work like I expected' issue.
This is more of a test than anything else, but I am trying to open a drawing with ReadDwgFile and then pull attribute data from a block in that drawing.
Here is my code:
Public Sub test() Dim pathtodwg As String = "C:\PlotItIn\PDB542503A4.dwg" Using dwg As Database = New Database(False, False) dwg.ReadDwgFile(pathtodwg, System.IO.FileShare.Read, True, Nothing) Dim db As Database = dwg.AcadDatabase Using Trans As Transaction = db.TransactionManager.StartTransaction
Dim curblock As String = "ahlbord" Dim curtag As String = "REV" Dim bktbl As BlockTable = db.BlockTableId.GetObject(OpenMode.ForRead) Dim revblk As BlockTableRecord = bktbl(curblock).GetObject(OpenMode.ForRead) Dim refs As ObjectIdCollection = revblk.GetBlockReferenceIds(False, False) For Each ref In refs Dim bref As BlockReference = Trans.GetObject(ref, OpenMode.ForRead) Dim atts As AttributeCollection = bref.AttributeCollection For Each obj In atts Dim att As AttributeReference
att = Trans.GetObject(obj, OpenMode.ForRead, False) If att.Tag = curtag Then Application.ShowAlertDialog(att.TextString) End If Next Next End Using End Using End Sub
I get the eNotOpenForWrite and AutoCAD fatals out. I dropped some alertdialogs in to see how far it was getting and it seems like it's bombing out at the ReadDwgFile line.
Thanks,
Jason
Solved! Go to Solution.