Revit 计算Face的中心点
直接看代码,扩展Face方法
/// <summary>
/// 计算面的中心点
/// </summary>
public static XYZ ComputeCenter(this Face face)
{
BoundingBoxUV boundingBoxUV = face.GetBoundingBox();
UV centerUV = (boundingBoxUV.Max + boundingBoxUV.Min) / 2d;
return face.Evaluate(centerUV);
}
/// <summary>
/// 计算面的中心点处的一阶导数
/// </summary>
public static Transform ComputeCenterDerivatives(this Face face)
{
BoundingBoxUV boundingBoxUV = face.GetBoundingBox();
UV centerUV = (boundingBoxUV.Max + boundingBoxUV.Min) / 2d;
return face.ComputeDerivatives(centerUV);
}
face.ComputeCenterDerivatives().Origin
等价于face.ComputeCenter()
注1:此时计算到的点,是相对于面的。若需要在三维场景中使用,需要计算处面所在模型的变换矩阵(Transform),再
transform.OfPoint(faceCenter)
。
注2:由于是通过包围盒计算的,所以算得的点,不一定在面上,如环
。