Difference between CurrentDBDocument , CurrentUIApplication & CurrentUIDocument

Hi ,

what the use of the below methods from DocumentManager class in RevitServices.Persistence Namespace
1)CurrentDBDocument
2)CurrentUIApplication
3)CurrentUIDocument
as far as i know the current DB document selects the open Revit file(correct me if i am wrong)
what about other 2 methods how can i use them ?

thank you

Hi @vamsi736,

These are just quick access to some useful objects in the Revit API. Here is a quick breakdown of what each is responsible for:-

  • CurrentDBDocument - This gives you access to the current Revit Document (revit file if you will), this is most likely what you will use most of the time as this is where all the things in the Document are stored (Element, sheets, views etc etc). When you are doing any CRUD (create, read/query, update, delete) operations, this is what you will need.

  • CurrentUIApplication - This gives you access to the current Revit Application UI (So Application Level UI Operations). You won’t need this that much as a Dynamo User, but it is useful if you want to Post Commands (not recommended - but possible as a last resort), subscribe to events or you want access to the Application Object which gives you further access to Application Wide operations such as opening documents, getting all open documents and other application level methods/properties/events. You will find yourself using the Application Class a little bit, but not nearly as much as the Document Class.

  • CurrentUIDocument - Again, you won’t need this that much, at least not as a Dynamo user, but this gives you access to the Document Level UI Operations (so UI operations that are only available in the context of an open document), a common operation is to Refresh the ActiveView to force a redraw of the view, get all Open Views of that Document or do a Save.

You can get to the current Document one way or another from any of the above. Similarly, you can get to the Application from any of these which further allows you to get to other opened documents and other cool things.

Hope that helps, and do click on the blue links as they will open the RevitAPIDocs where you can explore what each Class does/can do and what you can do with them. I thoroughly recommend browsing through these docs if you are interested in learning the Revit API (either with python or C#).

Cheers,
Dan

5 Likes

CurrentUIDocument - Again, you won’t need this that much, at least not as a Dynamo user, but this gives you access to the Document Level UI Operations (so UI operations that are only available in the context of an open document), a common operation is to Refresh the ActiveView to force a redraw of the view, get all Open Views of that Document or do a Save.

…and accesso to all Selections :wink:

1 Like