×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

"Select All" solid bodies using a journal

"Select All" solid bodies using a journal

"Select All" solid bodies using a journal

(OP)
Does anyone know how to select all the solid bodies in a part using a journal?

Thanks.

RE: "Select All" solid bodies using a journal

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

RE: "Select All" solid bodies using a journal

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

Thanks.

RE: "Select All" solid bodies using a journal

(OP)
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.

RE: "Select All" solid bodies using a journal

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources