cancel
Showing results for 
Search instead for 
Did you mean: 

Exiting the NX Open application

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Hello everyone!

 

How can I exit the C# NX Open application? I tried using the System.Environment.Exit(0) - but it shuts down NX altogether. Oops! How can I exit the application, but keep NX running?

15 REPLIES

Re: Exiting the NX Open application

Esteemed Contributor
Esteemed Contributor

In regular C it is just "return"

 

Record a C# journal & see what it does.

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: Exiting the NX Open application

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

I don't understand how can I record this. I know how to uload application when it finishes working in a regular way. What I need is to force terminate and close the application in the middle of the code upon catching a certain exception.

Re: Exiting the NX Open application

Phenom
Phenom

You need to exit from your main function/subroutine that gets called when your program starts. For most journals this is the "Main" function/sub. To exit early (before the end of the main function/sub) use the "Return" keyword. Something like below:

 

 

Sub Main()

    'do work

    'uh oh error!
If error then
Return
End If End Sub

 

If you catch the error in a sub function/routine, you will need to bubble it up to the main routine so you can exit correctly.

Re: Exiting the NX Open application

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Thank you once again, cowski! It seems to be working now!

Or, to be more correct, NOT working - what is exactly what's needed! Smiley Very Happy

Re: Exiting the NX Open application

Esteemed Contributor
Esteemed Contributor

If your application is running in an interactive NX session, you do not exit the application, it will just end.

Did you use the templates shipping with NX to create NXOpen applications?

Do you have an unload function added as contained in the templates?

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Exiting the NX Open application

Solution Partner Genius Solution Partner Genius
Solution Partner Genius
Hello! I have found the solution already. The problem was not to simply stop an application, but to force-stop it upon hitting a condition (in my case, catching an exception). I have found the way to do it.

Re: Exiting the NX Open application

Esteemed Contributor
Esteemed Contributor

So you use Exit Sub for a Sub and Return for a Function?

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Exiting the NX Open application

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Basically, yes. Although I use C# and thus I use Return command. The application catches an exception, exits the method, then the Main program and unloads itself in a regular way.

Re: Exiting the NX Open application

Phenom
Phenom

Return also works to exit a subroutine (in VB, at least).