unigraphics file path
unigraphics file path
(OP)
I was wondering if there is any way wo bring the full file path of the location of a ug part file into expressions. I know you can bring the file name into expressions. We have a very defined file structure that has the customer and the project description in our folder system. I am trying to completely automate out title blocks.
I currently have the file, the drawing number, the assembly file, the part description, the creation date, the drawing scale, and the sheet number.
I would like to get the customer and the project description, and possibly the person that designed the part. I know if I can get the file path I can extract the customer and the description from that. Is there any way of doing this?
Also is there any way of bringing in the person that designed the part. I know Unigraphics stores this in the part history.
Any suggestions?
thank you,
Mike
I currently have the file, the drawing number, the assembly file, the part description, the creation date, the drawing scale, and the sheet number.
I would like to get the customer and the project description, and possibly the person that designed the part. I know if I can get the file path I can extract the customer and the description from that. Is there any way of doing this?
Also is there any way of bringing in the person that designed the part. I know Unigraphics stores this in the part history.
Any suggestions?
thank you,
Mike





RE: unigraphics file path
John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:
To an Engineer, the glass is twice as big as it needs to be.
RE: unigraphics file path
"Wildfires are dangerous, hard to control, and economically catastrophic."
Ben Loosli
RE: unigraphics file path
John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:
To an Engineer, the glass is twice as big as it needs to be.
RE: unigraphics file path
( No i am not that person, i am a noob on programming
Regards,
Tomas
RE: unigraphics file path
CODE -->
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()) 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 '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 End ModuleRE: unigraphics file path
Thank you,
RE: unigraphics file path
copy the text from the white box and paste in notepad. Save the text file and replace the extension of the file from ".txt" to ".vb"
Journals are not "intelligent", - you need to run the journal again as soon as there is change in the filename / path etc.
Regards,
Tomas
RE: unigraphics file path
Thank you,
Mike
RE: unigraphics file path
To make sure that the files are always up to date you can modify your save and save as to always run the journal when files are saved.
RE: unigraphics file path
RE: unigraphics file path
The problem is I need to break out part of the file path using the split string and list in expressions. we have our customer and part description in our file path so I was going to use the path to fill in those fields.
RE: unigraphics file path
RE: unigraphics file path
thread561-351996: Split part name as automated text on a drawing
www.nxjournaling.com
RE: unigraphics file path
I used that same method to get the drawing name and number but the part is in a folder that has the description of the part it makes and that is in a folder that has the customer name in it that is what I needed the file path for so I do the same split string to pull that information into those fields on the drawing.
Thank you
RE: unigraphics file path
RE: unigraphics file path
I need:
1. Customer
2. Class and size
3. drawn by - This could be the user on the comp when drawing is started
4. part number - I used ug_askcurrentworkpart() and substring
5. part description - I used ug_askcurrentworkpart and split string and list
6. date drawn - I used StringUpper(dateTimeString("localTime?", True)) and substring
7. file name - I used <W@$SH_PART_NAME>
8. sheet number - I used <W@$SH_SHEET_NUMBER> of <W@$SH_NUMBER_OF_SHEETS>
9. drawing scale - I used <W@$SH_SHEET_SCALE_NUMERATOR>:<W@$SH_SHEET_SCALE_DENOMINATOR>
10. sheet size - I used <W@$SH_SHEET_SIZE><C>
RE: unigraphics file path
Dim user_name As String = System.Environment.ExpandEnvironmentVariables("%username%")
you can parse the string "user_name" to format it as you want and then send it to an attribute.
Mark Benson
Aerodynamic Model Designer
To a Designer, the glass was right on CAD.
RE: unigraphics file path
CODE -->
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 ModuleRE: unigraphics file path
RE: unigraphics file path
http://msdn.microsoft.com/en-us/library/ewdd6aed.a...
For the 2nd question, the answer is "yes". There are several ways to do it, probably the easiest is to use the .Replace string method. This will allow you to substitute an underscore or dash with a space or empty string.
http://www.dotnetperls.com/replace-vbnet
www.nxjournaling.com