Autodesk.Revit.DB.PlanViewDirection是一种表示Revit平面视图方向的Class,该方向可以是平行于X、Y或Z轴方向的平面视图。
public PlanViewDirection(XYZ forwardDirection, XYZ upDirection)
public XYZ UpDirection { get; }
获取平面视图向上方向的向量。
public XYZ ForwardDirection { get; }
获取平面视图正方向的向量。
public bool IsParallelTo(PlanViewDirection otherDirection)
返回值:比较的两个PlanViewDirection对象是否平行。
public bool IsPerpendicularTo(PlanViewDirection otherDirection)
返回值:比较的两个PlanViewDirection对象是否垂直。
//创建向上和正方向均为Z轴的平面视图
PlanViewDirection planViewDirection = new PlanViewDirection(new XYZ(0, 0, 1), new XYZ(0, 0, 1));
//获取平面视图的正方向
XYZ forwardDirection = planViewDirection.ForwardDirection;
//获取平面视图的向上方向
XYZ upDirection = planViewDirection.UpDirection;
//输出结果
Debug.Print("ForwardDirection: ({0}, {1}, {2})", forwardDirection.X, forwardDirection.Y, forwardDirection.Z);
Debug.Print("UpDirection: ({0}, {1}, {2})", upDirection.X, upDirection.Y, upDirection.Z);
//创建两个平行的平面视图方向对象
PlanViewDirection planViewDirection1 = new PlanViewDirection(new XYZ(1, 0, 0), new XYZ(0, 0, 1));
PlanViewDirection planViewDirection2 = new PlanViewDirection(new XYZ(1, 0, 0), new XYZ(0, 0, 1));
//创建两个垂直的平面视图方向对象
PlanViewDirection planViewDirection3 = new PlanViewDirection(new XYZ(1, 0, 0), new XYZ(0, 0, 1));
PlanViewDirection planViewDirection4 = new PlanViewDirection(new XYZ(0, 0, 1), new XYZ(0, 1, 0));
//判断两个PlanViewDirection对象是否平行
if (planViewDirection1.IsParallelTo(planViewDirection2))
{
Debug.Print("PlanViewDirection1 is parallel to PlanViewDirection2.");
}
else
{
Debug.Print("PlanViewDirection1 is not parallel to PlanViewDirection2.");
}
//判断两个PlanViewDirection对象是否垂直
if (planViewDirection3.IsPerpendicularTo(planViewDirection4))
{
Debug.Print("PlanViewDirection3 is perpendicular to PlanViewDirection4.");
}
else
{
Debug.Print("PlanViewDirection3 is not perpendicular to PlanViewDirection4.");
}