Message 1 of 14
How to determine when a document is completely loaded
Not applicable
05-18-2010
08:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
After several days of navigating the Object ARX .NET API documentation, I have yet to find a "good" way to determine when a document that is opened via Application.DocumentManager.Open() has been completely loaded. I was a bit surprised to find that there is no event for a Document object that will be fired once the document is completely loaded
In my case, I need to update custom properties and automatically save the document (which I am currently doing by running the "QSAVE" command). My custom command is running in "Session" mode (CommandFlags.Session), because it must open a new document and then make changes to this new document. This is my first ObjectArx app, so I have no idea if DocumentCollection.Open() is usually executed asynchronously or if it is only because my command is running in session mode.
I originally attempted to implement this functionality by handling the Application.DocumentManager.DocumentCreated event. However, when attempting to execute a command for an opening/loading document at this phase, the ObjectARX API throws an exception. I later decided to go outside the .NET wrapper API and take a look directly at the COM-interop assembly, where I came across the AcadApplication.EndOpen event. It turns out that I can both populate custom properties and save a document when this event is triggered. However, this event does not provide a document object in its Event arguments, only the path to the drawing. Since the same drawing can be opened multiple times, how do you narrow this down to an individual document?
I am hoping that someone can provide a better solution, or suggestion, for determining when a drawing has been completely loaded, and how to also retrieve the Document object (either from the managed wrapper API or Interop API) that corresponds to the drawing that was opened.
In my case, I need to update custom properties and automatically save the document (which I am currently doing by running the "QSAVE" command). My custom command is running in "Session" mode (CommandFlags.Session), because it must open a new document and then make changes to this new document. This is my first ObjectArx app, so I have no idea if DocumentCollection.Open() is usually executed asynchronously or if it is only because my command is running in session mode.
I originally attempted to implement this functionality by handling the Application.DocumentManager.DocumentCreated event. However, when attempting to execute a command for an opening/loading document at this phase, the ObjectARX API throws an exception. I later decided to go outside the .NET wrapper API and take a look directly at the COM-interop assembly, where I came across the AcadApplication.EndOpen event. It turns out that I can both populate custom properties and save a document when this event is triggered. However, this event does not provide a document object in its Event arguments, only the path to the drawing. Since the same drawing can be opened multiple times, how do you narrow this down to an individual document?
I am hoping that someone can provide a better solution, or suggestion, for determining when a drawing has been completely loaded, and how to also retrieve the Document object (either from the managed wrapper API or Interop API) that corresponds to the drawing that was opened.