Facing problems with face class methods

Dear Autodesk Community,

I am currently facing a problem in my python script that makes me despair a bit. I already solved the problem in Dynamo. No Issues here, but I am trying to speed up my dynamo script by transfering some processes into python. The script is supposed to give the middle points of the two smallest faces of a boundingbox. However it doesn’t work. Error message says "AttributeError: ‘Face’ object has no attribute ‘Evaluate’ ". I have already tried a few things, but nothing seems to work out, and I am bit helpless at the moment. Maybe someone can find my mistake?

I would appreciate any help. Thank you in advance :pray:

++++++++++++++++++++++++++++++++++++++++++++++


clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from Autodesk.DesignScript.Geometry.Core import *

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

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

#defining functions
def getBBoxFaces(bboxes):
	solidList = [ ]
	faceList = [ ]
	for bbox in bboxes:
		solidList.append(bbox.ToCuboid())
	for solid in solidList:
		facesPerSolid = solid.Faces
		faceList.append(facesPerSolid)
	return faceList
	
def get2smallestFaces(faces):
	smallestFacesPerSolid = [ ]
	for facesPerSolid in faces:
		smallestFaces = sorted(facesPerSolid, key=lambda face: Face.Area)[:2]
		smallestFacesPerSolid.append(smallestFaces)
	return smallestFacesPerSolid

def getMiddlePoints(faces):
	uv = UV(0.5,0.5)
	midPoints = [ ]
	for face in faces:
		midPoint = face.Evaluate(uv)
		midPoints.append(midPoint)
	return midPoints

def getMiddlePointsOfBBox(bboxes):
	middlePoints = [ ]
	faceList = getBBoxFaces(bboxes)
	smallestFacesList = get2smallestFaces(faceList)
	for smallFace in smallestFacesList:
		middlePoints.append(getMiddlePoints(smallFace))
	return middlePoints

# Start Transaction
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)

#Unwrap element
bboxes = UnwrapElement(IN[0])

#get Middle Points Of bbox
middlePoints = getMiddlePointsOfBBox(bboxes)

# End Transaction
TransactionManager.Instance.TransactionTaskDone()

OUT = middlePoints

P.S. these boxes are square brackets, so an empty list

@DynUser ,

i was not able to solve it but i think you have to use Surfaces instead of faces …

KR

Andreas

Hello, you looked with object type if these faces were revit faces (and not dynamo face)
your wrong attribute message may be coming from this aspect.
Cordially
christian.stan