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]
```
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:
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:
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?