Revit command "Place on face", how to do it ?

Revit command "Place on face", how to do it ?

AD8080202
Advocate Advocate
1,354 Views
2 Replies
Message 1 of 3

Revit command "Place on face", how to do it ?

AD8080202
Advocate
Advocate

Revit command "Place on face", how to do it ?

An error occurred after execution.
How can I solve this?

「The Reference of the input face is null.
If the face was obtained from Element.Geometry, make sure to turn on the option 'ComputeReferences'.
Parameter name: face 」

please help me.
Thank you!

 

FilteredElementCollector collector = new FilteredElementCollector(doc);
collector.OfClass(typeof(FamilySymbol)).OfCategory(BuiltInCategory.OST_GenericModel);
FamilySymbol symbol = collector.FirstElement() as FamilySymbol;


IList<Reference> Objects = uidoc.Selection.PickObjects(ObjectType.Face, "Select Faces");
Result result = Result.Failed;
if (Objects.Count == 0) { return result; }
Face face = null;
foreach (Reference reference in Objects)
{
GeometryObject thisGeomObj = thisElement.GetGeometryObjectFromReference(reference);
Face geomFace = thisGeomObj as Face;
face = geomFace;

BoundingBoxUV bboxUV = face.GetBoundingBox();
UV center = (bboxUV.Max + bboxUV.Min) / 2.0;
XYZ location = face.Evaluate(center);
XYZ normal = face.ComputeNormal(center);
XYZ refDir = normal.CrossProduct(XYZ.BasisZ);
FamilyInstance instance = doc.Create.NewFamilyInstance(face, location, refDir, symbol);
}
0 Likes
1,355 Views
2 Replies
Replies (2)
Message 2 of 3

AD8080202
Advocate
Advocate

190621.jpg

0 Likes
Message 3 of 3

AD8080202
Advocate
Advocate

My English is pretty basic, please don't mind.

Find the answer after searching.

Reference jeremytammik file

Https://thebuildingcoder.typepad.com/blog/2015/02/determining-the-face-tangent-at-a-picked-point.htm...

Thank you!

0 Likes