In this guide we will take a look at how to work with Revit Documents and Links using Grasshopper inside Revit.

Querying Open Documents

Use the Open Documents component to query the documents that are open in Revit:

The Active Document component always refers to the currently active document. Be aware that when you switch documents in Revit interface, the output of the component will be updated to reflect the newly activated document:

Note that the document components show the target document on the label at the bottom of the component

Use the Document Identity+ v1.0 to grab the identify information from the active document:

Document-Aware Components

Document-Aware components, can work on active or given documents. They have a hidden Document input parameter that can be added by zooming in into the component:

Once this input parameter is added, any Revit document can be passed into this input:

Here is another example of collecting wall instances from multiple source documents:

Document Properties

Use the Document File+ v1.0 component to inspect the file properties of the given document:

Use the Document Worksharing+ v1.0 to inspect the work-sharing properties of the given document:

Saving Documents

Use the Save Document component, to save the given documents into an output file. The output file is passed to the component as a path string. Make sure that the path is ending with the appropriate file extension for the given document:

Querying Linked Documents

When Revit loads a model, it also loads all the linked models into the memory as well. Each Revit model is represented by an instance of DB.Document. The DB.Document.IsLinked shows whether the document has been loaded as a link for another document. Revit can not open two instances of the same model in a Revit session. This is the primary reason that you can not edit a linked model, without unloading it from the host model first

Use the Query Revit Links+ v1.0 component shown here to get all the documents that are linked into the active (or given) document

Querying Linked Elements

Use the Query Elements component shown here to access elements if a given document. The input document can be a linked document as well.

You can chain the Open Documents component into the Query Revit Links+ v1.0 component to grab all the linked documents from all the open documents: