Problem with Editor.GetEntity eNullObjectID error

Problem with Editor.GetEntity eNullObjectID error

Anonymous
Not applicable
1,598 Views
2 Replies
Message 1 of 3

Problem with Editor.GetEntity eNullObjectID error

Anonymous
Not applicable

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?

 

 

0 Likes
1,599 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

Anybody...  Bueller ....

 

I haven't had any luck with this, the error seems like its a bug in the .net ARX wrappers, but it must be because of something I'm doing to that solid.

 

Can anyone suggusts an alternate way to make the cutout in the solid so I could test it. Again, it just needs to cut the counter top by the ouline of the sink and remove the 'plug' thats left. I can't think of another method.

 

Appreciate any assitance, thank you.

0 Likes
Message 3 of 3

Anonymous
Not applicable

Well, I found a solution, I rearanged my second code listing so that instead of trying to modify the same 3dsolid, i end up just deleting it and appending a new one to the database. This seems to have solved the issue. Although, if anyone can identify the problem in the original code, i would like to know what was happening so I can avoid similar problems in the future.

 

Heres the modified coded:

            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

            Dim 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
            'per documentaton I'm resposible for these objects
            For Each sol As Solid3d In Solids
                sol.Dispose()
            Next

            'delete the old counter 3dsolid
            Counter.Erase()

            'Append the newly created solid
            Dim btr As BlockTableRecord = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)
            btr.AppendEntity(NewCounter)
            tr.AddNewlyCreatedDBObject(NewCounter, True)

 

0 Likes