Message 1 of 3
Revit command "Place on face", how to do it ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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);
}