.NET

Reply
Contributor
bidanshi
Posts: 20
Registered: ‎06-04-2007
Message 1 of 3 (210 Views)
Accepted Solution

Abort drawing open

210 Views, 2 Replies
10-29-2013 01:58 PM

I would like to run some code BEFORE AutoCAD opens a drawing. It's a simple validation routine.  Ideally speaking the sequence would run as follows...

 

  1.  The user opens a drawing in some way (file dialog, windows explorer, sheet set, etc)
  2.  I run my validation routine
  3.  If it passes validation let AutoCAD open it / If it doesn't abort the process.

I can override the OPEN command and substitute my own, but there are a variety of ways to get a dwg open.

 

Does anyone know how to stop or abort opening a drawing consistently? Even if it's not .net?

*Expert Elite*
norman.yuan
Posts: 982
Registered: ‎04-27-2009
Message 2 of 3 (174 Views)

Re: Abort drawing open

10-30-2013 09:08 AM in reply to: bidanshi

If you need to actually run some routine against the drawing to to know if this drawing should be open, this is a kind of "Catch-22": you do not want a drawing to be opened, if it meets some conditions, and you cannt tell if the condistions are met unless you open the drawing.

 

So, I'd say, no, you probably cannot cancel drawing opening process, especially if the routine can only run after the drawiong information will only be available after it is opened.

 

Depending on what exactly you are to achieve, you could handle DocumentCollection event, such as DocumentCreated/DocumentBecameCurrent (the latter of the tow might be safer, in most cases) and have your routine run in this event handler. If the conidtions are met, you can change the just opened document to read-only by calling DowngradeDocOpen() method of the opend document. You can then pop up a message box, just as AutoCAD does to prompt user the drawing is readonly for certain reason.

 

 

Contributor
bidanshi
Posts: 20
Registered: ‎06-04-2007
Message 3 of 3 (164 Views)

Re: Abort drawing open

10-30-2013 03:20 PM in reply to: norman.yuan

It's not something that's in the document. It's kind of complicated, but it boils down to an external database that we use filenames to check against. That said... making the document read only is enough.  So question answered... Thank you!

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 or visit the Installation and Licensing Forum to get help installing your software.