×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NX Journal filepath

NX Journal filepath

NX Journal filepath

(OP)
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

RE: NX Journal filepath

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources