Showing results for 
Search instead for 
Did you mean: 

To code for "Execute" in NX 10.0



Can I execute exe file using CTRL+U programmatically and browse .exe file in NX 7.5 and NX 10.0 using or C++ ?

Your help would be appreciable!






Re: To code for "Execute" in NX 10.0

Ken_A 1st Gear
1st Gear

Not really.

NX API code *to be run from an NX session* has to be a DLL.

You can have external API programs that run, but don't interact with a session.

You can "remote" into NX from a separate EXE, but NX has to be running - there are examples (search this forum for remoting)

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
Apparently I've turned into a gearhead

Re: To code for "Execute" in NX 10.0

cowski1 3rd Gear
3rd Gear

In you can use the System.Diagnostics.Process.Start method. The journal below opens windows explorer. I'm sure there is a similar strategy for C++.


Option Strict Off
Imports System
Imports NXOpen

Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        If IsNothing(theSession.Parts.Work) Then
            'active part required
        End If

        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow

        Dim myFolder As String
        ' change the "myFolder" variable to point to your folder of choice
        myFolder = My.Computer.FileSystem.SpecialDirectories.MyDocuments
        'myFolder = "C:\Temp"
        'myFolder = "C:\path\to\your\folder"


            System.Diagnostics.Process.Start("explorer.exe", myFolder)

        Catch ex As Exception


        End Try


    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 Module


Edit: After reading Ken's post, I realize that I may have misunderstood the question. The above code will open an .exe file from NX, but not one that interacts with the NX session.

Re: To code for "Execute" in NX 10.0

Siemens Phenom Siemens Phenom
Siemens Phenom

Ken's comment is correct if the program is written in C or C++.


But for programs written in NXOpen VB.Net or C#.Net, you can run an executable (.exe) using File -> Execute -> NX Open, within an interactive NX session, and it will run in the context of the interactive session, not as a separate forked process, just as if you were running a .DLL.


I know, weird, huh?  But that is how it works.  8-)

Re: To code for "Execute" in NX 10.0

Siemens Phenom Siemens Phenom
Siemens Phenom

> I know, weird, huh?  But that is how it works


It's because, in the .NET world, there is very little difference between a DLL file and an EXE file. In .NET jargon, both are these are considered to be an "assembly". Some further explanation here.