' NX 7.0.1.7
' Journal created by adminuser on Mon Jul 12 14:52:17 2010 Central Daylight Time
'
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Function GetFilePath()
Dim strPath as String
Dim strPart as String
Dim pos as Integer
'get the full file path
strPath = displayPart.fullpath
'get the part file name
pos = InStrRev(strPath, "\")
strPart = Mid(strPath, pos + 1)
strPath = Left(strPath, pos)
'strip off the ".prt" extension
strPart = Left(strPart, Len(strPart) - 4)
GetFilePath = strPath
End Function
Function GetFileName()
Dim strPath as String
Dim strPart as String
Dim pos as Integer
'get the full file path
strPath = displayPart.fullpath
'get the part file name
pos = InStrRev(strPath, "\")
strPart = Mid(strPath, pos + 1)
strPath = Left(strPath, pos)
'strip off the ".prt" extension
strPart = Left(strPart, Len(strPart) - 4)
GetFileName = strPart
End Function
Sub Main
For Each fileName As String In My.Computer.FileSystem.GetFiles("C:\Documents and Settings\adminuser\Desktop\CATIA_translated files - Node 2\n2_eclss")
Dim theSession As Session = Session.GetSession()
' ----------------------------------------------
' Menu: File->Open...
' ----------------------------------------------
Dim basePart1 As BasePart
Dim partLoadStatus1 As PartLoadStatus
basePart1 = theSession.Parts.OpenBaseDisplay(fileName, partLoadStatus1)
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
partLoadStatus1.Dispose()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Enter Gateway")
' ----------------------------------------------
' Menu: File->Save As...
' ---------------------------------------------
Dim partSaveStatus1 As PartSaveStatus
Dim fileSavepath As String = "C:\Documents and Settings\adminuser\Desktop\Node 2 STP\"
Dim currentFile As String = GetFileName()
partSaveStatus1 = workPart.SaveAs(fileSavePath & currentFile & ".stp" )
partSaveStatus1.Dispose()
' ----------------------------------------------
' Menu: File->Close->All Parts
' ----------------------------------------------
theSession.Parts.CloseAll(BasePart.CloseModified.CloseModified, Nothing)
workPart = Nothing
displayPart = Nothing
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
Next
End Sub
End Module