Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Select All" solid bodies using a journal

Status
Not open for further replies.

claforet

Mechanical
Apr 8, 2010
54
Does anyone know how to select all the solid bodies in a part using a journal?

Thanks.
 
Replies continue below

Recommended for you

Here you go:

' get the display part solids
Dim bodies() As Body = GetBodies(s.Parts.Display)

' do an action on the collected solids
For ii As Integer = 0 To bodies.Length - 1

' your action on solids here...

Next
 
Thanks for thereply. The 'GetBodies' function doesn't exist apparently in my version of UG (NX5.0.6). Are there any other methods?

Thanks.
 
I guess I should be more specific about what I'm trying to do as well. I want to export a parasolid file for the current part (or assembly) using a journal. I found some code on the forum before which did this, except it popped up a dialogue asking you to select the bodies for export. I want all the solids to be automatically selected and exported without any user input.
 
Try the following code from the GTAC library. You might change the output "C:\temp\export_test.x_t" to your use.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++

Option Strict Off

Imports System
Imports System.Collections
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Utilities

Module export_all_bodies_to_parasolid

Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()

Sub Main()

Dim inx As Integer = 0
Dim dispPart As Part = s.Parts.Display
Dim n As String = vbCrLf

Dim bodies As BodyCollection = dispPart.Bodies
Dim bodyCount As Integer = bodies.ToArray.Length
Dim tagList(bodyCount - 1) As NXOpen.Tag

Do
tagList(inx) = dispPart.Bodies.ToArray(inx).Tag
inx = inx + 1

Loop Until inx = bodyCount

ufs.Ps.ExportData(tagList, "C:\temp\export_test.x_t")


End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

GetUnloadOption = UFConstants.UF_UNLOAD_IMMEDIATELY

End Function

End Module
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor