|
@@ -103,19 +103,24 @@ namespace RevitToJBim.Extension
|
|
|
SpatialElementBoundaryOptions options = new SpatialElementBoundaryOptions();
|
|
|
//options.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish;
|
|
|
var segments = space.GetBoundarySegments(options);
|
|
|
- double tolerance = space.Document.Application.ShortCurveTolerance;
|
|
|
+ Document doc = space.Document;
|
|
|
+ double tolerance = doc.Application.ShortCurveTolerance;
|
|
|
+
|
|
|
foreach (var segment in segments)
|
|
|
{
|
|
|
#region 取外轮廓的点
|
|
|
|
|
|
List<XYZ> xyzs = new List<XYZ>();
|
|
|
+ var allWalls = doc.GetElements<Wall>();
|
|
|
+ var tupleWalls = allWalls
|
|
|
+ .Select(t => new Tuple<Curve, Wall>(t.GetLocationCurve(), t)).ToList();
|
|
|
foreach (BoundarySegment boundarySegment in segment)
|
|
|
{
|
|
|
var segmentElement = space.Document.GetElement(boundarySegment.ElementId);
|
|
|
if (segmentElement is Wall wall)
|
|
|
{
|
|
|
var wallCurve = wall.GetLocationCurve();
|
|
|
- var parallelWalls = GetParallelWalls(wall);
|
|
|
+ var parallelWalls = GetParallelWalls(wall, tupleWalls);
|
|
|
var segmentCurve = boundarySegment.GetCurve();
|
|
|
var tessellates = segmentCurve.Tessellate();
|
|
|
foreach (XYZ tessellate in tessellates)
|
|
@@ -188,31 +193,31 @@ namespace RevitToJBim.Extension
|
|
|
return outlines;
|
|
|
}
|
|
|
|
|
|
- private static double m_RedundancySpace = 10d;
|
|
|
+ private static double m_RedundancySpace = 10d.ToApi();
|
|
|
/// <summary>
|
|
|
/// 获取平行墙,平行且投影有重叠部分
|
|
|
/// </summary>
|
|
|
/// <param name="wall"></param>
|
|
|
/// <returns></returns>
|
|
|
- public static List<Wall> GetParallelWalls(Wall wall)
|
|
|
+ public static List<Wall> GetParallelWalls(Wall wall, List<Tuple<Curve, Wall>> tupleWalls)
|
|
|
{
|
|
|
List<Wall> walls = new List<Wall>();
|
|
|
walls.Add(wall);
|
|
|
- var doc = wall.Document;
|
|
|
- var allWalls = doc.GetElements<Wall>();
|
|
|
var curve = wall.GetLocationCurve();
|
|
|
- var parallelWalls = allWalls.Where(t => t.GetLocationCurve().IsParallel(curve));
|
|
|
+ var parallelWallTuples = tupleWalls.Where(t => t.Item1.IsParallel(curve));
|
|
|
|
|
|
int len = walls.Count;
|
|
|
do
|
|
|
{
|
|
|
len = walls.Count;
|
|
|
- foreach (Wall parallelWall in parallelWalls)
|
|
|
+ foreach (Tuple<Curve, Wall> parallelWallTuple in parallelWallTuples)
|
|
|
{
|
|
|
- var curve1 = parallelWall.GetLocationCurve();
|
|
|
+ var curve1 = parallelWallTuple.Item1;
|
|
|
+ var parallelWall = parallelWallTuple.Item2;
|
|
|
+
|
|
|
var startP11 = CurveExtend.StartPoint(curve1);
|
|
|
var endP11 = CurveExtend.EndPoint(curve1);
|
|
|
- double width1 = parallelWall.Width.FromApi();
|
|
|
+ double width1 = parallelWall.Width;
|
|
|
for (int i = 0; i < walls.Count; i++)
|
|
|
{
|
|
|
Wall referenceWall = walls[i];
|
|
@@ -220,16 +225,11 @@ namespace RevitToJBim.Extension
|
|
|
var curve2 = referenceWall.GetLocationCurve();
|
|
|
var startP12 = CurveExtend.GetProjectPt(curve2, startP11);
|
|
|
var endP12 = CurveExtend.GetProjectPt(curve2, endP11);
|
|
|
- var startP21 = CurveExtend.StartPoint(curve2);
|
|
|
- var endP21 = CurveExtend.EndPoint(curve2);
|
|
|
- var startP22 = CurveExtend.GetProjectPt(curve1, startP21);
|
|
|
- var endP22 = CurveExtend.GetProjectPt(curve1, endP21);
|
|
|
//判断是否有重叠部分
|
|
|
- if (startP12.IsOnCurve(curve2) || endP12.IsOnCurve(curve2) || startP22.IsOnCurve(curve1) ||
|
|
|
- endP22.IsOnCurve(curve1))
|
|
|
+ if (startP12.IsOnCurve(curve2) || endP12.IsOnCurve(curve2))
|
|
|
{
|
|
|
- double width2 = referenceWall.Width.FromApi();
|
|
|
- double distacne = curve1.Distance(curve2).FromApi();
|
|
|
+ double width2 = referenceWall.Width;
|
|
|
+ double distacne = curve1.Distance(curve2);
|
|
|
if (distacne < (width1 + width2) / 2.0 + m_RedundancySpace)
|
|
|
walls.Add(parallelWall);
|
|
|
}
|