.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Abort drawing open

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
bidanshi
1519 Views, 2 Replies

Abort drawing open

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?

Tags (4)
2 REPLIES 2
Message 2 of 3
norman.yuan
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.

 

 

Message 3 of 3
bidanshi
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!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost