- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Afternoon, It been a while and Im trying to force a detach in a load of files using a batch script. No errors are being thrown but the image references that are not found are still in the drawing. Its got to be something simple in the code below. Just need another set of eyes.
Try
For Each Me.filepath In ListBox1.Items
ProgressBar1.Maximum = fileprogress
Dim fi As New FileInfo(filepath)
Dim db As New Database(False, True)
Try
db.ReadDwgFile(filepath, System.IO.FileShare.ReadWrite, False, "")
t = db.TransactionManager.StartTransaction
Using t
Dim bt As BlockTable = CType(db.BlockTableId.GetObject(OpenMode.ForRead), BlockTable)
Dim id As ObjectId
For Each id In bt
Dim btr As BlockTableRecord = CType(id.GetObject(OpenMode.ForRead), BlockTableRecord)
If btr.XrefStatus = XrefStatus.NotAnXref And btr.XrefStatus = XrefStatus.FileNotFound Or btr.XrefStatus = XrefStatus.Unreferenced Then
db.DetachXref(id)
End If
Next
t.Commit()
End Using
Catch
MsgBox(Err.Description + "ouch")
Finally
db.SaveAs(filepath, DwgVersion.Current)
t.Dispose()
End Try
Solved! Go to Solution.