.NET

Reply
Mentor
415 Posts
0 Kudos
Registered: ‎09-23-2004
Post 1 of 7
Accepted Solution

Programmatically Exiting AutoCad

455 Views, 6 Replies
01-18-2013 08:16 AM

I'm trying to update an existing program so that people can run it in a batch mode kind of way.  I want the code to run, then when the drawing is complete, the program will save the drawing and then exit AutoCad.

 

Is there a way to do this?  If so, how?

 

Thanks,

Mark

Hi,

 

>> So there's no way it can be added to the end of a .NET program?

I don't know what part of your program is dotNET now.
You start AutoCAD via batch file (at least I think so when looking to how you start AutoCAD). And you start AutoCAD with a script. Where is the part you have dotNET active?

 

If your AutoCAD script loads a dotNET-DLL then of course, you can quit the running application using SendCommand, or using COM-interface

   Autodesk.AutoCAD.Interop.IAcadApplication ==> .Quit

or using the managed part of the API

   Autodesk.AutoCAD.ApplicationServices.Application ==> .Quit

 

- alfred -

*Expert Elite*
9,832 Posts
1,218 Kudos
Registered: ‎06-29-2007
Post 2 of 7

Re: Programmatically Exiting AutoCad

01-18-2013 08:34 AM in reply to: mgorecki

Hi,

 

are you just starting a process with the Processes-functionality or did you use COM to start AutoCAD?

Show us how you are connected to AutoCAD as the answer might be different depending on how you opened AutoCAD.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Mentor
415 Posts
0 Kudos
Registered: ‎09-23-2004
Post 3 of 7

Re: Programmatically Exiting AutoCad

01-18-2013 08:49 AM in reply to: Alfred.NESWADBA

Hello Alfred,

Here is the command we use:

"C:\Program Files\AutoCAD 2010\acad.exe" /b "C:\Support\PackageOutline\403142PO.scr"

 

It launches AutoCad and immediately executes a script file that launches either a Lisp program or a .Net program.  The script also feeds it info for the program to launch.

 

Thanks,

Mark

*Expert Elite*
9,832 Posts
1,218 Kudos
Registered: ‎06-29-2007
Post 4 of 7

Re: Programmatically Exiting AutoCad

01-18-2013 09:14 AM in reply to: mgorecki

Hi,

 

ok, then - on the end of your script - use the _QUIT command

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Mentor
415 Posts
0 Kudos
Registered: ‎09-23-2004
Post 5 of 7

Re: Programmatically Exiting AutoCad

01-18-2013 09:48 AM in reply to: Alfred.NESWADBA

Thanks, I tried that in a test script and it worked great.

In LiSP I was able to add the save command followed by the command to quit and it worked.  So there's no way it can be added to the end of a .NET program? 

*Expert Elite*
9,832 Posts
1,218 Kudos
Registered: ‎06-29-2007
Post 6 of 7

Re: Programmatically Exiting AutoCad

01-18-2013 10:50 AM in reply to: mgorecki

Hi,

 

>> So there's no way it can be added to the end of a .NET program?

I don't know what part of your program is dotNET now.
You start AutoCAD via batch file (at least I think so when looking to how you start AutoCAD). And you start AutoCAD with a script. Where is the part you have dotNET active?

 

If your AutoCAD script loads a dotNET-DLL then of course, you can quit the running application using SendCommand, or using COM-interface

   Autodesk.AutoCAD.Interop.IAcadApplication ==> .Quit

or using the managed part of the API

   Autodesk.AutoCAD.ApplicationServices.Application ==> .Quit

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Mentor
415 Posts
0 Kudos
Registered: ‎09-23-2004
Post 7 of 7

Re: Programmatically Exiting AutoCad

01-18-2013 10:59 AM in reply to: Alfred.NESWADBA

Alfred, thank you very much.  I'm goimng to go with the _quit in the script file.  That way regardless of which program (LiSP or .Net) that runs, the script will save and quit out of AutoCad without me having to update either of the programs.

 

Best regards,

Mark

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!