How to select automaticly all solids

Hello all,

I have a situation with the journal following. I'm using it to take backups of parts as just solid body but I don't want it to ask me to select solids on screen. How can I make it select all solids automaticly?

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI

Module NXJournal
Sub Main()

Dim theSession As Session = Session.GetSession()
Dim theUFSession As UFSession = UFSession.GetUFSession()

'********************************************************************************

Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow

'find file name and folder path
Dim fileName As String = IO.Path.GetFileName(workPart.FullPath)
Dim fileNameNoExt As String = IO.Path.GetFileNameWithoutExtension(workPart.FullPath)
Dim parentFolder As String = IO.Path.GetDirectoryName(workPart.FullPath)

'prepare a clean dd.mm.yy hh.mm.ss type string
Dim TimeNote As DateTime
TimeNote = System.DateTime.Now()
Dim full_date_time As String = TimeNote
Dim hour As String = Mid(full_date_time, Len(full_date_time) - 7, 2)
Dim minute As String = Mid(full_date_time, Len(full_date_time) - 4, 2)
Dim second As String = Mid(full_date_time, Len(full_date_time) - 1, 2)
Dim ddmmyy As String = Left(full_date_time, Len(full_date_time) - 9)
Dim year_short As String = Right(ddmmyy, 2)
ddmmyy = Left(ddmmyy, Len(ddmmyy) - 4) & year_short
ddmmyy = ddmmyy.PadLeft(8, "0")

'prepare new backup folder if doesn't exist
Dim yeni_klasor As String = parentFolder & "\backup"
My.Computer.FileSystem.CreateDirectory(yeni_klasor)

'result of new file path with new file name
Dim sonuc As String = yeni_klasor & "\" & fileNameNoExt & " " & ddmmyy & " " & hour & "." & minute & "." & second & ".prt"

'********************************************************************************

Dim abody() As TaggedObject
If SelectBodies("select bodies", abody) = Selection.Response.Cancel Then
Return
End If

Dim bodyTags As New List(Of Tag)

For Each temp As TaggedObject In abody
bodyTags.Add(temp.Tag)
Next

Dim options As UFPart.ExportOptions
With options
.expression_mode = UFPart.ExportExpMode.CopyExpDeeply
.new_part = True
.params_mode = UFPart.ExportParamsMode.RemoveParams
End With

theUFSession.Part.ExportWithOptions(sonuc, bodyTags.Count, bodyTags.ToArray, options)

End Sub

Function SelectBodies(ByVal prompt As String, ByRef selObj() As TaggedObject) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim title As String = "Select one or more bodies"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim selectionMask_array(0) As Selection.MaskTriple

With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY
End With

Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selobj)
If resp = Selection.Response.Ok Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If

End Function
End Module

The code below will get all the bodies in the given part (prototype bodies for a part file, occurrence bodies in an assembly file). The "AskAllBodies" function does the work, the rest of the code shows how to make use of it.

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF

Module Module1

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()

Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow

Sub Main()

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "NXJ")

lw.Open()

Dim occBods As New List(Of Body)
occBods = AskAllBodies(theSession.Parts.Display)

lw.WriteLine("body count: " & occBods.Count.ToString)

For Each temp As Body In occBods
lw.WriteLine("is occurrence: " & temp.IsOccurrence.ToString)
If temp.IsOccurrence Then
lw.WriteLine("owning component: " & temp.OwningComponent.Name)
Else
lw.WriteLine("owning part: " & temp.OwningPart.Leaf)
End If
Next

lw.Close()

End Sub

Function AskAllBodies(ByVal thePart As Part) As List(Of Body)
Dim theBodies As New List(Of Body)

Dim aBodyTag As Tag = Tag.Null
Do
theUfSession.Obj.CycleObjsInPart(thePart.Tag,
UFConstants.UF_solid_type, aBodyTag)
If aBodyTag = Tag.Null Then
Exit Do
End If

Dim theType As Integer, theSubtype As Integer
theUfSession.Obj.AskTypeAndSubtype(aBodyTag, theType, theSubtype)
If theSubtype = UFConstants.UF_solid_body_subtype Then
theBodies.Add(theSession.GetObjectManager.GetTaggedObject(aBodyTag))
End If
Loop While True

Return theBodies
End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function

End Module