Determine if AutoCAD is unresponsive

Determine if AutoCAD is unresponsive

dennis
Advisor Advisor
1,332 Views
7 Replies
Message 1 of 8

Determine if AutoCAD is unresponsive

dennis
Advisor
Advisor

I have built a batch app that launches AutoCAD and "does some stuff".  What I would like to add to the programming is a "catch" should AutoCAD lock up or otherwise become unresponsive after a certain amount of time.  Can someone point me in the right direction?  I am using C Sharp for this particular program, and the 2015 version of AutoCAD.

0 Likes
Accepted solutions (1)
1,333 Views
7 Replies
Replies (7)
Message 2 of 8

Norman_Yuan
Mentor
Mentor

System.Diagnostics.Process has a boolean property "Responding" which you can test is an application's UI is responding or not.

 

I write "UI" in bold and red to emphasize that "responding or not" only indicates the UI status, it DOES not necessarily mean the app is not working. In your case, since you use an external app to automate AutoCAD, it is reasonable that AutoCAD's UI may not be responding but still do its batch work properly as the external app requested. So, I do not think simply counting the time of UI being not responding and then kills AutoCAD process is a good approach. 

 

Rather, for a batch processing, you may consider to use acad's core console/or Autdesk's cloud services for the batch processing, instead of automating heavy-UIed desktop app AutoCAD. Or, forget external app automating AutoCAD and do the batch inside AutoCAD with side database loading/processing.

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 8

SENL1362
Advisor
Advisor
You could also monitor other process params as a sign of "life", like changes in the amount of memory, io etc.
0 Likes
Message 4 of 8

FRFR1426
Collaborator
Collaborator

May be you can use Application.GetAcadState() if you're out-of-process.

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Message 5 of 8

FRFR1426
Collaborator
Collaborator

There is a nice explanation here of the inner working of the responding property: http://stackoverflow.com/a/6781937/200443

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Message 6 of 8

Balaji_Ram
Alumni
Alumni

Hi Dennis,

 

Happy new year to you !

 

There are already great answers in this thread.

 

Just wanted to add that you may also have a look at the ScriptPro 2.0 source code from the Autodesk Exchange Store.

 

I remember that it handles a scenario where AutoCAD does not respond and it needs to restart it.

 

Regards,

 

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 7 of 8

dennis
Advisor
Advisor

Balaji: You got me at "source code", however, on the Exchange App site, when I search for Script Pro, i get nothing.  But did find reference via Google which sent me to a forum that provided a link, and that link goes to the Labs, but then says the page is not found.

0 Likes
Message 8 of 8

Balaji_Ram
Alumni
Alumni
Accepted solution

Sorry, It was my mistake.

 

You can find it here :

 

http://adndevblog.typepad.com/autocad/2012/04/batch-purging-of-drawing-files-using-scriptpro-20.html

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes