Python: Area of material from face: \\\'Solid\\\' object has no attribute \\\'faces\\\'


#1

Does python script have holes in it or do I need an import somewhere (that I amy be missing - am new to dynamo/python) I have a python code script I am trying to adapt from here: <span style=“color: #75715e;”>http://help.autodesk.com/view/RVT/2014/ENU/?guid=GUID-E7B451BB-21DC-4D72-AD26-75F0C2E911E4</span> It Bombs out at line 23 “<span style=“font-weight: bold; color: #f92672;”>for</span> objFace <span style=“font-weight: bold; color: #f92672;”>in</span> objRoomSolid.faces:”

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. Traceback (most recent call last): File "", line 23, in AttributeError: 'Solid' object has no attribute 'faces'
Script as follows using mongolian-type notations-
##Started partial translation from help in the API :

## http://help.autodesk.com/view/RVT/2014/ENU/?guid=GUID-E7B451BB-21DC-4D72-AD26-75F0C2E911E4

import clr

clr.AddReference(‘RevitAPI’)

from Autodesk.Revit.DB import*

import Autodesk

clr.AddReference(“RevitNodes”)

import Revit

clr.ImportExtensions(Revit.GeometryConversion)

items = UnwrapElement(IN[0])

listElements = list()

for objRoom in items:

objDoc = objRoom.Document

calculator = SpatialElementGeometryCalculator(objDoc)###

objResults = calculator.CalculateSpatialElementGeometry(objRoom)

objRoomSolid = objResults.GetGeometry();

for objFace in objRoomSolid.faces:

FaceArea = objFace.area

## get the sub-faces for the face of the room

subfaceList = objResults.GetBoundaryFaceInfo(objFace)

for objRoomSolidFace in objRoomSolid.Faces:

for objsubface in objResults.GetBoundaryFaceInfo(objRoomSolidFace):

objBoundingElementface = ocjSubface.GetBoundingElementFace()

objEid = objBoundingElementface.MaterialElementId

listElements.append( doc.GetElement(objEid).Name +", id = “+ objEid.IntegerValue.ToString()+”\n")

#

OUT =(listelements)


#2

import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import*
import Autodesk

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

doc = DocumentManager.Instance.CurrentDBDocument

items = UnwrapElement(IN[0])
listElements = list()

for objRoom in items:
objDoc = objRoom.Document
calculator = SpatialElementGeometryCalculator(objDoc)
objResults = calculator.CalculateSpatialElementGeometry(objRoom)

objRoomSolid = objResults.GetGeometry()
for objFace in objRoomSolid.Faces:
faceArea = objFace.Area
subfaceList = objResults.GetBoundaryFaceInfo(objFace)

for objRoomSolidFace in objRoomSolid.Faces:
for objsubface in objResults.GetBoundaryFaceInfo(objRoomSolidFace):
objBoundingElementface = objsubface.GetBoundingElementFace()
objEid = objBoundingElementface.MaterialElementId
listElements.append(“Material Name = “+ doc.GetElement(objEid).Name +”, Material Id = “+ objEid.IntegerValue.ToString()+”, Material Area = “+ faceArea.ToString()+”\n”)

OUT =(listElements)

 


#3

Ron,

You have misspelled “Faces” in your code by spelling it like this: “faces”. That’s a syntax error.