# Python Element.Geometry

**URL:** <https://forum.dynamobim.com/t/python-element-geometry/48370>\
**Category:** Revit\
**Tags:** dynamo\
**Created:** [March 23, 2020, 6:36am UTC](https://forum.dynamobim.com/t/python-element-geometry/48370 "2020-03-23T06:36:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![abfletcher](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/abfletcher/32/45591_2.png) [@abfletcher](https://forum.dynamobim.com/u/abfletcher)\
**Post date:** [March 23, 2020, 6:36am UTC](https://forum.dynamobim.com/t/python-element-geometry/48370/1 "2020-03-23T06:36:18Z")

</div>

How do I get geomentry of element in one python script node. I don’t quite understand what I am missing here.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/7/c79d296a18c692c9160e8a4c35c09a8c3d092996.png)

```
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
floors = FilteredElementCollector(doc).OfClass(FilledRegion).ToElements()
out = []
for f in floors:
	out.append(f.Geometry())
OUT = out
```

---

<div class="post-metadata">

**Author:** ![stillgotme](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@stillgotme](https://forum.dynamobim.com/u/stillgotme)\
**Post date:** [March 23, 2020, 6:53am UTC](https://forum.dynamobim.com/t/python-element-geometry/48370/2 "2020-03-23T06:53:57Z")

</div>

maybe you can show us what is the working code? i mean you already got a working code, so whats wrong with it?

---

<div class="post-metadata">

**Author:** ![stillgotme](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@stillgotme](https://forum.dynamobim.com/u/stillgotme)\
**Post date:** [March 23, 2020, 7:03am UTC](https://forum.dynamobim.com/t/python-element-geometry/48370/3 "2020-03-23T07:03:19Z")

</div>

I believe is because you need to convert the collected elements to Dynamo Type before calling its property “Geomtry” of that particular element

---

<div class="post-metadata">

**Author:** ![abfletcher](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/abfletcher/32/45591_2.png) [@abfletcher](https://forum.dynamobim.com/u/abfletcher)\
**Post date:** [March 23, 2020, 7:21am UTC](https://forum.dynamobim.com/t/python-element-geometry/48370/4 "2020-03-23T07:21:29Z")

</div>

I need it to work on a single python node to be able to use the geometry and call a rollback transaction. The working code on this sample is just a separate of the one I pasted just without the Geometry() and as follows.  
import clr  
clr.AddReference(‘ProtoGeometry’)  
from Autodesk.DesignScript.Geometry import \*  
elements = IN[0]  
out =   
for e in elements:  
out.append(e.Geometry())  
OUT = out

---

<div class="post-metadata">

**Author:** ![stillgotme](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@stillgotme](https://forum.dynamobim.com/u/stillgotme)\
**Post date:** [March 23, 2020, 7:28am UTC](https://forum.dynamobim.com/t/python-element-geometry/48370/5 "2020-03-23T07:28:17Z")

</div>

Then the error occurs because you are getting Autodesk.Revit.DB.Element (Revit element) instead of Revit.Elements.Element (dynamo element), and thus unable to use dynamo element property just like that. You can either use Revit.Elements.ElementSelector.ByElementId(YOURELEMENTID) or .ToDSType(False or True) method to get the element in dynamo. Then call the Geometry() method on dynamo element

---

<div class="post-metadata">

**Author:** ![abfletcher](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/abfletcher/32/45591_2.png) [@abfletcher](https://forum.dynamobim.com/u/abfletcher)\
**Post date:** [March 23, 2020, 7:43am UTC](https://forum.dynamobim.com/t/python-element-geometry/48370/6 "2020-03-23T07:43:07Z")

</div>

Thanks it solved the issue. But then now I encountered a new problem which is I am unable to use either of the two element conversion inside a transaction.

---

<div class="post-metadata">

**Author:** ![stillgotme](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@stillgotme](https://forum.dynamobim.com/u/stillgotme)\
**Post date:** [March 23, 2020, 7:45am UTC](https://forum.dynamobim.com/t/python-element-geometry/48370/7 "2020-03-23T07:45:04Z")

</div>

do you mind eleborating more? im not able to see nor visualize what you just said

---

<div class="post-metadata">

**Author:** ![abfletcher](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/abfletcher/32/45591_2.png) [@abfletcher](https://forum.dynamobim.com/u/abfletcher)\
**Post date:** [March 23, 2020, 8:30am UTC](https://forum.dynamobim.com/t/python-element-geometry/48370/8 "2020-03-23T08:30:51Z")

</div>

@stillgotme

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/8/d851bd69918dbf7ca8203cb1a9d2b8cf2567f0cc.png)  
import clr  
clr.AddReference(“RevitServices”)  
from System.Collections.Generic import List  
clr.AddReference(“RevitNodes”)  
import Revit  
clr.ImportExtensions(Revit.GeometryConversion)  
clr.ImportExtensions(Revit.Elements)  
clr.AddReference(‘RevitAPI’)  
from Autodesk.Revit.DB import \*  
import RevitServices  
from RevitServices.Persistence import DocumentManager  
doc = DocumentManager.Instance.CurrentDBDocument  
def tolist(obj1):  
if hasattr(obj1,“ **iter** ”): return obj1  
else: return [obj1]  
elem = UnwrapElement(tolist(IN[0]))  
view = UnwrapElement(IN[1])  
type = UnwrapElement(IN[2])  
out =   
t = Transaction(doc, “Create Fill Region”)  
t.Start()  
for e in elem:  
ref = HostObjectUtils.GetTopFaces(e)[0]  
face = doc.GetElement(ref).GetGeometryObjectFromReference(ref)  
loop = face.GetEdgesAsCurveLoops()  
fill = FilledRegion.Create(doc,type.Id,view.Id,loop)  
out.append(fill.ToDSType(False).Geometry())  
t.RollBack()  
OUT = out

---

<div class="post-metadata">

**Author:** ![stillgotme](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@stillgotme](https://forum.dynamobim.com/u/stillgotme)\
**Post date:** [March 23, 2020, 8:55am UTC](https://forum.dynamobim.com/t/python-element-geometry/48370/9 "2020-03-23T08:55:47Z")

</div>

You will need to force close the dynamo’s automatic started transaction first, or use any api method to get on-going transaction and use it to generate a sub-transaction. With that being said, i think your script will still fail, but you can try
