.NET

Reply
Contributor
BugWare
Posts: 13
Registered: ‎04-17-2012
Message 1 of 4 (557 Views)
Accepted Solution

Closing AutoCAD from VB.NET

557 Views, 3 Replies
01-31-2014 12:22 PM

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

Micropaleontology
Oil Industry
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.
*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 4 (529 Views)

Re: Closing AutoCAD from VB.NET

02-01-2014 03:14 AM in reply to: BugWare
Handle Form_Closing event either for modal or modeless form:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Autodesk.AutoCAD.ApplicationServices.Application.Quit();
}
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 3 of 4 (520 Views)

Re: Closing AutoCAD from VB.NET

02-01-2014 06:43 AM 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.
Contributor
BugWare
Posts: 13
Registered: ‎04-17-2012
Message 4 of 4 (388 Views)

Re: Closing AutoCAD from VB.NET

02-20-2014 06:29 AM in reply to: BugWare

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!

Micropaleontology
Oil Industry
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!