# RevitFaceReference returns null values

**URL:** <https://forum.dynamobim.com/t/revitfacereference-returns-null-values/70091>\
**Category:** Revit\
**Tags:** revit, python, dynamo\
**Created:** [November 6, 2021, 7:49pm UTC](https://forum.dynamobim.com/t/revitfacereference-returns-null-values/70091 "2021-11-06T19:49:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lunzur](https://avatars.discourse-cdn.com/v4/letter/l/8797f3/32.png) [@Lunzur](https://forum.dynamobim.com/u/Lunzur)\
**Post date:** [November 6, 2021, 7:49pm UTC](https://forum.dynamobim.com/t/revitfacereference-returns-null-values/70091/1 "2021-11-06T19:49:46Z")

</div>

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:

> [@Create dimensions](https://forum.dynamobim.com/t/create-dimensions/27851/5):
>
> lucamanzoni san I am grateful for your cooperation. Python is a beginner, but I created Dynamo with reference to the topic I gave you. I was able to create dimensions of wall width and thickness, but it is stalled because I can not get the reference surface of the layer. [Wall\_Layer\_Dimension\_02.dyn](https://forum.dynamobim.com/uploads/short-url/jAFD3fi2A2jLuGcV9vqG3lpa2KE.dyn) (8.6 KB) I’d appreciate it if you can give us advice on how to get the reference surface of the layer in Python. You can provide me with the answers whenever you l…

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:

 ![Works](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/0/80233ee34c637ef72c81c1ed1c70bb1905c1ccb8.png)

Does not work

 ![Does not work](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/0/60578d1fe45c2da75965552b66e7a26188b2c107.png)

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

My script to extract the faces from floors

```auto
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

```

---

<div class="post-metadata">

**Author:** ![111205](https://avatars.discourse-cdn.com/v4/letter/1/ee7513/32.png) [@111205](https://forum.dynamobim.com/u/111205)\
**Post date:** [November 6, 2021, 11:51pm UTC](https://forum.dynamobim.com/t/revitfacereference-returns-null-values/70091/2 "2021-11-06T23:51:01Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/2/32f7fe7c7c75857329e7436f2d58eae8d891ff7d.png)

[Floor\_Dimension\_Test.dyn](https://forum.dynamobim.com/uploads/short-url/l7cfMtwLbasu0G7dyWjXhF4Lx78.dyn) (28.5 KB)  
[Floor\_Dimension\_Test.rvt](https://forum.dynamobim.com/uploads/short-url/gHq08VbqC98QiT0i1f9LUqZWbNR.rvt) (1.3 MB)

---

<div class="post-metadata">

**Author:** ![Lunzur](https://avatars.discourse-cdn.com/v4/letter/l/8797f3/32.png) [@Lunzur](https://forum.dynamobim.com/u/Lunzur)\
**Post date:** [November 7, 2021, 2:29pm UTC](https://forum.dynamobim.com/t/revitfacereference-returns-null-values/70091/3 "2021-11-07T14:29:37Z")

</div>

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

```auto
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](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’

 ![joined floors](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/5/2590c702000a5c5c710183d483c6f78069ac808e.png)  
 ![Test](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/4/14c1b3402014f2536ecab3e2750f150fd59f3163.png)

Have a nice day!
