Revit API

Reply
Contributor
leslief
Posts: 13
Registered: ‎12-05-2012
Message 1 of 3 (278 Views)
Accepted Solution

External Application non-modifiable document

278 Views, 2 Replies
12-05-2012 06:22 AM

I'm working with a DocumentChanged event in the ExternalApplication class.  I cannot figure out how to get the document that is passed to my DocumentChanged event to be modifiable.  Is it possible?  

 

My DocumentChanged event works fine when I trigger it from an IExternalCommand, so I think the main issue is the non-modifiable document passed from the External App.  Any help is appreciated!

Employee
arnostlobel
Posts: 133
Registered: ‎05-20-2011
Message 2 of 3 (264 Views)

Re: External Application non-modifiable document

12-06-2012 02:08 PM in reply to: leslief

Actually, the document for which a DocumentChanged event is raised is never modifiable. Other documents (if there are other documents currently open) may be modifiable depending on their respective state, but the actual document in which the change was just made is always set to be read-only for the entire duration of the DocumentChanged event. This is completely intentional. The are several reasons, in fact. For one, if the change was a result of a completed transaction, the transaction has already been finalized and would not accept any other changes. That is the most common case of all. Or, if the event was raised as a result of undoing or redoing of transactions, the document is out of a transaction at that moment and therefore immutable. Furthermore, since creating new transactions while undoing or redoing cannot be allowed, the document must be set read-only.

 

As a general rule, the DocumentChanged was not designed for the scenarios in which a document gets modified as a result of some other changes happening in that very same document. In such scenarios, the Dynamic Updaters are the right tool to be utilized.

 

By the way, you cannot trigger the event from your External Command. Only Revit can trigger it, since the Revit Application is the event’s originator and sender. You can invoke your handler for that event, but that is not the same. When you invoke the handler explicitly, the document will have the state you are currently in, therefore it is perfectly expectable it would be modifiable if you are invoking it from an external command and you happen being in  in a transaction at that moment (either automatic or manual).

 

Thank you

 

Arnošt Löbel

Autodesk Revit R&D

Arnošt Löbel
Sr. Principal Engineer
Autodesk, Revit R&D
Contributor
leslief
Posts: 13
Registered: ‎12-05-2012
Message 3 of 3 (252 Views)

Re: External Application non-modifiable document

12-07-2012 06:40 AM in reply to: arnostlobel

This is great!  Thank you, Arnošt. 

 

I hadn't yet discovered the Dynamic Updaters, but after reading your post I looked them up, and it seems to be what I need instead of the DocumentChanged event.  

 

For anyone else looking for this info, it's under IUpdater in the API, and here:

    wiki

http://wikihelp.autodesk.com/Revit/enu/2013/Help/00006-API_Developer%27s_Guide/0135-Advanced135/0152...

    webcast

http://au.autodesk.com/?nd=class&session_id=6843

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

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 to get help installing your software.

Ask the Community


Revit Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Revit helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Revit

Twitter

Facebook

Blogs

Youtube