# Get Revit.DB.Reference from a grid

**URL:** <https://forum.dynamobim.com/t/get-revit-db-reference-from-a-grid/24506>\
**Category:** Developers\
**Created:** [August 6, 2018, 10:23am UTC](https://forum.dynamobim.com/t/get-revit-db-reference-from-a-grid/24506 "2018-08-06T10:23:25Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Wintour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paul_wintour/32/9381_2.png) [@Paul\_Wintour](https://forum.dynamobim.com/u/Paul_Wintour)\
**Post date:** [August 6, 2018, 10:23am UTC](https://forum.dynamobim.com/t/get-revit-db-reference-from-a-grid/24506/1 "2018-08-06T10:23:25Z")

</div>

Does anyone know how to get the Revit.DB.Reference from a grid?

I’m using the [NewDimension](http://www.revitapidocs.com/2018.1/47b3977d-da93-e1a4-8bfa-f23a29e5c4c1.htm) method which quires an array of geometric references to which the dimension is to be bound. But the grid does not seem to have any such geometric reference. According to this [post](http://thebuildingcoder.typepad.com/blog/2015/05/how-to-retrieve-dimensioning-references.html#3), I need to include non visible geometry. But I’m not sure how that is done. Any thoughts?

> **[How to Retrieve Dimensioning References](https://thebuildingcoder.typepad.com/blog/2015/05/how-to-retrieve-dimensioning-references.html)**
>
> Several cases recently came up asking how to obtain references to programmatically create dimensioning elements. These hints expand on the recently discussed topic of creating dimensioning between family instance insertion points. They were raised by...

---

<div class="post-metadata">

**Author:** ![m.rijsmus](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@m.rijsmus](https://forum.dynamobim.com/u/m.rijsmus)\
**Post date:** [August 6, 2018, 11:43am UTC](https://forum.dynamobim.com/t/get-revit-db-reference-from-a-grid/24506/2 "2018-08-06T11:43:30Z")

</div>

@Paul_Wintour

Maybe this helps

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/4/8433eeef5f7f0fd7a1ede9bfa8606bdeddcc026d.png)

Springs Package

---

<div class="post-metadata">

**Author:** ![Paul\_Wintour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paul_wintour/32/9381_2.png) [@Paul\_Wintour](https://forum.dynamobim.com/u/Paul_Wintour)\
**Post date:** [August 7, 2018, 9:28am UTC](https://forum.dynamobim.com/t/get-revit-db-reference-from-a-grid/24506/3 "2018-08-07T09:28:04Z")

</div>

Doesn’t seem to work on grids…

@Dimitar_Venkov any thoughts?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/a/8a11ea1ec1886731c6fc2a1af92e56c14164ca89.jpg)

---

<div class="post-metadata">

**Author:** ![m.rijsmus](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@m.rijsmus](https://forum.dynamobim.com/u/m.rijsmus)\
**Post date:** [August 7, 2018, 9:36am UTC](https://forum.dynamobim.com/t/get-revit-db-reference-from-a-grid/24506/4 "2018-08-07T09:36:01Z")

</div>

If its just Grids you can use  
[Maatvoering Stramienen.dyn](https://forum.dynamobim.com/uploads/short-url/zytqF8npl2nWnuJtECGd1KJsDFk) (62.3 KB)

I posted Element.Geometry+ since it has the method for invisible objects inside it in Python, which might be of use.

---

<div class="post-metadata">

**Author:** ![Paul\_Wintour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paul_wintour/32/9381_2.png) [@Paul\_Wintour](https://forum.dynamobim.com/u/Paul_Wintour)\
**Post date:** [August 8, 2018, 12:16am UTC](https://forum.dynamobim.com/t/get-revit-db-reference-from-a-grid/24506/5 "2018-08-08T00:16:58Z")

</div>

The OOTB dimension node only works with line based elements (such as grids). I’m trying to create a string of dimensions to various elements - grids, stairs, walls, etc. For this I need the Revit.DB.Reference. I can get this for the other elements, but not grids. Any other thoughts?

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [August 8, 2018, 1:50am UTC](https://forum.dynamobim.com/t/get-revit-db-reference-from-a-grid/24506/6 "2018-08-08T01:50:51Z")

</div>

Extract the geometry of the grid and get a reference from the contained curve(s). Be sure to set `ComputeReferences` to true

---

<div class="post-metadata">

**Author:** ![Paul\_Wintour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paul_wintour/32/9381_2.png) [@Paul\_Wintour](https://forum.dynamobim.com/u/Paul_Wintour)\
**Post date:** [August 8, 2018, 10:15pm UTC](https://forum.dynamobim.com/t/get-revit-db-reference-from-a-grid/24506/7 "2018-08-08T22:15:43Z")

</div>

@Dimitar_Venkov I’m guessing you mean via Python?

 ![extract](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/3/930423a14b6d45cefad1bd0018d9840b0d4e88b1.jpeg)

Is this what you mean - Grid \> curve \> reference

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

I can get this but to be able to use it for creating a dimension, it needs to be a Revit.DB.Reference doesn’t it?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/4/543794ff922b1999eeba8810387141dad72a1f3b.jpg)

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [August 9, 2018, 2:02pm UTC](https://forum.dynamobim.com/t/get-revit-db-reference-from-a-grid/24506/8 "2018-08-09T14:02:16Z")

</div>

Last time I checked, clockwork’s node filtered out only solids. You need to use similar code but get the curves of the grid instead. Once you’ve done that with geometry extraction options that had the compute references turned on, you’ll be able to pull out a valid reference for use in dimensions.

---

<div class="post-metadata">

**Author:** ![Myhail\_Veselkin](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@Myhail\_Veselkin](https://forum.dynamobim.com/u/Myhail_Veselkin)\
**Post date:** [September 26, 2018, 11:09am UTC](https://forum.dynamobim.com/t/get-revit-db-reference-from-a-grid/24506/9 "2018-09-26T11:09:51Z")

</div>

Hello! If I understood you correctly, now these referents for grids on the python:  
for grid in grids:  
\_\_\_\_for obj in grid.get\_Geometry(opt):  
\_\_\_\_\_\_\_\_if isinstance(obj, Line):  
\_\_\_\_\_\_\_\_gline = obj  
\_\_\_\_\_\_\_\_Ref.Append(gline.Reference)

---

<div class="post-metadata">

**Author:** ![djordje.m.popovic](https://avatars.discourse-cdn.com/v4/letter/d/eb8c5e/32.png) [@djordje.m.popovic](https://forum.dynamobim.com/u/djordje.m.popovic)\
**Post date:** [November 19, 2018, 9:38am UTC](https://forum.dynamobim.com/t/get-revit-db-reference-from-a-grid/24506/10 "2018-11-19T09:38:45Z")

</div>

Hello Myhail, have You resolve this by any chance ? I am searching for same solution but with no API experiance.  
Regards

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [November 19, 2018, 8:07pm UTC](https://forum.dynamobim.com/t/get-revit-db-reference-from-a-grid/24506/11 "2018-11-19T20:07:00Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/8/584ea9a1a7eb485b064894127c65aa2cc0d6a6ed.png)

Copy the following code into a Python node 😀

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

doc = DocumentManager.Instance.CurrentDBDocument

def tolist(obj1):
    if hasattr(obj1,' __iter__'): return obj1
    else: return [obj1]

grids=tolist(UnwrapElement(IN[0]))
Ref=[]

opt=Options()
opt.ComputeReferences=True
opt.IncludeNonVisibleObjects=True
opt.View=doc.ActiveView

for grid in grids:
	for obj in grid.get_Geometry(opt):
		if isinstance(obj, Line):
			gline = obj
			Ref.append(gline.Reference)
OUT = Ref
```

---

<div class="post-metadata">

**Author:** ![jean](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jean/32/188752_2.png) [@jean](https://forum.dynamobim.com/u/jean)\
**Post date:** [November 20, 2018, 2:33am UTC](https://forum.dynamobim.com/t/get-revit-db-reference-from-a-grid/24506/12 "2018-11-20T02:33:08Z")

</div>

@Paul_Wintour, you can get **Reference** by this way also;

> [@Ewan\_Opie](#):
>
> ```
> Ref = ReferenceArray()
> for grid in grids:
> Ref.Append(Reference(grid))
> OUT = Ref
> 
> ```

---

<div class="post-metadata">

**Author:** ![djordje.m.popovic](https://avatars.discourse-cdn.com/v4/letter/d/eb8c5e/32.png) [@djordje.m.popovic](https://forum.dynamobim.com/u/djordje.m.popovic)\
**Post date:** [November 21, 2018, 8:34am UTC](https://forum.dynamobim.com/t/get-revit-db-reference-from-a-grid/24506/13 "2018-11-21T08:34:43Z")

</div>

Master THANK You
