Changing the folder destination HELP!!!!
Changing the folder destination HELP!!!!
(OP)
In this piece of code the output file goes to the folder where the .prt file is located.
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim outputPath As String = IO.Path.GetDirectoryName(workPart.FullPath)
Dim outputFile As String = IO.Path.GetFileNameWithoutExtension(workPart.FullPath)
outputFile = IO.Path.Combine(outputPath, outputFile & "MatingSurf")
I have been trying to do two things with no luck.
First, instead of the same folder I need to go back to a certain folder in the root folder.
N:\CAD Data\DATA\dwr12324\Step Data Release\Release CAD Is where the .prt file is located
N:\CAD Data\DATA\dwr12324\Step Data Release\Mating Surfaces Is where the .prt file is located
In excel I know that I can use the left string to rename the folder detestation but it seems not to work with UG.
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim outputPath As String = IO.Path.GetDirectoryName(workPart.FullPath)
Dim outputFile As String = IO.Path.GetFileNameWithoutExtension(workPart.FullPath)
outputFile = IO.Path.Combine(outputPath, outputFile & "MatingSurf")
I have been trying to do two things with no luck.
First, instead of the same folder I need to go back to a certain folder in the root folder.
N:\CAD Data\DATA\dwr12324\Step Data Release\Release CAD Is where the .prt file is located
N:\CAD Data\DATA\dwr12324\Step Data Release\Mating Surfaces Is where the .prt file is located
In excel I know that I can use the left string to rename the folder detestation but it seems not to work with UG.





RE: Changing the folder destination HELP!!!!
CODE
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim ufs As UFSession = UFSession.GetUFSession() Dim workPart As Part = theSession.Parts.Work '************************************* 'Get parent directory with string manipulation commands Dim parentDir As String parentDir = IO.Path.GetDirectoryName(workPart.FullPath) parentDir = parentDir.Substring(0, parentDir.Length - (parentDir.Length - parentDir.LastIndexOf("\"))) MsgBox("parentDir: " & parentDir) '************************************* '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 'Get parent directory with IO commands Dim directoryInfo As System.IO.DirectoryInfo directoryInfo = System.IO.Directory.GetParent(IO.Path.GetDirectoryName(workPart.FullPath)) '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 'change "temp" to the directory name of your choosing Dim outputPath As String = IO.Path.Combine(directoryInfo.FullName, "temp") If Not IO.Directory.Exists(outputPath) Then 'code to create directory here, if desired... MsgBox("The specified directory:" & ControlChars.CrLf & outputPath & ControlChars.CrLf & _ "does not exist. Please create the directory and re-run the journal") Return End If Dim outputFile As String = IO.Path.GetFileNameWithoutExtension(workPart.FullPath) outputFile = IO.Path.Combine(outputPath, outputFile & "MatingSurf") ufs.Disp.CreateImage(outputFile, UFDisp.ImageFormat.Jpeg, UFDisp.BackgroundColor.White) End Sub Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image when the NX session terminates GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination End Function End Modulewww.nxjournaling.com
RE: Changing the folder destination HELP!!!!
RE: Changing the folder destination HELP!!!!
Here is a link to some examples:
http://msdn.microsoft.com/en-us/library/aa903372%2...
www.nxjournaling.com