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...
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?
Solved! Go to Solution.
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.
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!