Can't place family on face (only on level) with Python

Hi.

I am trying to place revit familes with the method NewFamilyInstance Method (Face, XYZ, XYZ, FamilySymbol) but I get an error: ‘Expected Face, got Surface’

I have viewed this post but it didn’t help me: https://forum.dynamobim.com/t/placing-a-new-family-on-a-face-in-python/13335

Please see attached image for the code I have used:

Thanks for the help in advance!

Would you be able to also show how your inputs are being generated before they get to the Python script? It looks like you may be running into the same issue shown in the post you linked. In that post, the “Select Face” node is a bit misleading as it returns a Surface instead of a Face. The Face class has a GetSurface() method, but it looks like there isn’t a way to get a Face from a Surface.

Hi @cgartland @Figleggedtom

If you’re looking to convert Surface into Face here is OOTB method. I will soon post python as well:
image

I have updated the script and converted the surfaces to faces with the Topology.Faces node as you suggested but I still get an error. This time It’s: “Expected Face, got Face”. :?

The method needs Revit Faces, whereas you are feeding Dynamo Faces.

You can get Revit faces from Dynamo faces like this:

Python:

import clr

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

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

#Import ToDSType(bool) extensions method
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument

faces = IN[0]

output = []

for i in faces:
	elemRef = i.Tags.LookupTag('RevitFaceReference')
	elem = doc.GetElement(elemRef)
	output.append(elem.GetGeometryObjectFromReference(elemRef))
#Assign your output to the OUT variable.

OUT = output

Hi. Thanks for the reply. I have tried to convert the faces to Revit faces with the code you have provided but when I feed the Revit face to the code I get this error message now:

Any thoughts?

Try to add this to your code:

opt = Options()
opt.ComputeReferences = True

Hey Chris,

Long time no see :slightly_smiling_face:.
I’m afraid it won’t be og any help to create the Options() object and compute references in this case, because unlike the get_Geometry() method, the GetGeometryObjectFromReference() does not take the Options() object as a parameter.

I was working on a script that would compare the dynamo faces with Revit faces by comparing their Evaluate() to UV(0.5,0.5), but I didn’t have time to finish it. I’ll upload my result when I get back from my vacation, if no one have solved this :slightly_smiling_face:

1 Like

Ah, I haven’t noticed that one. :slight_smile:
Just read the API once again and I now see what you mean.
Looking forward to see your solution to @Figleggedtom. I hope I can learn something too.

I completely forgot about this. I’ll se if i can dig it out and get it finished :slight_smile:

1 Like

Hey,

Perhaps this helps? The python inside is great!
image

I had to make a face based family, I’m not sure this one will work?
image

Cheers,

Mark

Hey @Mark.Ackerley,

Sorry for the late reply. Yeah Dimitars nodes are great resources, and also confusing sometimes :grin:.
I actually got my solution working, but thanks for the heads up. I’ll see if I get time to look into it :slightly_smiling_face:

1 Like