There is a lot more, but most of it is just me testing different approaches. Some of it is from another post and I've yet to implement it in a usable way. All of it dirty.
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim imageDicId As ObjectId = RasterImageDef.GetImageDictionary(db)
If IsDBNull(imageDicId) = False Then
Dim imagedic As DBDictionary = TryCast(tr.GetObject(imageDicId, OpenMode.ForRead), DBDictionary)
Dim imageDicIDColl As New ObjectIdCollection
imageDicIDColl = CType(GetDatabaseID(imagedic, imageDicIDColl), ObjectIdCollection)
Dim btab As BlockTable = DirectCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
For Each btid As ObjectId In btab
Dim btrec As BlockTableRecord = TryCast(tr.GetObject(btid, OpenMode.ForRead), BlockTableRecord)
Next
For Each id As ObjectId In imageDicIDColl
Dim imageDef As RasterImageDef = TryCast(id.GetObject(OpenMode.ForRead), RasterImageDef)
If imageDef Is Nothing Then
Continue For
End If
Dim imageRecID As ObjectIdCollection = imageDef.GetPersistentReactorIds()
For Each imageID As ObjectId In imageRecID
Dim r As DBObject = TryCast(tr.GetObject(imageID, OpenMode.ForRead), DBObject)
If r Is Nothing Then
Continue For
End If
Dim ri As RasterImage = TryCast(tr.GetObject(r.OwnerId, OpenMode.ForWrite), RasterImage)
If ri Is Nothing Then
Continue For
End If
Next
End if
GetDatabaseID function, originally used for a purging.
Public Shared Function GetDatabaseID(ByVal DBtable As Object, ByVal idsToPurge As ObjectIdCollection)
Dim dicID As DBDictionaryEntry
'process Database dictionarys only
If TypeOf DBtable Is DBDictionary Then
Dim DBdic As DBDictionary = TryCast(DBtable, DBDictionary)
For Each dicID In DBdic
Dim key As String = dicID.Key
'Weed out keys that may cause trouble
If (key <> "ByBlock") AndAlso (key <> "ByLayer") AndAlso (key <> "Global") Then
If dicID.Value.IsValid Then
'add to master list of items to purge
idsToPurge.Add(dicID.Value)
End If
End If
Next
Else
'Process non-dictionary databases
For Each OId As ObjectId In DBtable
If OId.IsValid Then
'add to master list of items to purge
idsToPurge.Add(OId)
End If
Next
End If
Return idsToPurge
End Function