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 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.

The links output contains the document name, Location, Shared Location Name and the unique instance ID for that link.

The documents output contains the name of the linked document and can be used in the document input of the query components.

Querying Linked Elements

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

When the Query Elements component is used to find elements in linked models, will import in their base orientation as they sit in the linked model. Linked elements then must be oriented to the location of the link instance in the host project. See the Linked Geometry Orientation below.

Linked Geometry Orientation

The graphic elements will come into the file as they are oriented in their base project. It is necessary to orient the geometry into the location of the link instance. Use the Orient Component for this: