Option Strict Off
Imports System
Imports System.IO
Imports NXOpen
Imports NXOpen.UF
Module NXJurnal
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Sub Main
workPart.SetAttribute("File_Path", GetFilePath())
workPart.SetAttribute("File_Name", GetFileName())
workPart.SetAttribute("Part_Number", GetFileNumber())
workPart.SetAttribute("Part_Decsription", GetFileDescription())
workPart.SetAttribute("Tooling_type", GetFileToolingType())
workPart.SetAttribute("Class_size", GetFileClassSize())
workPart.SetAttribute("Customer_Name", GetFileCustomerName())
Dim user_name As String = System.Environment.ExpandEnvironmentVariables("%username%")
workPart.SetAttribute("Name", user_name)
End Sub
'***********************************************************************
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
'***********************************************************************
Function GetFilePath()
Dim strPath as String
Dim strPart as String
Dim pos as Integer
'get the full file path
strPath = displayPart.fullpath
GetFilePath = strPath
End Function
'***********************************************************************
Function GetFileNumber()
Dim strPath as String
Dim strPart as String
Dim pos as Integer
Dim e as Integer
Dim l as Integer
'get the full file path
strPath = displayPart.fullpath
'get the part file name
pos = InStrRev(strPath, "\")
strPart = Mid(strPath, pos + 1)
strPath = Right(strPath, pos)
e = Len(strPart)
l =(e-11)
strPart = Left(strPart, Len(strPart) - l)
GetFileNumber = strPart
End Function
'***********************************************************************
Function GetFileDescription()
Dim strPath as String
Dim strPart as String
Dim pos as Integer
Dim e as Integer
Dim L as Integer
'get the full file path
strPath = displayPart.fullpath
'get the part file name
pos = InStrRev(strPath, "\")
strPart = Mid(strPath, pos + 1)
strPath = Right(strPath, pos)
'strip off the "xxx-xxx-xxx-_"
strPart = Right(strPart, Len(strPart) - 13)
'strip off the ".prt" extension
strPart = Left(strPart, Len(strPart) - 4)
GetFileDescription = strPart
End Function
'***********************************************************************
Function GetFileToolingType()
Dim strPath as String
Dim strPart as String
Dim strPart2 as String
Dim pos as Integer
Dim pos2 as Integer
'get the full file path
strPath = displayPart.fullpath
pos = InStrRev(strPath, "\")
strPart = Left(strPath, pos - 1)
pos2 = InStrRev(strPart, "\")
strPart2 = Mid(strPart, pos2 + 1)
GetFileToolingType = strPart2
End Function
'***********************************************************************
Function GetFileClassSize()
Dim strPath as String
Dim strPart as String
Dim strPart2 as String
Dim strPart3 as String
Dim pos as Integer
Dim pos2 as Integer
Dim pos3 as Integer
'get the full file path
strPath = displayPart.fullpath
pos = InStrRev(strPath, "\")
strPart = Left(strPath, pos - 1)
pos2 = InStrRev(strPart, "\")
strPart2 = Left(strPart, pos2 - 1)
pos3 = InStrRev(strPart2, "\")
strPart3 = Mid(strPart2, pos3 + 1)
GetFileClassSize = strPart3
End Function
'***********************************************************************
Function GetFileCustomerName()
Dim strPath as String
Dim strPart as String
Dim strPart2 as String
Dim strPart3 as String
Dim strPart4 as String
Dim pos as Integer
Dim pos2 as Integer
Dim pos3 as Integer
Dim pos4 as Integer
'get the full file path
strPath = displayPart.fullpath
pos = InStrRev(strPath, "\")
strPart = Left(strPath, pos - 1)
pos2 = InStrRev(strPart, "\")
strPart2 = Left(strPart, pos2 - 1)
pos3 = InStrRev(strPart2, "\")
strPart3 = Left(strPart2, pos3 - 1)
pos4 = InStrRev(strPart3, "\")
strPart4 = Mid(strPart3, pos4 + 1)
GetFileCustomerName = strPart4
End Function
End Module