ReadToEnd Dim stdLines ( ) As String = stdOutput. StandardError ( ) Dim stdOutput As String = std_out. RedirectStandardError = TrueĬonvertProcess. FileName = "" "" & convertPath & "" "" & unitArg & "" "" & partPath & "" "" Information, "A backup file has been saved to: " & copyPart ) Dim conversionSuccess As Boolean = False Try Dim convertProcess As New Process CopyFile (partPath, copyPart, True ) 'tell user about backup copy WorkPart = Nothing 'UF_UNDO_delete_all_marks End If 'save backup copy to temp folder before conversion Dim tempPath As String = System. WorkPart = Nothing 'UF_UNDO_delete_all_marks End If Else 'just close Dim markId1 As Session. WorkPart = Nothing Else 'just close Dim markId1 As Session. Question, "Save part before closing?" ) If response = 1 Then 'save and close Dim partSaveStatus1 As PartSaveStatus Question, "Convert part to " & targetUnits & " units?" ) '1 = Yes '2 = No If response = 2 Then Return End If If ufs. WriteLine ( "Part has no components, units will be converted" ) End If Dim response As Integer WriteLine ( "Assemblies not supported in this version, journal exiting" ) Return Else GetEnvironmentVariable ( "UGII_ROOT_DIR" ) & "ug_convert_part.exe" 'lw.WriteLine("UGII_ROOT_DIR: " & convertPath) Dim c As ComponentAssembly = workPart. GetRemoteUtilities ( ) Dim convertPath As String = rm. UnitArg = " -mm " End If Dim rm As RemoteUtilities = RemoteUtilities. ToString ) Dim targetUnits As String = "" Dim unitArg As String = "" If workPart. WriteLine ( "current part units: " & workPart. WriteLine ( "part name: " & partName ) 'lw.WriteLine("copy destination: " & copyPart) Information, "This journal only works in native NX" ) Exit Sub End If 'lw.WriteLine("user: " & Environment.UserName) 'lw.WriteLine("part path: " & partPath) IsUgmanagerActive (IsTcEng ) If IsTcEng Then GetTempPath, partName ) Dim lw As ListingWindow = theSession. GetFileName (partPath ) Dim copyPart As String = System. FullPath Dim partName As String = System. GetUFSession Dim theUISession As UI = UI. GetSession ( ) Dim ufs As UFSession = UFSession. Sub Main ( ) Dim theSession As Session = Session.
' '' 'journal to convert the units of the work part, native NX filesystem only 'journal closes the work part and calls ug_convert_part, reports success/failure, and reopens the part ' 'changelog: ' Jbugfix: target units assigned incorrectly Option Strict Off If Teamcenter is detected, a warning message will appear and the journal will exit. It will not work with Teamcenter or other PDM/PLM system that stores your files in a database.
#Ug nx 6 code#
The code operates on the current work part (actually, it works best if the desired part is both the work and displayed part). The code below will use the utility ug_convert_part.exe to do what is perhaps the most common operation: convert the part units of a given part and overwrite the file. But with the power of some journal code, we can tame the CLI program to do our bidding while simultaneously making it user friendly. Even seasoned users tend to be intimidated by CLI programs, especially those used infrequently. The graphical user interface (GUI) has spoiled us. Did you make a typo in the argument list? At best, it will give you an error message and won't run at worst, it will run with an option you didn't intend, possibly overwriting multiple files.
You'll have to type in all the commands you want it to execute, making sure to follow the syntax it expects. It is a command line interface (CLI) program. Suffice it to say that it has all of your part unit conversion needs covered. For those not yet familiar, ug_convert_part.exe will convert the units of a single part, an entire assembly, or an entire directory of parts (with optional sub-directories), overwriting the originals or creating copies in a folder you specify. Have you ever needed to convert the units (inches to millimeters or vice versa) of the part you are working on? If so, you probably already know about the utility program, ug_convert_part.exe.