Hello all,
i'm just working with NX journals. I have a part that uses ug_excel_read.
now i want to create an attribute that looks to the file location of the part.
I have already created this part, also that it cuts off the .prt extension.
but now is the thing that i want to add the extions .xlsx.
does anyone knows how to do this or if it is possible or a other way to program this.
here is the journal file:
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())
Dim user_name As String = System.Environment.ExpandEnvironmentVariables("%username%")
workPart.SetAttribute("Name", user_name)
End Sub
'***********************************************************************
Function GetFilePath()
Dim strPath as String
Dim strPart as String
Dim pos as Integer
'get the full file path
strPath = displayPart.fullpath
'remove the last 4 characters of the path
Dim strPath2 As String = strPath.Substring(0, strPath.Length - 4)
GetFilePath = strPath2
End Function
End Module
Ruud van den Brand
re: change extension
The .net framework has just the function for you: IO.Path.ChangeExtension
Option Strict Off
Imports System
Imports NXOpen
Module Module41
Sub Main()
Dim theSession As Session = Session.GetSession
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
Dim strPath As String = theSession.Parts.Work.FullPath
lw.WriteLine("strPath: " & strPath)
strPath = IO.Path.ChangeExtension(strPath, ".xlsx")
lw.WriteLine("path with .xlsx extension: " & strPath)
End Sub
End Module