NX
The number of bodies cannot be obtained correctly
2021-10-06T23:27:57Z
NX for Design
Summary
Details
cannot get the number of body exists in a nx part by NX Open. It seems to be gotten the number of deleted body, too.
Actually, the number of the solid body in the part is 2. However, the result by the NX Open API are 4.
Step to reproduce:
1. Create 2 bodies > delete one of the bodies. - Creating new bodies "Block" - Delete one of 2 bodies by Delete Body 2. Tools > Journal > Edit
3. Select New in the appeared journal editor > put any source code like below > Save it
-------------------------------------------------------------------------------------- Imports System Imports NXOpen
Module NXJournal Sub Main (ByVal args() As String)
Dim theSession As Session = Session.GetSession() Dim theUI As UI = UI.GetUI()
Dim c As Integer For Each temp As body In theSession.Parts.Display.Bodies If temp.IsSolidBody Then c += 1 Next msgbox(c)
End Sub End Module ---------------------------------------------------------------------------------------------- 4. Tools > Play Journal > Browse the journal created in step 3 above > Run - 2 bodies counted as the result.
Solution
It was fixed in NX1926.
- PR9517878: NXOpen.BodyCollection.ToArray returning an body which was deleted by Delete Body
Work around ( for NX11 - NX1899 Series):
Checking the number of faces and edges such as below:
If temp.IsSolidBody Then
Dim faces As Array faces = temp.GetFaces
Dim edges As Array edges = temp.GetEdges
If faces.Length + edges.Length > 0 Then c += 1
End If End If
Notes and References
The problem can be confirmed by Show/Hide function, too. "2 objects shown" messages appears even though actually one solid body is available in the model. - The result of Hide > Show "Solid Bodies".
- Actually there is one body, though.( go to Type Filter > set Solid Body > then please count it in Graphic Window.
Hardware/Software Configuration
Platform: INTL64 OS: windows OS Version: 1064 Product: NX Application: DESIGN Version: V11.0 Function: FEATURE_MODEL