Author Topic: Preventing Quit and or Document closing.  (Read 2106 times)

0 Members and 1 Guest are viewing this topic.

GUIDO ROOMS

  • Guest
Preventing Quit and or Document closing.
« on: August 08, 2012, 09:30:48 AM »
I can't find how to prevent AutoCAD from quitting or closing documents.
For the moment I'm using the com event AcadApplication.BeginQuit, which has a Cancel parameter, but I'd like to use the
.net api for doing this.
I've checked arxdoc, but this doesn't make me much wiser.
Thanks in advance for any help on this.

kaefer

  • Guest
Re: Preventing Quit and or Document closing.
« Reply #1 on: August 08, 2012, 10:00:06 AM »
I can't find how to prevent AutoCAD from quitting or closing documents.

The Document.BeginDocumentClose event appears to do this for documents.

From arxmgd.chm:
Quote
Implementers can call DocumentBeginCloseEventArgs.Veto() during this notification to stop AutoCAD from shutting down the document.

GUIDO ROOMS

  • Guest
Re: Preventing Quit and or Document closing.
« Reply #2 on: August 08, 2012, 10:55:55 AM »
Also from ArxDoc, about the BeginQuit event:

Quote
Wraps the AcEditorReactor.beginQuit() ObjectARX function, which is called when AutoCAD starts to shutdown. The method allows a veto() that will cancel the shutdown.

Problem is, the vetoing, wouldn't know how to do that.
System.EventArgs have no Veto() method. At least, I can't see it. :kewl:

This is from the object browser:

Quote
Public Shared Event BeginQuit(sender As Object, e As System.EventArgs)
     Member of Autodesk.AutoCAD.ApplicationServices.Application.

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Preventing Quit and or Document closing.
« Reply #3 on: August 08, 2012, 11:07:46 AM »
You should be implementing with a DocumentBeginCloseEventArgs like this:

Code: [Select]
private void OnBeginDocumentClose(object sender, DocumentBeginCloseEventArgs args)
        {
            args.Veto();
        }
Revit 2019, AMEP 2019 64bit Win 10

GUIDO ROOMS

  • Guest
Re: Preventing Quit and or Document closing.
« Reply #4 on: August 08, 2012, 12:04:38 PM »
Thanks MexicanCustard (sorry, that's what you're calling yourself ;-)),

But ah, what about vetoing BeginQuit?
I'd like to prevent AutoCAD quitting without using com events...

kaefer

  • Guest
Re: Preventing Quit and or Document closing.
« Reply #5 on: August 08, 2012, 12:13:58 PM »
But ah, what about vetoing BeginQuit?

That's simply not implemented. As you have already noticed, it would've been necessary to implement a class derived from System.EventArgs to make any additional members accessible. I suppose that's just another stale reference to the original arxref documentation.

GUIDO ROOMS

  • Guest
Re: Preventing Quit and or Document closing.
« Reply #6 on: August 08, 2012, 12:27:13 PM »

Quote
I suppose that's just another stale reference to the original arxref documentation.

Thanks kaefer.
That documentation stinks.
I'll go on using com for this.