如何找到穿过选定墙的参考平面的数量。
How to find number of Reference Planes passing through a selected wall.
我需要找出穿过所选墙的参考平面的数量及其名称。我可以获得特定文档的所有参考平面,但我该如何为特定的墙执行此操作。
您的帮助将不胜感激!
谢谢。
我将从尝试内置 ElementIntersectFilter
开始。该文档有一个很好的示例,将“FamilyInstance
”替换为“referencePlane
”,这样就可以了。
http://www.revitapidocs.com/2017/19276b94-fa39-64bb-bfb8-c16967c83485.htm
如果这不起作用,您将需要提取墙的实体并与参考平面相交。
如果 ElementIntersectFilter
不能满足您的需求,您必须提取墙的几何形状和参考平面并直接使用它们。
将参考平面与墙实体相交可以工作,但如果我正确理解您的问题,则有一个更简单的答案可以工作。我假设您只想要参考平面的绿线相交的墙,而不是将参考平面对象视为无限几何平面。在下面的屏幕截图中,我假设您想要找到复选标记,而不是红色的 X。 我还假设您将此视为计划练习,而不是专门设置参考平面的垂直范围(这仅基于我看到的大多数人使用 Revit 的方式)。以下函数将单个墙和参考平面列表作为输入(您提到您已经拥有所有参考平面的集合),并将 return 与墙相交的参考平面列表。
public static List<ReferencePlane> getRefPlanesIntersectingWall( Wall wal, List<ReferencePlane> refPlanesIn)
{
//simplify this to a 2D problem, using the location curve of the wall
List<ReferencePlane> refPlanesOut = new List<ReferencePlane>();
LocationCurve wallLocation = wal.Location as LocationCurve;
Curve wallCurve = wallLocation.Curve;
Double wallZ = wallLocation.Curve.GetEndPoint(0).Z;
foreach (ReferencePlane rp in refPlanesIn)
{
XYZ startPt = new XYZ(rp.BubbleEnd.X, rp.BubbleEnd.Y, wallZ);
XYZ endPt = new XYZ(rp.FreeEnd.X, rp.FreeEnd.Y, wallZ);
Line rpLine = Line.CreateBound(startPt, endPt);
SetComparisonResult test = wallCurve.Intersect(rpLine);
if (test == SetComparisonResult.Overlap ||
test == SetComparisonResult.Subset ||
test == SetComparisonResult.Superset ||
test == SetComparisonResult.Equal )
{
refPlanesOut.Add(rp);
}
}
return refPlanesOut;
}
我需要找出穿过所选墙的参考平面的数量及其名称。我可以获得特定文档的所有参考平面,但我该如何为特定的墙执行此操作。
您的帮助将不胜感激! 谢谢。
我将从尝试内置 ElementIntersectFilter
开始。该文档有一个很好的示例,将“FamilyInstance
”替换为“referencePlane
”,这样就可以了。
http://www.revitapidocs.com/2017/19276b94-fa39-64bb-bfb8-c16967c83485.htm
如果这不起作用,您将需要提取墙的实体并与参考平面相交。
如果 ElementIntersectFilter
不能满足您的需求,您必须提取墙的几何形状和参考平面并直接使用它们。
将参考平面与墙实体相交可以工作,但如果我正确理解您的问题,则有一个更简单的答案可以工作。我假设您只想要参考平面的绿线相交的墙,而不是将参考平面对象视为无限几何平面。在下面的屏幕截图中,我假设您想要找到复选标记,而不是红色的 X。
public static List<ReferencePlane> getRefPlanesIntersectingWall( Wall wal, List<ReferencePlane> refPlanesIn)
{
//simplify this to a 2D problem, using the location curve of the wall
List<ReferencePlane> refPlanesOut = new List<ReferencePlane>();
LocationCurve wallLocation = wal.Location as LocationCurve;
Curve wallCurve = wallLocation.Curve;
Double wallZ = wallLocation.Curve.GetEndPoint(0).Z;
foreach (ReferencePlane rp in refPlanesIn)
{
XYZ startPt = new XYZ(rp.BubbleEnd.X, rp.BubbleEnd.Y, wallZ);
XYZ endPt = new XYZ(rp.FreeEnd.X, rp.FreeEnd.Y, wallZ);
Line rpLine = Line.CreateBound(startPt, endPt);
SetComparisonResult test = wallCurve.Intersect(rpLine);
if (test == SetComparisonResult.Overlap ||
test == SetComparisonResult.Subset ||
test == SetComparisonResult.Superset ||
test == SetComparisonResult.Equal )
{
refPlanesOut.Add(rp);
}
}
return refPlanesOut;
}