Autodesk.Revit.DB.PlanarFace
是Revit API中描述Revit模型中平面面的类。这个类通过定义平面的边界线和法线向量来定义面。PlanarFace对象可以用于表示多边形和矩形平面。
Vertices
- 获取和设置平面的角点。EdgeLoops
- 获取和设置平面的边界线集合。Reference
- 获取和设置平面的引用。Contains
- 判断给定点是否位于平面内。Intersect
- 计算平面与给定直线的交点。Project
- 计算一个点在平面上的投影点。创建平面并设置其属性:
XYZ point1 = new XYZ(0, 0, 0);
XYZ point2 = new XYZ(10, 0, 0);
XYZ point3 = new XYZ(10, 10, 0);
XYZ point4 = new XYZ(0, 10, 0);
CurveArray curveArray = new CurveArray();
curveArray.Append(Line.CreateBound(point1, point2));
curveArray.Append(Line.CreateBound(point2, point3));
curveArray.Append(Line.CreateBound(point3, point4));
curveArray.Append(Line.CreateBound(point4, point1));
Plane plane = Plane.CreateByThreePoints(point1, point2, point3);
PlanarFace planarFace = PlanarFace.Create(Document, curveArray, plane);
判断给定点是否位于平面内:
XYZ point = new XYZ(5, 5, 0);
bool contains = planarFace.Contains(point);
计算平面与给定直线的交点:
XYZ startPoint = new XYZ(2, 2, 5);
XYZ endPoint = new XYZ(2, 2, -5);
Line line = Line.CreateBound(startPoint, endPoint);
IntersectionResultArray resultArray = new IntersectionResultArray();
foreach (Curve edge in planarFace.EdgeLoops.get_Item(0))
{
SetComparisonResult comparisonResult = edge.Intersect(line, out IntersectionResult intersectionResult);
if (comparisonResult == SetComparisonResult.Overlap)
{
resultArray.Append(intersectionResult);
}
}
计算一个点在平面上的投影点:
XYZ point = new XYZ(5, 5, 5);
PlanarFace face = (PlanarFace)Element;
XYZ projection = face.Project(point);