cancel
Showing results for 
Search instead for 
Did you mean: 

Journal to open a folder in Windows explorer

Valued Contributor
Valued Contributor

Hi

 

Does anyone have a journal that will open a folder in Windows explorer.

 

Juts looking to bring a standard folder onto the screen so users can drag and drop pieces of text.

 

I would normally use Note command, but the Insert from file option doesn't work in NX9.03 with Teamcenter.

Martyn, Snr CAE Engineer, Renishaw PLC
NX10 Tc10
5 REPLIES

Re: Journal to open a folder in Windows explorer

Siemens Phenom Siemens Phenom
Siemens Phenom

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.Utilities

Module openWindowsExplorer

    Dim theSession As Session = Session.GetSession()

    Sub Main()

        Dim dp As Part = theSession.Parts.Display
        Dim wp As Part = theSession.Parts.Work

        Shell("explorer.exe", AppWinStyle.NormalFocus, False)

        Echo("The program has launched a Windows Explorer window.")

    End Sub

    Sub Echo(ByVal output As String)

        theSession.ListingWindow.Open()
        theSession.ListingWindow.WriteLine(output)
        theSession.LogFile.WriteLine(output)

    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        Return Session.LibraryUnloadOption.Immediately
    End Function

End Module

Re: Journal to open a folder in Windows explorer

Siemens Phenom Siemens Phenom
Siemens Phenom

 

I left out the folder specification - sorry about that.  It is just passed as an argument to the executable:

 

Shell("explorer.exe C:\Temp", AppWinStyle.NormalFocus, False)

 

 

Re: Journal to open a folder in Windows explorer

Valued Contributor
Valued Contributor
Thanks, that's brilliant.

Regards
Martyn
--------------------------------------------------------------------------------------------------
This email and any attachments are confidential and are for the use of the
addressee only. If you are not the addressee, you must not use or disclose the
contents to any other person. Please immediately notify the sender and
delete the email. Statements and opinions expressed here may not
represent those of the company. Email correspondence is monitored by
the company. This information may be subject to export control
regulation. You are obliged to comply with such regulations.

Renishaw plc (company number 1106260) and Wotton Travel Limited (company
number 01973158) are companies registered in England and Wales with a registered office
at New Mills, Wotton-under-Edge, Gloucestershire, GL12 8JR,
United Kingdom, Telephone +44 1453 524524.
--------------------------------------------------------------------------------------------------
Martyn, Snr CAE Engineer, Renishaw PLC
NX10 Tc10

Re: Journal to open a folder in Windows explorer

Experimenter
Experimenter
another way: CreateObject("Wscript.Shell").Run("c:")

Re: Journal to open a folder in Windows explorer

Siemens Pioneer Siemens Pioneer
Siemens Pioneer

hi

this will open current's displayed part's (nx native) win folder.

 

Imports System.IO

Imports System.Environment

Imports NXOpen.UI

Imports NXOpen.Utilities

Imports NXOpen.UF

Module open_folder

Sub Main()

Dim s As Session = Session.GetSession()

Dim theSession As Session = Session.GetSession()

Dim displayPart As Part = theSession.Parts.Display

Dim lw As ListingWindow = s.ListingWindow()

Dim ufs As UFSession = UFSession.GetUFSession()

Dim dispPart_name As String

Dim dispPart As Part = s.Parts.Display

Dim folder_name As String

Dim path As String = folder_name

If displayPart Is Nothing Then

lw.Open()

lw.WriteLine("must be a dispalyed part")

lw.WriteLine("now exit")

lw.WriteLine(" ")

Else

ufs.Part.AskPartName(dispPart.Tag, dispPart_name)

folder_name = Left(dispPart_name, Instrrev(dispPart_name, "\") - 1)

Shell("explorer.exe /e, " & path, vbNormalFocus)

End If

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function

End Module