Problem with Editor.GetEntity eNullObjectID error

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a strange issue. After perfoming some solids editing on an object, trying to select that 3dSolid again using Editor.GetEntity generates a eNullObjectId exception.
Here is the code that generates the error:
.
Public Shared Function SelectCounterTopSolid(ByVal tr As Transaction, ByVal db As Database, ByVal ed As Editor) As Solid3d Dim peo3 As New PromptEntityOptions(vbLf & "Select couter top solid 3d: ") peo3.SetRejectMessage(vbLf & "Entity is not a solid.") peo3.AddAllowedClass(GetType(Solid3d), False) Dim per3 As PromptEntityResult = ed.GetEntity(peo3) If per3.Status <> PromptStatus.OK Then Return Nothing End If Return TryCast(tr.GetObject(per3.ObjectId, OpenMode.ForWrite, True), Solid3d) End Function
The error occurs on the get enity line when the 3d solid is clicked on. The interesting part is that this error only happens after the following code is run agains the same 3d solid in a previous command:
Private Shared Sub CreateAutomaticSinkCutout(ByVal sink_br As BlockReference, ByVal Counter As Solid3d) Counter.RecordHistory = False 'Subtract sink solids from counter Dim Enities As New DBObjectCollection sink_br.Explode(Enities) For Each Ent As DBObject In Enities If Ent.GetType() Is GetType(Solid3d) Then Counter.BooleanOperation(BooleanOperationType.BoolSubtract, Ent) End If Ent.Dispose() Next Using NewCounter As New Solid3d Dim Solids() As Solid3d = Counter.SeparateBody() Dim Sols As List(Of Solid3d) = Solids.ToList Sols.Add(Counter) 'Loop through list that includes counter For Each sol As Solid3d In Sols If Not (sink_br.GeometricExtents.MaxPoint.X >= sol.GeometricExtents.MaxPoint.X And _ sink_br.GeometricExtents.MaxPoint.Y >= sol.GeometricExtents.MaxPoint.Y And _ sink_br.GeometricExtents.MaxPoint.Z >= sol.GeometricExtents.MaxPoint.Z And _ sink_br.GeometricExtents.MinPoint.X <= sol.GeometricExtents.MinPoint.X And _ sink_br.GeometricExtents.MinPoint.Y <= sol.GeometricExtents.MinPoint.Y And _ sink_br.GeometricExtents.MinPoint.Z <= sol.GeometricExtents.MinPoint.Z) Then 'Sinks extents do not contain the solids extents, add back to counter NewCounter.BooleanOperation(BooleanOperationType.BoolUnite, sol) End If Next 'dispose of all in array that came from separatebocy For Each sol As Solid3d In Solids sol.Dispose() Next '### copy geometry to counter Counter.CopyFrom(NewCounter) End Using End Sub
The point of the above code is that the Solid3D is a counter top, with possible backsplashes (may not be a simple cube), and the sink_br is a block that contains a solid3d. The function automatically cuts a hole in the counter top solid 3D, so you can see inside the sink once it's placed. It does the boolean subtraction then has to separate the solid and add the pieces back together to try to eliminated the piece thats left inside the sink after the subtraction.
I'm not sure if I'm doing something wrong in the cutout code that makes the solid unable to be selected, or if its a bug in the API in the Editor.GetEntity. Whatever it is, could you guys take a look and let me know what you think?