.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Closing AutoCAD from VB.NET

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
2403 Views, 3 Replies

Closing AutoCAD from VB.NET

I am using VB.NET 2010 and AutoCAD OEM 2014 (though for Development I use regular AutoCAD 2014).  I run Visual Studio, and it opens AutoCAD automatically.  Then I NETLOAD my app, which opens a new vb.net form.  Then my user can draw different entitites onto the AutoCAD pallette.

 

Of course it's easy to close the VB form, but how can I close the full AutoCAD program programatically from my VB form?  I've tried AcadApp.Quit() from my VB form but it does nothing.

 

The reason that this is important not to leave it to the user to close it is that I check for a valid license from VB, and if there is none, I don't want the user to be able to continue to use AutoCAD.

 

Also, what/where is the reference manual to find examples of using VB.NET and AutoCAD?

 

thanks in advance!

Mitch

3 REPLIES 3
Message 2 of 4
Hallex
in reply to: Anonymous

Handle Form_Closing event either for modal or modeless form:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Autodesk.AutoCAD.ApplicationServices.Application.Quit();
}
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 4
Anonymous
in reply to: Hallex

That will probably work 99% of the time except if autocad is stuck on some command. I think Environment.Exit(0) will "brute force" close it no matter what.
Message 4 of 4
Anonymous
in reply to: Anonymous

Environment.Exit(0)  seems to work nicely, and I like the 'brute force' approach since the user no longer has valid use of the program if it reaches this point.  Thanks very much!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost