PDW
Automotive
- Oct 13, 2010
- 110
Dear all,
Based on the Journal created by UGperson Link, i would like to do something similar.
But i have another folder structure and 2 different folder quantitys
With below journal, it is fully functional in case I have 4 Folders.
In Case I only have 3 folders, it is extracting the wrong Folder information.
Anybody willing to support on this to have it working for both folder structures?
Best regards,
Pascal
Working on NX11, No TC
Based on the Journal created by UGperson Link, i would like to do something similar.
But i have another folder structure and 2 different folder quantitys
With below journal, it is fully functional in case I have 4 Folders.
In Case I only have 3 folders, it is extracting the wrong Folder information.
Anybody willing to support on this to have it working for both folder structures?
Best regards,
Pascal
Working on NX11, No TC
Code:
'Release "QUA_Set_PartFileAttributes.vb"
'Drive:\Customer\XXXX\Mould\Final\XXXX-YYY.prt
'Drive:\Customer\XXXX\tool\XXXX-YYY-ZZZ.prt
'This journal updates, based on the OS File Name, several extracted Attributes
'FILE_PATH
'FILE_NAME
'Part_Spec
'PART_NAME
'MOULD_NR
'CUSTOMER_NAME
'***********************************************************************
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_Spec", (GetFilePath() & GetFileName())&".prt")
workPart.SetAttribute("PART_NAME", GetFilePartName())
workPart.SetAttribute("MOULD_NR", GetFileMould())
workPart.SetAttribute("CUSTOMER_NAME", GetFileCustomerName())
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
lw.WriteLine("Path : " & GetFilePath)
lw.WriteLine("Name : " & GetFileName)
lw.WriteLine("Customer : " & GetFileCustomerName)
lw.WriteLine("Mould : " & GetFileMould)
lw.WriteLine("Part Number : " & GetFilePartName)
'Dim user_name As String = System.Environment.ExpandEnvironmentVariables("%username%")
'workPart.SetAttribute("Name", user_name)
End Sub
'QUA_Set_PartFileAttributes
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
'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 GetFilePartName()
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) - 5)
'strip off the ".prt" extension
strPart = Left(strPart, Len(strPart) - 4)
GetFilePartName = strPart
End Function
'***********************************************************************
'***********************************************************************
Function GetFileCustomerName()
Dim strPath as String
Dim strPart as String
Dim strPart1 as String
Dim strPart2 as String
Dim strPart3 as String
Dim strPart4 as String
Dim pos as Integer
Dim pos1 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)
pos1 = InStrRev(strPart, "\")
strPart1 = Left(strPath, pos1 - 1)
pos2 = InStrRev(strPart1, "\")
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
'***********************************************************************
Function GetFileMould()
Dim strPath as String
Dim strPart as String
Dim strPart1 as String
Dim strPart2 as String
Dim strPart3 as String
Dim pos as Integer
Dim pos1 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)
pos1 = InStrRev(strPart, "\")
strPart1 = Left(strPath, pos1 - 1)
pos2 = InStrRev(strPart1, "\")
strPart2 = Left(strPart, pos2 - 1)
pos3 = InStrRev(strPart2, "\")
strPart3 = Mid(strPart2, pos3 + 1)
'pos4 = InStrRev(strPart3, "\")
'strPart4 = Mid(strPart3, pos4 + 1)
GetFileMould = strPart3
End Function
End Module