# Retrieve units from links

**URL:** <https://forum.dynamobim.com/t/retrieve-units-from-links/97848>\
**Category:** Revit\
**Tags:** dynamo, units, link\
**Created:** [February 6, 2024, 3:17pm UTC](https://forum.dynamobim.com/t/retrieve-units-from-links/97848 "2024-02-06T15:17:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![acastillo.cafte](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@acastillo.cafte](https://forum.dynamobim.com/u/acastillo.cafte)\
**Post date:** [February 6, 2024, 3:17pm UTC](https://forum.dynamobim.com/t/retrieve-units-from-links/97848/1 "2024-02-06T15:17:27Z")

</div>

Hi all

I’m trying to retrieve the units in use in the linked documents. I will like to use a federated RVT model with several links (up to 20 in some cases) to do some basic fast check before the submissions to the client.  
The requirement is to submit the model in “Meter” units for “Length”. I’m trying with the GeniusLoci “Document Units” custom node, feeding with Link Doc and Link Instance with no luck.  
I know that some of the links are in centimetres or inches (I’ve edited them for testing purpose) but the result is always Meters.

 ![imagen](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/8/981c0c29835a4b56cb05ade0e6ac2702f72aba5e.png)

Is there other way to show this information in dynamo?

Kind regards

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [February 7, 2024, 1:35am UTC](https://forum.dynamobim.com/t/retrieve-units-from-links/97848/2 "2024-02-07T01:35:34Z")

</div>

Here’s some python to achieve what you are after

```python
import sys

import clr

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import FilteredElementCollector, RevitLinkInstance, SpecTypeId, UnitUtils

doc = DocumentManager.Instance.CurrentDBDocument

revit_links = FilteredElementCollector(doc).OfClass(RevitLinkInstance)
length = SpecTypeId.Length

# Helper function
def get_unit_type(link, spec):
    link_doc = link.GetLinkDocument()
    units = link_doc.GetUnits()
    unit = units.GetFormatOptions(spec).GetUnitTypeId()
    return link_doc.Title, UnitUtils.GetTypeCatalogStringForUnit(unit)

OUT = [get_unit_type(link, length) for link in revit_links]

```

Also check your list level on the _Document Units_ node  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/c/3c8f570d4d859df6dd98051853a8c1e0bdd9a95f.png)

 ![link_doc_units_2024-02-07_09-32-01](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/7/57a7e98553393746f4f8c79ec232870a1f99bda4.png)

---

<div class="post-metadata">

**Author:** ![acastillo.cafte](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@acastillo.cafte](https://forum.dynamobim.com/u/acastillo.cafte)\
**Post date:** [February 7, 2024, 8:10am UTC](https://forum.dynamobim.com/t/retrieve-units-from-links/97848/3 "2024-02-07T08:10:07Z")

</div>

Hi Mike.Buttery  
The python script you provided works flawless.  
The addition of the document name is also a great touch (I’m hiding it for safety reasons):

 ![imagen](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/d/9d37e57a76feef4cd5e518e3d096b3edf3fd4686.png)

I’ve checked the levels in the Document Units node but the result is the same as before, it shows the units of the active document and not the links as in the script you provided:

 ![imagen](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/c/bc48ff27037f274446f30f9b45355ef0c62e9cc0.png)

Thank you Mike for your help! It will save me lots of hours of open-check-close models.
