Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

NX Journal filepath

Status
Not open for further replies.

RuudvdBrand

Computer
Aug 6, 2012
34
NL
Dear all,

i have a question about a journal that i have found.
I want to place the file location into a part attribute.

this so i can use this attribute to controle a ug_excel_read expression.
This part is changed from location when there is a save as action been done.

now i can created with the journal the complet filepath but i want to cut off the .prt
how can help me with this.

Below the script.

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


GetFilePath = strPath
End Function


End Module

already thanks

Ruud
 
Replies continue below

Recommended for you

Here are a few functions that may be useful.

Code:
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)

        'remove the last 4 characters of the path
        Dim strPath2 As String = strPath.Substring(0, strPath.Length - 4)
        lw.WriteLine("strPath2: " & strPath2)

        Dim strFile As String = IO.Path.GetFileName(strPath)
        lw.WriteLine("file name with extension: " & strFile)

        Dim strFileNoExt As String = IO.Path.GetFileNameWithoutExtension(strPath)
        lw.WriteLine("file name without extension: " & strFileNoExt)

        Dim strDir As String = IO.Path.GetDirectoryName(strPath)
        lw.WriteLine("strDir: " & strDir)


    End Sub
End Module

www.nxjournaling.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top