Can I execute exe file using CTRL+U programmatically and browse .exe file in NX 7.5 and NX 10.0 using VB.net or C++ ?
Your help would be appreciable!
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)
Production: NX10.0.3.5 MP16/TC11.2
I'd rather be e-steamed than e-diseaseled
In VB.net 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 Return End If Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() 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" Try System.Diagnostics.Process.Start("explorer.exe", myFolder) Catch ex As Exception MsgBox(ex.Message) Finally End Try lw.Close() 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.
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-)
> 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.