# How to get Link Document and Link Instance from a Revit Model Element

**URL:** <https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197>\
**Category:** Revit\
**Tags:** revit, python, dynamo\
**Created:** [January 2, 2019, 12:33pm UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197 "2019-01-02T12:33:56Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![maycon.freitas](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@maycon.freitas](https://forum.dynamobim.com/u/maycon.freitas)\
**Post date:** [January 2, 2019, 12:33pm UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/1 "2019-01-02T12:33:56Z")

</div>

Hi there,

I am trying to use the node “Select Model Element” to select a Revit link Instance, and from it I want to take the Link Document and the Link Instance.

I am wondering if it is possible with python, because I tried to find a node that do this task, but I didnt.

---

<div class="post-metadata">

**Author:** ![MartinSpence](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/martinspence/32/25208_2.png) [@MartinSpence](https://forum.dynamobim.com/u/MartinSpence)\
**Post date:** [January 2, 2019, 3:36pm UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/2 "2019-01-02T15:36:16Z")

</div>

There are several packages that include nodes with this functionality. I usually use the one from archi-lab; GetDocuments I think it’s called.

---

<div class="post-metadata">

**Author:** ![maycon.freitas](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@maycon.freitas](https://forum.dynamobim.com/u/maycon.freitas)\
**Post date:** [January 2, 2019, 4:23pm UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/3 "2019-01-02T16:23:03Z")

</div>

Hi @MartinSpence, thanks for your reply.  
Actually I need a node that retrieves the link document and the link instance just from the model element that I select, not all link files.  
The node GetDocuments that I know retrieves information about all link files of my project.

---

<div class="post-metadata">

**Author:** ![MartinSpence](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/martinspence/32/25208_2.png) [@MartinSpence](https://forum.dynamobim.com/u/MartinSpence)\
**Post date:** [January 2, 2019, 4:59pm UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/4 "2019-01-02T16:59:16Z")

</div>

Aha! Sorry, I misunderstood what you are after then. I don’t know of a node that will return the doc/instance it originates from.

Personally, I’ve never researched if elements in links have this information stored in them, but perhaps it’s out there 🙂. But in that case you’re probably looking at some python scripting.

---

<div class="post-metadata">

**Author:** ![MartinSpence](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/martinspence/32/25208_2.png) [@MartinSpence](https://forum.dynamobim.com/u/MartinSpence)\
**Post date:** [January 2, 2019, 9:38pm UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/5 "2019-01-02T21:38:25Z")

</div>

This is what you mean, isn’t it?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/a/eadd9fcbdf7d45eb3a9e4aeecf428ccbb9a299df.png)

Python script:

```
import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

eleDoc = UnwrapElement(IN[0]).Document

#To get the doc:
OUT = eleDoc

```

Edit: I just read the title again and realized this whasn’t it :-D.

---

<div class="post-metadata">

**Author:** ![Ning\_Zhou](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ning_zhou/32/68283_2.png) [@Ning\_Zhou](https://forum.dynamobim.com/u/Ning_Zhou)\
**Post date:** [August 6, 2019, 8:14am UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/6 "2019-08-06T08:14:00Z")

</div>

seems it will get host document instead of linked one, any easy way to get linked document from linked instance? well, I prefer user actually selecting the link instance for flexibility

---

<div class="post-metadata">

**Author:** ![MartinSpence](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/martinspence/32/25208_2.png) [@MartinSpence](https://forum.dynamobim.com/u/MartinSpence)\
**Post date:** [August 6, 2019, 8:49am UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/7 "2019-08-06T08:49:17Z")

</div>

Hi @Ning_Zhou,

The method show above will yield the document of which the element, in this case a wall, resides. Here’s a [link](https://apidocs.co/apps/revit/2019/9e530d25-61ca-3899-a531-cbcfd994358d.htm) to the property in the API.

If you have your user select the link manually, you can retrieve the document by using the `GetLinkDocument()` method. See [here](https://apidocs.co/apps/revit/2019/6f81c365-15d9-06b8-48ef-df84914fec60.htm) for more info.

Good luck.

Edit:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/2/624b8f522a68c68124fc1a604f5eda0d49d0c095.png)

---

<div class="post-metadata">

**Author:** ![Ning\_Zhou](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ning_zhou/32/68283_2.png) [@Ning\_Zhou](https://forum.dynamobim.com/u/Ning_Zhou)\
**Post date:** [August 6, 2019, 9:07am UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/8 "2019-08-06T09:07:18Z")

</div>

got it, thanks Martin!

---

<div class="post-metadata">

**Author:** ![ruben.romero](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ruben.romero/32/115842_2.png) [@ruben.romero](https://forum.dynamobim.com/u/ruben.romero)\
**Post date:** [August 28, 2021, 12:43pm UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/9 "2021-08-28T12:43:54Z")

</div>

> [@MartinSpence](#):
>
> The method show above will yield the document of which the element, in this case a wall, resides. Here’s a [link](https://apidocs.co/apps/revit/2019/9e530d25-61ca-3899-a531-cbcfd994358d.htm) to the property in the API.

I tried but I got this error:

> Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.  
> Traceback (most recent call last):  
> File “”, line 7, in   
> AttributeError: ‘List[object]’ object has no attribute ‘GetLinkDocument’

---

<div class="post-metadata">

**Author:** ![MartinSpence](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/martinspence/32/25208_2.png) [@MartinSpence](https://forum.dynamobim.com/u/MartinSpence)\
**Post date:** [August 28, 2021, 12:58pm UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/10 "2021-08-28T12:58:22Z")

</div>

If you’re feeding a list, you need to loop through the list, and call the method.

Can elaborate later if needed.

---

<div class="post-metadata">

**Author:** ![chuongmep](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/chuongmep/32/197537_2.png) [@chuongmep](https://forum.dynamobim.com/u/chuongmep)\
**Post date:** [August 28, 2021, 1:59pm UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/11 "2021-08-28T13:59:29Z")

</div>

Problem has resolved in here : [Getting Link Document - Revit - Dynamo (dynamobim.com)](https://forum.dynamobim.com/t/getting-link-document/56475)

---

<div class="post-metadata">

**Author:** ![ruben.romero](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ruben.romero/32/115842_2.png) [@ruben.romero](https://forum.dynamobim.com/u/ruben.romero)\
**Post date:** [August 28, 2021, 4:49pm UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/12 "2021-08-28T16:49:01Z")

</div>

it does not work for a revit link input list though, although I can get all links and documents with a library:

> IronPythonEvaluator.EvaluateIronPythonScript operation failed.  
> Traceback (most recent call last):  
> File “”, line 7, in   
> AttributeError: ‘List[object]’ object has no attribute ‘GetLinkDocument’

---

<div class="post-metadata">

**Author:** ![MartinSpence](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/martinspence/32/25208_2.png) [@MartinSpence](https://forum.dynamobim.com/u/MartinSpence)\
**Post date:** [August 28, 2021, 8:22pm UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/13 "2021-08-28T20:22:25Z")

</div>

Here’s an example:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/6/963f95fd1b3da09a7e1dc5391b797e722e0996a7.png)

```auto
# Enable Python support and load DesignScript library
import clr

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

links = UnwrapElement(IN[0])

output = []

for i in links:
	output.append(i.GetLinkDocument())

# Assign your output to the OUT variable.
OUT = output

```

---

<div class="post-metadata">

**Author:** ![shashank.baganeACM](https://avatars.discourse-cdn.com/v4/letter/s/35a633/32.png) [@shashank.baganeACM](https://forum.dynamobim.com/u/shashank.baganeACM)\
**Post date:** [November 17, 2021, 8:40am UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/14 "2021-11-17T08:40:34Z")

</div>

@MartinSpence I am getting this error. Can you please help me out ?

![link instance type error](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/9/394eaecf406e750e6d7c6d98dbf4dfa5ecace37b.png)

---

<div class="post-metadata">

**Author:** ![MartinSpence](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/martinspence/32/25208_2.png) [@MartinSpence](https://forum.dynamobim.com/u/MartinSpence)\
**Post date:** [November 17, 2021, 8:43am UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/15 "2021-11-17T08:43:24Z")

</div>

Hi @shashank.baganeACM,

The code you are using is expecting a list. If you place a list.create between your two nodes, it should work.

Otherwise you can use this snippet instead:

```auto
import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

eleDoc = UnwrapElement(IN[0]).Document

#To get the doc:
OUT = eleDoc

```

---

<div class="post-metadata">

**Author:** ![joumana95](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@joumana95](https://forum.dynamobim.com/u/joumana95)\
**Post date:** [November 18, 2021, 11:25am UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/16 "2021-11-18T11:25:52Z")

</div>

please could you tell me the difference between link document and link instance?

---

<div class="post-metadata">

**Author:** ![MartinSpence](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/martinspence/32/25208_2.png) [@MartinSpence](https://forum.dynamobim.com/u/MartinSpence)\
**Post date:** [November 19, 2021, 11:01am UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/17 "2021-11-19T11:01:56Z")

</div>

Hi @joumana95 ,

The information you are able to extract from the two elements classes are very different.

You can explore the two API classes via the links below:

Link to the [Document Class](https://apidocs.co/apps/revit/2021.1/f4fb9f58-4933-f84e-8715-3ea73291b27f.htm).

Link to the [LinkInstance Class](https://apidocs.co/apps/revit/2021.1/b343bf81-5ce3-32b3-3549-316466b7e820.htm).

---

<div class="post-metadata">

**Author:** ![joumana95](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@joumana95](https://forum.dynamobim.com/u/joumana95)\
**Post date:** [November 21, 2021, 12:20pm UTC](https://forum.dynamobim.com/t/how-to-get-link-document-and-link-instance-from-a-revit-model-element/30197/18 "2021-11-21T12:20:13Z")

</div>

many thanks
