.NET

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

Closing AutoCAD from VB.NET

461 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
*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 4 (433 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 (424 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 (292 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community