' Build this as an external Console Application ' and execute it from a NX Command Prompt like this: ' ' batch_convert_stp_files_in_directory.exe D:\Full\Path\To\NXPartFiles ' ' OR ' ' run it from a NX Command Prompt as uncompiled journal file: ' ' run_journal batch_convert_stp_files_in_directory.vb -args D:\Full\Path\To\NXPartFiles ' Option Strict Off Imports System Imports System.Collections Imports NXOpen Imports NXOpen.UF Imports NXOpen.Utilities Module batch_convert_stp_files_in_directory Dim s As Session = Session.GetSession() Dim ufs As UFSession = UFSession.GetUFSession() Dim lw As ListingWindow = s.ListingWindow Sub Main(ByVal args As String()) Try Dim theDirectory As String = args(0) Dim fileCount = 0 lw.Open() lw.WriteLine("Directory to process: " & theDirectory) For Each fileName As String In My.Computer.FileSystem.GetFiles( theDirectory) Dim loadStatus As NXOpen.PartLoadStatus = Nothing Dim extension As String = Right$(fileName, 4) If extension.ToLower() = ".stp" Then Dim currentPart As Part = _ s.Parts.OpenBaseDisplay(fileName, loadStatus) If loadStatus.NumberUnloadedParts < 1 Then lw.WriteLine(" Processing file: " & fileName) currentPart.Save(Part.SaveComponents.False, Part.CloseAfterSave.True) Else lw.WriteLine(" *** ERR *** Unable to load file: " & fileName) End If ' Close any open part files Dim partCount As Integer = ufs.Part.AskNumParts() If partCount > 0 Then s.Parts.CloseAll(BasePart.CloseModified.CloseModified, Nothing) lw.WriteLine(" ") End If fileCount = fileCount+1 End If Next lw.WriteLine("Files processed: " & fileCount) Catch ex As Exception Console.OpenStandardOutput() Console.WriteLine(ex.ToString) Console.WriteLine() End Try End Sub End Module