Skip to content

Commit 7d00ca4

Browse files
enarhiJosef Taylor
authored andcommitted
Stories tweaked and check added for overlapping wall openings
1 parent 3a06529 commit 7d00ca4

File tree

2 files changed

+46
-19
lines changed

2 files changed

+46
-19
lines changed

RAM_Adapter/CRUD/Create.cs

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -523,22 +523,46 @@ private bool CreateCollection(IEnumerable<Panel> bhomPanels)
523523

524524
if ((openMin.Z.ToInch() >= ramStory.dElevation - ramStory.dFlrHeight) && (openMin.Z.ToInch() < ramStory.dElevation))
525525
{
526-
//Get opening on wall extents
527-
if (!(outline.IsContaining(openOutline, false)))
526+
IFinalWallOpenings ramWallOpenings = ramWall.GetFinalOpenings();
527+
528+
int openOverlapCount = 0;
529+
530+
for (int j = 0; i < ramWallOpenings.GetCount(); j++)
528531
{
529-
openOutline = outline.BooleanIntersection(openOutline)[0];
530-
Engine.Reflection.Compute.RecordWarning("Panel " + name + " opening intersects wall boundary. Boolean intersection was used to get opening extents on panel.");
532+
IFinalWallOpening testOpen = ramWallOpenings.GetAt(j);
533+
IPoints openingPts = testOpen.GetOpeningVertices();
534+
535+
//Re-add first point to close Polygon
536+
IPoint firstOPt = openingPts.GetAt(0);
537+
SCoordinate firstOCoord = new SCoordinate();
538+
firstOPt.GetCoordinate(ref firstOCoord);
539+
openingPts.Add(firstOCoord);
540+
541+
Polyline wallOpeningOutline = openingPts.ToPolyline();
542+
List<Point> intPts = wallOpeningOutline.ICurveIntersections(openOutline);
543+
if (wallOpeningOutline.IsContaining(openOutline) || openOutline.IsContaining(wallOpeningOutline) || intPts.Count > 0)
544+
{ openOverlapCount += 1; }
531545
}
532546

533-
Point closestOpenPt = BH.Engine.Geometry.Query.ClosestPoint(wallMin, openOutline.ControlPoints());
534-
double distX = Math.Sqrt(Math.Pow(closestOpenPt.X - wallMin.X, 2) + Math.Pow(closestOpenPt.Y - wallMin.Y, 2));
535-
double distZinch = openBounds.Min.Z.ToInch() - (ramStory.dElevation - ramStory.dFlrHeight);
536-
double openWidth = Math.Sqrt(Math.Pow(openBounds.Max.X - openBounds.Min.X, 2) + Math.Pow(openBounds.Max.Y - openBounds.Min.Y, 2));
537-
double openHt = openBounds.Max.Z - openBounds.Min.Z;
538-
539-
//Add opening to RAM
540-
IRawWallOpenings ramWallOpenings = ramWall.GetRawOpenings();
541-
ramWallOpenings.Add(EDA_MEMBER_LOC.eBottomStart, distX.ToInch(), distZinch, openWidth.ToInch(), openHt.ToInch());
547+
if (openOverlapCount == 0)
548+
{
549+
//Get opening on wall extents
550+
if (!(outline.IsContaining(openOutline, false)))
551+
{
552+
openOutline = outline.BooleanIntersection(openOutline)[0];
553+
Engine.Reflection.Compute.RecordWarning("Panel " + name + " opening intersects wall boundary. Boolean intersection was used to get opening extents on panel.");
554+
}
555+
556+
Point closestOpenPt = BH.Engine.Geometry.Query.ClosestPoint(wallMin, openOutline.ControlPoints());
557+
double distX = Math.Sqrt(Math.Pow(closestOpenPt.X - wallMin.X, 2) + Math.Pow(closestOpenPt.Y - wallMin.Y, 2));
558+
double distZinch = openBounds.Min.Z.ToInch() - (ramStory.dElevation - ramStory.dFlrHeight);
559+
double openWidth = Math.Sqrt(Math.Pow(openBounds.Max.X - openBounds.Min.X, 2) + Math.Pow(openBounds.Max.Y - openBounds.Min.Y, 2));
560+
double openHt = openBounds.Max.Z - openBounds.Min.Z;
561+
562+
//Add opening to RAM
563+
IRawWallOpenings ramRawWallOpenings = ramWall.GetRawOpenings();
564+
ramRawWallOpenings.Add(EDA_MEMBER_LOC.eBottomStart, distX.ToInch(), distZinch, openWidth.ToInch(), openHt.ToInch());
565+
}
542566
}
543567
}
544568
}
@@ -592,17 +616,20 @@ private bool CreateCollection(IEnumerable<Level> bhomLevels)
592616
for (int i = 0; i < sortedBhomLevels.Count(); i++)
593617
{
594618
Level level = sortedBhomLevels.ElementAt(i);
595-
double levelHt = level.Elevation.ToInch();
619+
double levelHtDbl = level.Elevation.ToInch();
620+
double levelHt = Math.Round(levelHtDbl, 3);
596621

597622
// Get elevations and skip if level elevation already in RAM
598623
ramStories = m_Model.GetStories();
599624
List<double> ramElevs = new List<double>();
625+
List<string> ramStoryNames = new List<string>();
600626
for (int j = 0; j < ramStories.GetCount(); j++)
601627
{
602628
ramElevs.Add(ramStories.GetAt(j).dElevation);
629+
ramStoryNames.Add(ramStories.GetAt(j).strLabel);
603630
}
604631

605-
if (ramElevs.Contains(levelHt) != true)
632+
if (ramElevs.Contains(levelHt) != true && ramStoryNames.Contains(level.Name) != true)
606633
{
607634
double height;
608635
// Ground floor ht = 0 for RAM
@@ -631,9 +658,10 @@ private bool CreateCollection(IEnumerable<Level> bhomLevels)
631658
Boolean floorTypeExists = false;
632659
for (int j = 0; j < ramFloorTypes.GetCount(); j++)
633660
{
634-
if (ramFloorTypes.GetAt(j).strLabel == level.Name)
661+
IFloorType testFloorType = ramFloorTypes.GetAt(j);
662+
if (testFloorType.strLabel == level.Name)
635663
{
636-
ramFloorType = ramFloorTypes.GetAt(j);
664+
ramFloorType = testFloorType;
637665
floorTypeExists = true;
638666
}
639667
}
@@ -653,7 +681,6 @@ private bool CreateCollection(IEnumerable<Level> bhomLevels)
653681
{
654682
IStory ramStoryBelow = ramStories.GetAt(newIndex - 1);
655683
height = levelHt - ramStoryBelow.dElevation;
656-
657684
}
658685

659686
// Insert story at index

RAM_Adapter/Convert/ToBHoM.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ public static Panel ToBHoMObject(this IWall ramWall)
537537
List<ICurve> wallOpeningPLs = new List<ICurve>();
538538
List<Opening> bhomWallOpenings = new List<Opening>();
539539

540-
// Create openings (disabled, causing database freeze)
540+
// Create openings
541541
IFinalWallOpenings IFinalWallOpenings = ramWall.GetFinalOpenings();
542542
IRawWallOpenings rawOpenings = ramWall.GetRawOpenings();
543543
if (rawOpenings.GetCount() > 0)

0 commit comments

Comments
 (0)