RevitFaceReference returns null values

Hello,
I want to make a script that dimensions my floors in a sectionview.
I found a script that does close to what I want:

This script takes a set of faces to dimension and a line to refer to the position of the dimension.

Now I have made in python a script that finds the floors in the active view, then I extract the top and bottom faces from the floors.
So I can create a dimension between the floors and the floor thicknesses.

I get an error because when I try to get the RevitFaceReference is only shows null values.
I use this to get RevitFaceReference, I need this to make a dimension.
for face in faces:
try:
ref = face.Tags.LookupTag(“RevitFaceReference”)
elementlist.Append(ref)
except:
elementlist.Append(ReferenceArray())

But when I use the dynamo nodes to extract faces the script works

Works:

Does not work

I think the problem lies in my script where I extract the faces from the floors

My script to extract the faces from floors

import clr
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
import System
from System import Array
from System.Collections.Generic import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager 
from RevitServices.Transactions import TransactionManager 

clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")

import Autodesk 
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB import Options
from Autodesk.Revit.UI import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application 
uidoc = uiapp.ActiveUIDocument

#Functies
#Maakt list als het geen list is
def fun_make_list(input):
	input_list = input if isinstance(input, list) else [input]
	return input_list
#Krijg parameter waarde
def fun_getparameter(element, parametername):
        param = element.LookupParameter(parametername)
	if param.StorageType == StorageType.String:
		return param.AsString()
	else:
		return param.AsValueString()
#Set parameters
def fun_setparameter(element, parametername, value):
	element.LookupParameter(parametername).Set(value)

#Flatten list
def fun_flattenlist(flist):
        return [val for sublist in flist for val in sublist]
        

floors = FilteredElementCollector(doc, doc.ActiveView.Id).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsNotElementType().ToElements()

breedplaat = [x for x in floors if "breedplaat" in fun_getparameter(x, "Type")]
breedplaat = UnwrapElement(breedplaat)
option = Autodesk.Revit.DB.Options()
option.ComputeReferences = True
solid = [x.get_Geometry(option) for x in breedplaat]
solid = fun_flattenlist(solid)
geo = [i.Convert() for i in solid]

polysurface = [PolySurface.BySolid(i) for i in geo]
surface = [PolySurface.Surfaces(i) for i in polysurface]




faces = []
for i in surface:
	faces_sub = []
	for j in i:
		opp = j.Area
		faces_sub.append(opp)
		 
	max_value = max(faces_sub)
	max_2_values = sorted( [x for x in faces_sub], reverse=True )[:2]
	for k in i:
		if k.Area == max_2_values[0] or k.Area == max_2_values[1]:
			faces.append(k)
			
#Start transaction			
TransactionManager.Instance.EnsureInTransaction(doc)


#End transaction	
TransactionManager.Instance.TransactionTaskDone()

OUT = faces

Hello
I think there is such a method, so please refer to it.

Floor_Dimension_Test.dyn (28.5 KB)
Floor_Dimension_Test.rvt (1.3 MB)

Hello,

Thanks for the script it works!
Espacialy for this piece of code where you get the top and bottom faces of the floor.
And I also think my script did not work because I had not set this value for the the option:
options.IncludeNonVisibleObjects = True

def referece(element):
	options = Options()
	options.IncludeNonVisibleObjects = True
	options.ComputeReferences = True
	
	geometry = element.get_Geometry(options)

	ref = []
	for geometryObject in geometry:
		for face in geometryObject.Faces:
			#Floor Top & Bottom Face
			if face.FaceNormal.Z == 1 or face.FaceNormal.Z == -1:
				ref.append(face.Reference)
	return ref

I didn’t know about the FaceNormal property, if I understand it correctly 1 is always the top and -1 the bottom.
Where can I find which sides is which? I could not find it at the Revit API docs:
https://www.revitapidocs.com/2016/5ddd3db6-5b9a-afda-d96e-6a607c3bcc87.htm

But I found out that when I have a floor that is joined in each other I get the following error:
I will look further to find out what exactly creates the error.
AttributeError: ‘CylindricalFace’ object has no attribute ‘FaceNormal’


Have a nice day!