Private Function GetXDataEntities() As ObjectIdCollection
Dim entitiesId = New ObjectIdCollection()
Dim database = Active.Database
Try
Using transaction = Active.Database.TransactionManager.StartTransaction()
Dim blockTable = TryCast(transaction.GetObject(database.BlockTableId, OpenMode.ForRead), BlockTable)
If blockTable IsNot Nothing Then
Dim modelspace = TryCast(transaction.GetObject(blockTable(BlockTableRecord.ModelSpace), OpenMode.ForRead), BlockTableRecord)
If modelspace IsNot Nothing Then
EntityWalker(modelspace, entitiesId, transaction)
End If
End If
End Using
Catch exception As System.Exception
Log.Logger.Error(exception, "GetLineEntities: Error getting entity objectId")
End Try
Return entitiesId
End Function
Private Sub EntityWalker(blockTableRecord As BlockTableRecord, ByRef entitiesId As ObjectIdCollection, transaction As Transaction)
Try
Dim rxc As RXClass = RXClass.GetClass(GetType(BlockReference))
For Each entityId As ObjectId In blockTableRecord
Dim entity = TryCast(transaction.GetObject(entityId, OpenMode.ForRead, False, True), Entity)
If entity IsNot Nothing Then
If entityId.ObjectClass = rxc Then
Dim blockReference = TryCast(transaction.GetObject(entityId, OpenMode.ForRead), BlockReference)
If blockReference IsNot Nothing Then
Dim blockTableRecord2 = TryCast(transaction.GetObject(blockReference.BlockTableRecord, OpenMode.ForRead, False, True), BlockTableRecord)
If blockTableRecord2 IsNot Nothing Then
EntityWalker(blockTableRecord2, entitiesId, transaction)
End If
End If
Else
If XData.CheckXDataExists(entity, _AppName) Then
If Not entitiesId.Contains(entity.ObjectId) Then
entitiesId.Add(entity.ObjectId)
End If
End If
End If
End If
Next
Catch exception As Exception
Log.Logger.Error(exception, "EntityWalker: Error getting entity objectId")
End Try
End Sub