Private Sub InsertSingle(sender As Object, e As EventArgs) Handles SemiAutoInsertButton.Click
Dim document = Active.Document
Dim paths As List(Of FullSubentityPath)
Using document.LockDocument()
Using transaction As Transaction = Active.Database.TransactionManager.StartTransaction()
If Extensions.EditorExtensions.SelectNestedEntities(Active.Editor, paths, "Select an entity to add to extents:") Then
' This for each loop is where I am going wrong.
Dim extents = New Extents3d()
For Each fsp As FullSubentityPath In paths
Dim oIds = New List(Of ObjectId)(fsp.GetObjectIds())
oIds.Reverse()
Dim entity = DirectCast(oIds(0).GetObject(OpenMode.ForWrite), Entity)
extents.AddExtents(entity.GeometricExtents)
Next
Dim drawables = New List(Of Drawable)
Dim col As New IntegerCollection
Dim box = New Box(extents)
drawables.AddRange(box.GetBoxAsLineCollection())
For Each drawable In drawables
TransientManager.CurrentTransientManager.AddTransient(drawable, TransientDrawingMode.Highlight, 128, col)
Next
Extensions.EditorExtensions.UnhighlightSubEntities(paths)
End If
transaction.Commit()
End Using
End Using
End Sub