# TypeCast GeometryElement to Solid using Python

**URL:** <https://forum.dynamobim.com/t/typecast-geometryelement-to-solid-using-python/34240>\
**Category:** Developers\
**Tags:** python\
**Created:** [April 1, 2019, 1:40pm UTC](https://forum.dynamobim.com/t/typecast-geometryelement-to-solid-using-python/34240 "2019-04-01T13:40:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jnoordzij](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jnoordzij/32/32419_2.png) [@jnoordzij](https://forum.dynamobim.com/u/jnoordzij)\
**Post date:** [April 1, 2019, 1:40pm UTC](https://forum.dynamobim.com/t/typecast-geometryelement-to-solid-using-python/34240/1 "2019-04-01T13:40:36Z")

</div>

I am trying to get the faces of an element using Python code.

I am following the example from the Revit API docs, on how to get the Faces property of a Solid class object.

link to + excerpt of the example:  
[[http://www.revitapidocs.com/2019/b45fa881-3077-409c-0ef1-5d42744e7429.htm](http://www.revitapidocs.com/2019/b45fa881-3077-409c-0ef1-5d42744e7429.htm)]

````
```
 Autodesk.Revit.DB.Options opt = new Options();
    Autodesk.Revit.DB.GeometryElement geomElem = wall.get_Geometry(opt);
    foreach (GeometryObject geomObj in geomElem)
    {
        Solid geomSolid = geomObj as Solid;
        if (null != geomSolid)
        {
            int faces = 0;
            double totalArea = 0;
            foreach (Face geomFace in geomSolid.Faces)
            {
```

````

my python code:

```
doc = DocumentManager.Instance.CurrentDBDocument
element = UnwrapElement(IN[0])
options = Autodesk.Revit.DB.Options()

geometryInstance = element.get_Geometry(options)

inst_geom = []

for i in geometryInstance:
	inst_geom.append(i.GetInstanceGeometry()) 

OUT = inst_geom[0]

```

Up to here, all is well. Dynamo output looks like this:

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

Now if i add a small piece of code:

```
doc = DocumentManager.Instance.CurrentDBDocument
element = UnwrapElement(IN[0])
options = Autodesk.Revit.DB.Options()

geometryInstance = element.get_Geometry(options)

inst_geom = []

for i in geometryInstance:
	inst_geom.append(i.GetInstanceGeometry())

faces = []

for i in inst_geom:
	faces.append(i.Faces)

OUT = faces[0]

```

I get this:

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

So… to me this looks like Python is failing to read the Autodesk.Revit.DB.Solid as a Solid, instead it is reading it as a GeometryElement. So I would need to typecast this somehow. As the example says:

`Solid geomSolid = geomObj as Solid;`

How can I do this in Python?

---

<div class="post-metadata">

**Author:** ![jnoordzij](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jnoordzij/32/32419_2.png) [@jnoordzij](https://forum.dynamobim.com/u/jnoordzij)\
**Post date:** [April 1, 2019, 1:44pm UTC](https://forum.dynamobim.com/t/typecast-geometryelement-to-solid-using-python/34240/2 "2019-04-01T13:44:39Z")

</div>

My bad. I was in the wrong hierarchy. Solution is:

```
for i in inst_geom[0]:
	faces.append(i.Faces)

```

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