/***************************************************/ /**** Private methods ****/ /***************************************************/ private bool CreateCollection(IEnumerable <ISurfaceProperty> srfProps) { foreach (ISurfaceProperty srfProp in srfProps) { RAMId RAMId = new RAMId(); if (srfProp is Ribbed) { Ribbed compProp = (Ribbed)srfProp; ICompDeckProp ramProp; //Validity check for ribbed properties thickness above flutes if (compProp.Thickness < 2.0.FromInch()) { Engine.Base.Compute.RecordError("Deck property " + srfProp.Name + " has an invalid thickness. Thickness was automatically changed to 2 inches in order to ensure required shear stud engagement per RAM."); compProp.Thickness = 2.0.FromInch(); } ICompDeckProps compDeckProps = m_Model.GetCompositeDeckProps(); try { ramProp = compDeckProps.Add2(compProp.Name, Engine.Base.Query.PropertyValue(compProp, "DeckProfileName").ToString(), compProp.Thickness.ToInch(), compProp.TotalDepth.ToInch() - 1.5); } catch { Engine.Base.Compute.RecordWarning("Deck label for surface property " + srfProp.Name + " not found or invalid for specified thickness. Using default deck profile. Please provide a valid deck name from the RAM Deck Table as a property on the SurfaceProperty named DeckProfileName."); ramProp = compDeckProps.Add2(compProp.Name, "ASC 3W", compProp.Thickness.ToInch(), 4.5); } RAMId.Id = ramProp.lUID; } else if (srfProp is ConstantThickness && !(srfProp.Material is Steel)) { ConstantThickness prop = (ConstantThickness)srfProp; if (prop.PanelType != PanelType.Wall) //Wall surface properties are created on a per wall element basis { IConcSlabProps concSlabProps = m_Model.GetConcreteSlabProps(); IConcSlabProp ramProp; ramProp = concSlabProps.Add(prop.Name, prop.Thickness.ToInch(), prop.Material.Density.ToPoundPerCubicFoot()); RAMId.Id = ramProp.lUID; } } else if (srfProp is ConstantThickness && srfProp.Material is Steel) { ConstantThickness prop = (ConstantThickness)srfProp; if (prop.PanelType != PanelType.Wall) //Wall surface properties are created on a per wall element basis { INonCompDeckProps nonCompDeckProps = m_Model.GetNonCompDeckProps(); INonCompDeckProp ramProp; ramProp = nonCompDeckProps.Add(prop.Name); ramProp.dEffectiveThickness = prop.Thickness.ToInch(); RAMId.Id = ramProp.lUID; } } srfProp.SetAdapterId(RAMId); } //Save file m_IDBIO.SaveDatabase(); return(true); }
/***************************************************/ public static UniformLoadSet ToBHoMObject(this ISurfaceLoadPropertySet ramSrfLoadPropSet) { RAMLiveLoadTypes liveType = RAMLiveLoadTypes.LiveUnReducibleLCa; if (ramSrfLoadPropSet.eLiveLoadType != ELoadCaseType.DeadLCa) { liveType = ramSrfLoadPropSet.eLiveLoadType.ToBHoM(); } else { Engine.Base.Compute.RecordWarning($"Live Load type for load set {ramSrfLoadPropSet.strLabel} was set as Dead. This usually means that no live load is applied in RAM; check results."); } UniformLoadSet uniformLoadSet = Engine.Adapters.RAM.Create.RAMUniformLoadSet( ramSrfLoadPropSet.dDeadLoad.FromKilopoundForcePerSquareInch(), ramSrfLoadPropSet.dConstDeadLoad.FromKilopoundForcePerSquareInch(), ramSrfLoadPropSet.dConstLiveLoad.FromKilopoundForcePerSquareInch(), liveType, ramSrfLoadPropSet.dPartitionLoad.FromKilopoundForcePerSquareInch(), ramSrfLoadPropSet.dConstLiveLoad.FromKilopoundForcePerSquareInch(), ramSrfLoadPropSet.dMassDeadLoad.FromKilopoundForcePerSquareInch(), ramSrfLoadPropSet.strLabel ); // Unique RAM ID RAMId RAMId = new RAMId(); RAMId.Id = ramSrfLoadPropSet.lUID; uniformLoadSet.SetAdapterId(RAMId); return(uniformLoadSet); }
/***************************************************/ public static Bar ToBHoMObject(IHorizBrace ramHorizBrace, ILayoutHorizBrace ramLayoutHorizBrace, double dElevation) { string sectionName = ramHorizBrace.strSectionLabel; ISectionProperty sectionProperty = ToBHoMSection(ramHorizBrace); // Get the start and end pts of every brace double StartSupportX = new double(); double StartSupportY = new double(); double StartSupportZOffset = new double(); double EndSupportX = new double(); double EndSupportY = new double(); double EndSupportZOffset = new double(); double StoryZ = dElevation; // Get coordinates from ILayout Brace ramLayoutHorizBrace.GetLayoutCoordinates(out StartSupportX, out StartSupportY, out StartSupportZOffset, out EndSupportX, out EndSupportY, out EndSupportZOffset); Node startNode = new Node { Position = new oM.Geometry.Point() { X = StartSupportX.FromInch(), Y = StartSupportY.FromInch(), Z = StoryZ.FromInch() + StartSupportZOffset.FromInch() } }; Node endNode = new Node { Position = new oM.Geometry.Point() { X = EndSupportX.FromInch(), Y = EndSupportY.FromInch(), Z = StoryZ.FromInch() + EndSupportZOffset.FromInch() } }; Bar bhomBar = new Bar { StartNode = startNode, EndNode = endNode, SectionProperty = sectionProperty, Name = sectionName }; bhomBar.OrientationAngle = 0; // Unique RAM ID RAMId RAMId = new RAMId(); RAMId.Id = ramLayoutHorizBrace.lUID; bhomBar.SetAdapterId(RAMId); //Add Frame Data fragment RAMFrameData ramFrameData = new RAMFrameData(); ramFrameData.FrameNumber = ramLayoutHorizBrace.lLabel; ramFrameData.Material = ramLayoutHorizBrace.eMaterial.ToString(); bhomBar.Fragments.Add(ramFrameData); bhomBar.Tags.Add("HorizontalBrace"); return(bhomBar); }
/***************************************************/ public static Bar ToBHoMObject(this IVerticalBrace ramVerticalBrace) { // Get the column name string sectionName = ramVerticalBrace.strSectionLabel; ISectionProperty sectionProperty = ToBHoMSection(ramVerticalBrace); // Get the start and end pts of every column SCoordinate startPt = new SCoordinate(); SCoordinate endPt = new SCoordinate(); ramVerticalBrace.GetEndCoordinates(ref startPt, ref endPt); Node startNode = new Node { Position = startPt.PointFromRAM() }; Node endNode = new Node { Position = endPt.PointFromRAM() }; Bar bhomBar = new Bar { StartNode = startNode, EndNode = endNode, SectionProperty = sectionProperty, Name = sectionName }; bhomBar.OrientationAngle = 0; // Unique RAM ID RAMId RAMId = new RAMId(); RAMId.Id = ramVerticalBrace.lUID; bhomBar.SetAdapterId(RAMId); //Add Frame Data fragment RAMFrameData ramFrameData = new RAMFrameData(); ramFrameData.FrameNumber = ramVerticalBrace.lLabel; ramFrameData.FrameType = ramVerticalBrace.eSeismicFrameType.ToString(); ramFrameData.Material = ramVerticalBrace.eMaterial.ToString(); bhomBar.Fragments.Add(ramFrameData); bhomBar.Tags.Add("VerticalBrace"); return(bhomBar); }
/***************************************************/ public static ContourLoadSet ToBHoMObject(this ISurfaceLoadSet ramSrfLoadSet, IStory ramStory) { // Get srf load outline List <Point> srfLoadContourPts = new List <Point>(); double elev = ramStory.dElevation; IPoints srfPolyPts = ramSrfLoadSet.GetPoints(); Polyline srfLoadContour = ToPolyline(srfPolyPts, elev); ContourLoadSet srfLoad = new ContourLoadSet { Contour = srfLoadContour }; // Unique RAM ID RAMId RAMId = new RAMId(); RAMId.Id = ramSrfLoadSet.lUID; srfLoad.SetAdapterId(RAMId); return(srfLoad); }
/***************************************************/ /**** Private methods ****/ /***************************************************/ private bool CreateCollection(IEnumerable <UniformLoadSet> loadSets) { foreach (UniformLoadSet loadSet in loadSets) { try { ISurfaceLoadPropertySets ramSurfaceLoadPropertySets = m_Model.GetSurfaceLoadPropertySets(); int existingLoadPropSetID = 0; //Check if load set already exists for (int i = 0; i < ramSurfaceLoadPropertySets.GetCount(); i++) { ISurfaceLoadPropertySet ramPropSet = ramSurfaceLoadPropertySets.GetAt(i); if (ramPropSet.strLabel == loadSet.Name) { existingLoadPropSetID = ramPropSet.lUID; } } if (existingLoadPropSetID == 0) { //Add the loadset if it does not already exist ISurfaceLoadPropertySet ramLoadSet = ramSurfaceLoadPropertySets.Add(loadSet.Name); int liveCount = 0; foreach (UniformLoadSetRecord loadRecord in loadSet.Loads) { switch (loadRecord.Name) { case "ConstructionDeadLCa": ramLoadSet.dConstDeadLoad = loadRecord.Load.ToKilopoundForcePerSquareInch(); break; case "ConstructionLiveLCa": ramLoadSet.dConstLiveLoad = loadRecord.Load.ToKilopoundForcePerSquareInch(); break; case "DeadLCa": ramLoadSet.dDeadLoad = loadRecord.Load.ToKilopoundForcePerSquareInch(); break; case "MassDeadLCa": ramLoadSet.dMassDeadLoad = loadRecord.Load.ToKilopoundForcePerSquareInch(); break; case "PartitionLCa": ramLoadSet.dPartitionLoad = loadRecord.Load.ToKilopoundForcePerSquareInch(); break; case "LiveLCa": ramLoadSet.eLiveLoadType = ELoadCaseType.LiveReducibleLCa; ramLoadSet.dLiveLoad = loadRecord.Load.ToKilopoundForcePerSquareInch(); liveCount++; break; case "LiveStorageLCa": ramLoadSet.eLiveLoadType = ELoadCaseType.LiveStorageLCa; ramLoadSet.dLiveLoad = loadRecord.Load.ToKilopoundForcePerSquareInch(); liveCount++; break; case "LiveUnReducibleLCa": ramLoadSet.eLiveLoadType = ELoadCaseType.LiveUnReducibleLCa; ramLoadSet.dLiveLoad = loadRecord.Load.ToKilopoundForcePerSquareInch(); liveCount++; break; case "LiveRoofLCa": ramLoadSet.eLiveLoadType = ELoadCaseType.LiveRoofLCa; ramLoadSet.dLiveLoad = loadRecord.Load.ToKilopoundForcePerSquareInch(); liveCount++; break; default: Engine.Base.Compute.RecordWarning($"the record {loadRecord.Name} in {loadSet.Name} was not recognized. Create your UniformLoadSet using CreateRAMUniformLoadSet() in the RAM toolkit!"); break; } } ; if (liveCount > 1) { Engine.Base.Compute.RecordWarning("More than one live load has been set; only the last one will be applied"); } //Set the custom data to return if created RAMId RAMId = new RAMId(); RAMId.Id = ramLoadSet.lUID; loadSet.SetAdapterId(RAMId); } else { //Set the custom data to return if already existing RAMId RAMId = new RAMId(); RAMId.Id = existingLoadPropSetID; loadSet.SetAdapterId(RAMId); } } catch { CreateElementError("UniformLoadSet", loadSet.Name); } } //Save file m_IDBIO.SaveDatabase(); return(true); }
/***************************************************/ /**** Private methods ****/ /***************************************************/ private bool CreateCollection(IEnumerable <Panel> bhomPanels) { //Code for creating a collection of floors and walls in the software List <Panel> panels = bhomPanels.ToList(); // Register Floor types IFloorType ramFloorType; IStories ramStories; IStory ramStory; //Create wall and floor lists with individual heights List <Panel> wallPanels = new List <Panel>(); List <Panel> floors = new List <Panel>(); List <double> panelHeights = new List <double>(); List <Point> panelPoints = new List <Point>(); // Split walls and floors and get all elevations foreach (Panel panel in panels) { double panelNormZ = panel.Normal().Z; //Split walls and floors if (Math.Abs(panelNormZ) < 0.707) // check normal against 45 degree slope { wallPanels.Add(panel); } else { floors.Add(panel); } } ramStories = m_Model.GetStories(); #region Create Floors // Cycle through floors and create on story foreach (Panel panel in floors) { RAMId RAMId = new RAMId(); string name = panel.Name; PolyCurve outlineExternal = panel.OutlineCurve(); ramStory = panel.GetStory(ramStories); ramFloorType = ramStory.GetFloorType(); try { // Set slab edges on FloorType in RAM for external edges ISlabEdges ramSlabEdges = ramFloorType.GetAllSlabEdges(); ISlabEdges ramOpeningEdges = ramFloorType.GetAllSlabOpenings(); // Get external and internal edges of floor panel List <PolyCurve> panelOutlines = new List <PolyCurve>(); List <PolyCurve> openingOutlines = new List <PolyCurve>(); Vector zDown = BH.Engine.Geometry.Create.Vector(0, 0, -1); // RAM requires edges clockwise, flip if counterclockwise PolyCurve cwOutline = (outlineExternal.IsClockwise(zDown) == false) ? outlineExternal.Flip() : outlineExternal; List <ICurve> edgeCrvs = cwOutline.Curves; foreach (ICurve crv in edgeCrvs) { Point startPt = crv.IStartPoint(); Point endPt = crv.IEndPoint(); ramSlabEdges.Add(startPt.X.ToInch(), startPt.Y.ToInch(), endPt.X.ToInch(), endPt.Y.ToInch(), 0); } List <Opening> panelOpenings = panel.Openings; foreach (Opening opening in panelOpenings) { PolyCurve outlineOpening = opening.OutlineCurve(); openingOutlines.Add(outlineOpening); } foreach (PolyCurve outline in openingOutlines) { // RAM requires edges clockwise, flip if counterclockwise PolyCurve cwOpenOutline = (outline.IsClockwise(zDown) == false) ? outline.Flip() : outline; if (!(outlineExternal.IsContaining(cwOpenOutline, false))) { cwOpenOutline = outlineExternal.BooleanIntersection(cwOpenOutline)[0]; Engine.Base.Compute.RecordWarning("Panel " + name + " opening intersects floor boundary. Boolean intersection was used to get opening extents on panel, confirm opening extents in RAM."); } List <ICurve> openEdgeCrvs = cwOpenOutline.Curves; foreach (ICurve crv in openEdgeCrvs) { Point startPt = crv.IStartPoint(); Point endPt = crv.IEndPoint(); ramOpeningEdges.Add(startPt.X.ToInch(), startPt.Y.ToInch(), endPt.X.ToInch(), endPt.Y.ToInch(), 0); } } // Create Deck List <Point> ctrlPoints = cwOutline.ControlPoints(); if (ctrlPoints.First() != ctrlPoints.Last()) { ctrlPoints.Add(ctrlPoints.Last().DeepClone()); } ISurfaceProperty srfProp = panel.Property; int deckProplUID = GetAdapterId <int>(srfProp); //Add decks, then set deck points per outline IDecks ramDecks = ramFloorType.GetDecks(); IDeck ramDeck = ramDecks.Add(deckProplUID, ctrlPoints.Count); IPoints ramPoints = ramDeck.GetPoints(); // Create list of SCoordinates for floor outlines List <SCoordinate> cornersExt = new List <SCoordinate>(); foreach (Point point in ctrlPoints) { SCoordinate cornerExt = point.ToRAM(); cornersExt.Add(cornerExt); } for (int k = 0; k < cornersExt.Count; k++) { ramPoints.Delete(k); ramPoints.InsertAt(k, cornersExt[k]); } ramDeck.SetPoints(ramPoints); // Add warning to report floors flattened to level as required for RAM if (Math.Abs(panel.Normal().Z) < 1) { Engine.Base.Compute.RecordWarning("Panel " + name + " snapped to level " + ramStory.strLabel + "."); } } catch { CreateElementError("panel", name); } } #endregion #region Create Walls //Cycle through walls; if wall crosses level place at level foreach (Panel wallPanel in wallPanels) { string name = wallPanel.Name; try { double thickness = 0.2; // default thickness if (wallPanel.Property is ConstantThickness) { ConstantThickness prop = (ConstantThickness)wallPanel.Property; thickness = prop.Thickness; } // Find outline of planar panel PolyCurve outline = BH.Engine.Spatial.Query.OutlineCurve(wallPanel); List <Point> wallPts = outline.DiscontinuityPoints(); List <Point> sortedWallPts = wallPts.OrderBy(p => p.X).ToList(); Point leftPt = sortedWallPts.First(); Point rtPt = sortedWallPts.Last(); bool downToRight = leftPt.Y > rtPt.Y; BoundingBox wallBounds = BH.Engine.Geometry.Query.Bounds(outline); Point wallMin = wallBounds.Min; Point wallMax = wallBounds.Max; double tempY = wallMin.Y; wallMin.Y = downToRight ? wallMax.Y : wallMin.Y; wallMax.Y = downToRight ? tempY : wallMax.Y; for (int i = 0; i < ramStories.GetCount(); i++) { ramStory = ramStories.GetAt(i); // If wall crosses level, add wall to ILayoutWalls for that level if (Math.Round(wallMax.Z.ToInch(), 0) >= ramStory.dElevation && Math.Round(wallMin.Z.ToInch(), 0) < ramStory.dElevation) { ramFloorType = ramStory.GetFloorType(); //Get ILayoutWalls of FloorType and add wall ILayoutWalls ramLayoutWalls = ramFloorType.GetLayoutWalls(); ILayoutWall ramLayoutWall = ramLayoutWalls.Add(EMATERIALTYPES.EWallPropConcreteMat, wallMin.X.ToInch(), wallMin.Y.ToInch(), 0, 0, wallMax.X.ToInch(), wallMax.Y.ToInch(), 0, 0, thickness.ToInch()); //Set lateral ramLayoutWall.eFramingType = EFRAMETYPE.MemberIsLateral; IWalls ramWalls = ramLayoutWall.GetAssociatedStoryWalls(); IWall ramWall = ramWalls.GetAt(0); // Find opening location, width, and height from outline and apply foreach (Opening open in wallPanel.Openings) { PolyCurve openOutline = open.OutlineCurve(); BoundingBox openBounds = BH.Engine.Geometry.Query.Bounds(openOutline); Point openMin = openBounds.Min; Point openMax = openBounds.Max; if ((openMin.Z.ToInch() >= ramStory.dElevation - ramStory.dFlrHeight) && (openMin.Z.ToInch() < ramStory.dElevation)) { IFinalWallOpenings ramWallOpenings = ramWall.GetFinalOpenings(); int openOverlapCount = 0; for (int j = 0; i < ramWallOpenings.GetCount(); j++) { IFinalWallOpening testOpen = ramWallOpenings.GetAt(j); IPoints openingPts = testOpen.GetOpeningVertices(); //Re-add first point to close Polygon IPoint firstOPt = openingPts.GetAt(0); SCoordinate firstOCoord = new SCoordinate(); firstOPt.GetCoordinate(ref firstOCoord); openingPts.Add(firstOCoord); Polyline wallOpeningOutline = openingPts.ToPolyline(); List <Point> intPts = wallOpeningOutline.ICurveIntersections(openOutline); if (wallOpeningOutline.IsContaining(openOutline) || openOutline.IsContaining(wallOpeningOutline) || intPts.Count > 0) { openOverlapCount += 1; } } if (openOverlapCount == 0) { //Get opening on wall extents if (!(outline.IsContaining(openOutline, false))) { openOutline = outline.BooleanIntersection(openOutline)[0]; Engine.Base.Compute.RecordWarning("Panel " + name + " opening intersects wall boundary. Boolean intersection was used to get opening extents on panel."); } Point closestOpenPt = BH.Engine.Geometry.Query.ClosestPoint(wallMin, openOutline.ControlPoints()); double distX = Math.Sqrt(Math.Pow(closestOpenPt.X - wallMin.X, 2) + Math.Pow(closestOpenPt.Y - wallMin.Y, 2)); double distZinch = openBounds.Min.Z.ToInch() - (ramStory.dElevation - ramStory.dFlrHeight); double openWidth = Math.Sqrt(Math.Pow(openBounds.Max.X - openBounds.Min.X, 2) + Math.Pow(openBounds.Max.Y - openBounds.Min.Y, 2)); double openHt = openBounds.Max.Z - openBounds.Min.Z; //Add opening to RAM IRawWallOpenings ramRawWallOpenings = ramWall.GetRawOpenings(); ramRawWallOpenings.Add(EDA_MEMBER_LOC.eBottomStart, distX.ToInch(), distZinch, openWidth.ToInch(), openHt.ToInch()); } } } } } } catch { CreateElementError("panel", name); } } #endregion //Save file m_IDBIO.SaveDatabase(); return(true); }
/***************************************************/ /**** Private methods ****/ /***************************************************/ private List <ISurfaceProperty> ReadISurfaceProperties(List <string> ids = null) { List <ISurfaceProperty> propList = new List <ISurfaceProperty>(); ISteelCriteria steelCriteria = m_Model.GetSteelCriteria(); IDeckTableEntries deckProfiles = steelCriteria.GetDeckTableEntries(); ICompDeckProps compDeckProps = m_Model.GetCompositeDeckProps(); for (int i = 0; i < compDeckProps.GetCount(); i++) { ICompDeckProp DeckProp = compDeckProps.GetAt(i); string deckLabel = DeckProp.strLabel; string deckProfileName = DeckProp.strDeckType; IDeckTableEntry profile = null; for (int j = 0; j < deckProfiles.GetCount(); j++) // find ram deck profile to get props { profile = deckProfiles.GetAt(j); if (profile.strDeckName == deckLabel) { break; } } double concThickness = DeckProp.dThickAboveFlutes.FromInch(); double deckProfileThickness = profile.dTD.FromInch(); double deckThickness = concThickness + deckProfileThickness; IMaterialFragment material = Engine.Structure.Create.Concrete("Concrete Over Deck"); Ribbed deck2DProp = new Ribbed(); deck2DProp.Name = deckLabel; deck2DProp.Thickness = concThickness; deck2DProp.PanelType = PanelType.Slab; deck2DProp.Material = material; deck2DProp.Spacing = profile.dRSpac; deck2DProp.StemWidth = profile.dWR; deck2DProp.TotalDepth = deckThickness; // Unique RAM ID RAMId RAMId = new RAMId(); RAMId.Id = DeckProp.lUID; deck2DProp.SetAdapterId(RAMId); RAMDeckData ramDeckData = new RAMDeckData(); ramDeckData.DeckProfileName = deckProfileName; deck2DProp.Fragments.Add(ramDeckData); propList.Add(deck2DProp); } IConcSlabProps concSlabProps = m_Model.GetConcreteSlabProps(); for (int i = 0; i < concSlabProps.GetCount(); i++) { IConcSlabProp DeckProp = concSlabProps.GetAt(i); double deckThickness = DeckProp.dThickness.FromInch(); string deckLabel = DeckProp.strLabel; IMaterialFragment material = Engine.Structure.Create.Concrete("Concrete"); ConstantThickness deck2DProp = new ConstantThickness(); deck2DProp.Name = deckLabel; deck2DProp.Material = material; deck2DProp.Thickness = deckThickness; deck2DProp.PanelType = PanelType.Slab; propList.Add(deck2DProp); // Unique RAM ID RAMId RAMId = new RAMId(); RAMId.Id = DeckProp.lUID; deck2DProp.SetAdapterId(RAMId); } INonCompDeckProps nonCompDeckProps = m_Model.GetNonCompDeckProps(); for (int i = 0; i < nonCompDeckProps.GetCount(); i++) { INonCompDeckProp DeckProp = nonCompDeckProps.GetAt(i); double deckThickness = DeckProp.dEffectiveThickness.FromInch(); string deckLabel = DeckProp.strLabel; IMaterialFragment material = Engine.Structure.Create.Steel("Metal Deck"); ConstantThickness deck2DProp = new ConstantThickness(); deck2DProp.Name = deckLabel; deck2DProp.Material = material; deck2DProp.Thickness = deckThickness; deck2DProp.PanelType = PanelType.Slab; propList.Add(deck2DProp); // Unique RAM ID RAMId RAMId = new RAMId(); RAMId.Id = DeckProp.lUID; deck2DProp.SetAdapterId(RAMId); } return(propList); }
/***************************************************/ /**** Private methods ****/ /***************************************************/ private bool CreateCollection(IEnumerable <Bar> bhomBars) { //Code for creating a collection of bars in the software List <Bar> bars = bhomBars.ToList(); //Get the stories in the model IStories ramStories = m_Model.GetStories(); //Cycle through bars, split to beam and col lists, then add to corresponding story. List <Bar> barBeams = new List <Bar>(); List <Bar> barCols = new List <Bar>(); foreach (Bar testBar in bars) { bool isBeam = Math.Abs(testBar.Tangent(true).DotProduct(Vector.ZAxis)) < 0.5; if (isBeam) { barBeams.Add(testBar); } else { barCols.Add(testBar); } } //Create beams per story, flat foreach (Bar bar in barBeams) { string name = bar.Name; ILayoutBeam ramBeam; try { RAMId RAMId = new RAMId(); IStory barStory = bar.GetStory(StructuralUsage1D.Beam, ramStories); IFloorType ramFloorType = barStory.GetFloorType(); ILayoutBeams ramBeams = ramFloorType.GetLayoutBeams(); double zStart = bar.StartNode.Position.Z.ToInch() - barStory.dElevation; double zEnd = bar.EndNode.Position.Z.ToInch() - barStory.dElevation; // Get beam fragment cantilever data double startCant = 0; double endCant = 0; bool isStubCant = false; RAMFrameData ramFrameData = bar.FindFragment <RAMFrameData>(typeof(RAMFrameData)); if (ramFrameData != null) { startCant = ramFrameData.StartCantilever; endCant = ramFrameData.EndCantilever; isStubCant = ramFrameData.IsStubCantilever; } if (isStubCant.Equals("True") || isStubCant.Equals("1")) //Check bool per RAM or GH preferred boolean context { SCoordinate startPt, endPt; if (startCant > 0) // Ensure startPt corresponds with support point { startPt = bar.EndNode.Position.ToRAM(); endPt = bar.StartNode.Position.ToRAM(); } else { startPt = bar.StartNode.Position.ToRAM(); endPt = bar.EndNode.Position.ToRAM(); } ramBeam = ramBeams.AddStubCantilever(bar.SectionProperty.Material.ToRAM(), startPt.dXLoc, startPt.dYLoc, 0, endPt.dXLoc, endPt.dYLoc, 0); // No Z offsets, beams flat on closest story } else { // Get support points Vector barDir = bar.Tangent(true); Point startSupPt = BH.Engine.Geometry.Modify.Translate(bar.StartNode.Position, barDir * startCant); Point endSupPt = BH.Engine.Geometry.Modify.Translate(bar.EndNode.Position, -barDir * endCant); SCoordinate start = startSupPt.ToRAM(); SCoordinate end = endSupPt.ToRAM(); ramBeam = ramBeams.Add(bar.SectionProperty.Material.ToRAM(), start.dXLoc, start.dYLoc, 0, end.dXLoc, end.dYLoc, 0); // No Z offsets, beams flat on closest story if (startSupPt.X < endSupPt.X || (startSupPt.X == endSupPt.X && startSupPt.Y > endSupPt.Y)) { ramBeam.dStartCantilever = startCant.FromInch(); ramBeam.dEndCantilever = endCant.FromInch(); } else { ramBeam.dStartCantilever = endCant.FromInch(); ramBeam.dEndCantilever = startCant.FromInch(); } } // Add warning to report distance of snapping to level as required for RAM if (zStart != 0 || zEnd != 0) { Engine.Base.Compute.RecordWarning("Bar " + name + " snapped to level " + barStory.strLabel + ". Bar moved " + Math.Round(zStart, 2).ToString() + " inches at start and " + Math.Round(zEnd, 2).ToString() + " inches at end."); } IBeams beamsOnStory = barStory.GetBeams(); IBeam beam = beamsOnStory.Get(ramBeam.lUID); beam.strSectionLabel = bar.SectionProperty.Name; // beam.EAnalyzeFlag = EAnalyzeFlag.eAnalyze; deprecated in API RAMId.Id = beam.lUID; bar.SetAdapterId(RAMId); } catch { CreateElementError("bar", name); } } //Create columns at each story with offset per actual height foreach (Bar bar in barCols) { string name = bar.Name; try { RAMId RAMId = new RAMId(); IStory barStory = bar.GetStory(StructuralUsage1D.Column, ramStories); List <Node> colNodes = new List <Node>() { bar.StartNode, bar.EndNode }; colNodes.Sort((x, y) => x.Position.Z.CompareTo(y.Position.Z)); double xBtm = colNodes[0].Position.X.ToInch(); double yBtm = colNodes[0].Position.Y.ToInch(); double zBtm = colNodes[0].Position.Z.ToInch() - barStory.dElevation; double xTop = colNodes[1].Position.X.ToInch(); double yTop = colNodes[1].Position.Y.ToInch(); double zTop = colNodes[1].Position.Z.ToInch() - barStory.dElevation + barStory.dFlrHeight; IFloorType ramFloorType = barStory.GetFloorType(); ILayoutColumns ramColumns = ramFloorType.GetLayoutColumns(); ILayoutColumn ramColumn; // Get RAM column data bool isHanging = false; RAMFrameData ramFrameData = bar.FindFragment <RAMFrameData>(typeof(RAMFrameData)); if (ramFrameData != null) { isHanging = ramFrameData.IsHangingColumn; } if (isHanging.Equals("True") || isHanging.Equals("1")) //Check bool per RAM or GH preferred boolean context { ramColumn = ramColumns.Add3(bar.SectionProperty.Material.ToRAM(), xBtm, yBtm, xTop, yTop, 0, 0, 1); //No Z offsets, cols start and end at stories } else if (bar.IsVertical()) { //Failing if no section property is provided ramColumn = ramColumns.Add(bar.SectionProperty.Material.ToRAM(), xTop, yTop, 0, 0); //No Z offsets, cols start and end at stories } else { ramColumn = ramColumns.Add2(bar.SectionProperty.Material.ToRAM(), xTop, yTop, xBtm, yBtm, 0, 0); //No Z offsets, cols start and end at stories } //Set column properties IColumns colsOnStory = barStory.GetColumns(); IColumn column = colsOnStory.Get(ramColumn.lUID); column.strSectionLabel = bar.SectionProperty.Name; column.EAnalyzeFlag = EAnalyzeFlag.eAnalyze; RAMId.Id = column.lUID; bar.SetAdapterId(RAMId); } catch { CreateElementError("bar", name); } } //Save file m_IDBIO.SaveDatabase(); return(true); }
/***************************************************/ public static Grid ToBHoMObject(this IModelGrid ramModelGrid, IGridSystem ramGridSystem, int counter) { Grid myGrid = new Grid(); // Get the parameters of Gridsystem string gridSystemLabel = ramGridSystem.strLabel; // Set the name of the GridSystem from RAM int gridSystemID = ramGridSystem.lUID; //Set the lUID from RAM string gridSystemType = ramGridSystem.eOrientationType.ToString(); // Set the orientation type double gridXoffset = ramGridSystem.dXOffset.FromInch(); // Set the offset of the GridSystem from 0 along the X axis double gridYoffset = ramGridSystem.dYOffset.FromInch(); // Set the offset of the GridSystem from 0 along the Y axis double gridSystemRotation = ramGridSystem.dRotation; // Set the rotation angle of the GridSystem double gridRotAngle = 0; // Add the properties of the GridSystem as a fragment RAMId RAMId = new RAMId(); RAMId.Id = gridSystemID; myGrid.SetAdapterId(RAMId); RAMGridData ramGridData = new RAMGridData(); ramGridData.Label = gridSystemLabel; ramGridData.Type = gridSystemType; ramGridData.XOffset = gridXoffset; ramGridData.YOffset = gridYoffset; ramGridData.Rotation = gridSystemRotation; //Get info for each grid line int gridLinelUID = ramModelGrid.lUID; //unique ID od of the grid line object string gridLineLabel = ramModelGrid.strLabel; // label of the gridline double gridLineCoord_Angle = ramModelGrid.dCoordinate_Angle; // the grid coordinate or angle string gridLineAxis = ramModelGrid.eAxis.ToString(); // grid line axis , X/Radial Y/Circular double dMaxLimit = ramModelGrid.dMaxLimitValue.FromInch(); // maximum limit specified by the user to which gridline will be drawn from origin double dMinLimit = ramModelGrid.dMinLimitValue.FromInch(); // minimum limit specified by the user to which gridline will be drawn from origin double GridLength = 100; //default grid length value //Set max and min limit values based on if they are used or if -1 is returned if (dMaxLimit != 0) { GridLength = 0; } Point gridCoordPoint1 = new Point(); Point gridCoordPoint2 = new Point(); if (gridSystemType == "eGridOrthogonal") // code to place grids in orthogonal X and Y { //Set Grid start offset from system origin double spacing = ramModelGrid.dCoordinate_Angle.FromInch(); //check the orientation to place grids accordingly if (gridLineAxis == "eGridXorRadialAxis") { // position of first point gridCoordPoint1.X = gridXoffset + spacing; // at the origin point we add the spacing of the grid gridCoordPoint1.Y = gridYoffset + dMinLimit; gridCoordPoint1.Z = 0; // position of second point gridCoordPoint2.X = gridXoffset + spacing; gridCoordPoint2.Y = gridYoffset + GridLength + dMaxLimit;// add the max limit to the origin point to get full length of gridline gridCoordPoint2.Z = 0; } else if (gridLineAxis == "eGridYorCircularAxis") { // position of first point gridCoordPoint1.X = gridXoffset + dMinLimit; // at the origin point we add the coordinate of the grid gridCoordPoint1.Y = gridYoffset + spacing; gridCoordPoint1.Z = 0; // position of second point gridCoordPoint2.X = gridXoffset + GridLength + dMaxLimit; // add the max limit to the origin point to get full length of gridline gridCoordPoint2.Y = gridYoffset + spacing; gridCoordPoint2.Z = 0; } // initialize a new line to create the gridline Line gridLine = new Line(); gridLine.Start = gridCoordPoint1; gridLine.End = gridCoordPoint2; //Create a new grid object from the drawn line and return it myGrid = new Grid { Curve = gridLine, Name = gridLineLabel }; } else if (gridSystemType == "eGridRadial") //code to place grids radially { gridRotAngle = (Math.PI / 180) * (gridLineCoord_Angle + gridSystemRotation); if (gridLineAxis == "eGridXorRadialAxis") { // position of first point gridCoordPoint1.X = gridXoffset; // at the origin point we add the coordinate of the grid gridCoordPoint1.Y = gridYoffset; gridCoordPoint1.Z = 0; // position of second point gridCoordPoint2.X = gridXoffset + Math.Cos(gridRotAngle) * (GridLength + dMaxLimit); // add the max limit to the origin point to get full length of gridline gridCoordPoint2.Y = gridYoffset + Math.Sin(gridRotAngle) * (GridLength + dMaxLimit); gridCoordPoint2.Z = 0; // initialize a new line to create the gridline Line gridLine = new Line(); gridLine.Start = gridCoordPoint1; gridLine.End = gridCoordPoint2; //Create a new grid object from the drawn line and return it myGrid = new Grid { Curve = gridLine, Name = gridLineLabel }; } else if (gridLineAxis == "eGridYorCircularAxis") { // position of first point gridCoordPoint1.X = gridXoffset; // at the origin point we add the coordinate of the grid gridCoordPoint1.Y = gridYoffset; gridCoordPoint1.Z = 0; // initialize a new line to create the gridline Circle gridLine = new Circle(); Vector cirNormal = new Vector { X = 0, Y = 0, Z = 1 }; gridLine.Centre = gridCoordPoint1; gridLine.Normal = cirNormal; gridLine.Radius = gridLineCoord_Angle.FromInch(); //Create a new grid object from the drawn line and return it myGrid = new Grid { Curve = gridLine, Name = gridLineLabel }; } } /// end of Grid toBhomObject method return(myGrid); }
/***************************************************/ public static Panel ToBHoMObject(this IWall ramWall) { //Find corner points of wall in RAM model SCoordinate TopstartPt = new SCoordinate(); SCoordinate TopendPt = new SCoordinate(); SCoordinate BottomstartPt = new SCoordinate(); SCoordinate BottomendPt = new SCoordinate(); ramWall.GetEndCoordinates(ref TopstartPt, ref TopendPt, ref BottomstartPt, ref BottomendPt); // Create list of points List <Point> corners = new List <Point>(); corners.Add(TopstartPt.PointFromRAM()); corners.Add(TopendPt.PointFromRAM()); corners.Add(BottomendPt.PointFromRAM()); corners.Add(BottomstartPt.PointFromRAM()); corners.Add(TopstartPt.PointFromRAM()); // Create outline from corner points Polyline outline = new Polyline(); outline.ControlPoints = corners; //Create opening outlines List <ICurve> wallOpeningPLs = new List <ICurve>(); List <Opening> bhomWallOpenings = new List <Opening>(); // Create openings IFinalWallOpenings IFinalWallOpenings = ramWall.GetFinalOpenings(); IRawWallOpenings rawOpenings = ramWall.GetRawOpenings(); if (rawOpenings.GetCount() > 0) { IRawWallOpening check = rawOpenings.GetAt(0); } for (int i = 0; i < IFinalWallOpenings.GetCount(); i++) { IFinalWallOpening IFinalWallOpening = IFinalWallOpenings.GetAt(i); IPoints openingPts = IFinalWallOpening.GetOpeningVertices(); //Re-add first point to close Polygon IPoint firstOPt = openingPts.GetAt(0); SCoordinate firstOCoord = new SCoordinate(); firstOPt.GetCoordinate(ref firstOCoord); openingPts.Add(firstOCoord); ICurve wallOpeningOutline = ToPolyline(openingPts); Opening bhomOpening = Engine.Structure.Create.Opening(wallOpeningOutline); bhomWallOpenings.Add(bhomOpening); } // Create wall Panel bhomPanel = Engine.Structure.Create.Panel(outline, bhomWallOpenings); HashSet <String> tag = new HashSet <string>(); tag.Add("Wall"); //Get wall section property ConstantThickness wall2DProp = new ConstantThickness(); string wallLabel = ""; double wallThickness = ramWall.dThickness.FromInch(); IMaterialFragment Material = null; if (ramWall.eMaterial == EMATERIALTYPES.EWallPropConcreteMat) { wallLabel = "Concrete " + ramWall.dThickness.ToString() + " in"; Material = Engine.Structure.Create.Concrete("Concrete"); } else { wallLabel = "Other " + ramWall.dThickness.ToString() + " in"; Material = Engine.Structure.Create.Concrete("Other"); } wall2DProp.Name = wallLabel; wall2DProp.Thickness = wallThickness; wall2DProp.PanelType = PanelType.Wall; wall2DProp.Material = Material; bhomPanel.Property = wall2DProp; bhomPanel.Tags = tag; bhomPanel.Name = ramWall.lLabel.ToString(); // Add custom data RAMId RAMId = new RAMId(); RAMId.Id = ramWall.lUID; bhomPanel.SetAdapterId(RAMId); bhomPanel.Tags.Add("Wall"); return(bhomPanel); }
/***************************************************/ public static Panel ToBHoMObject(IDeck ramDeck, IModel ramModel, int ramStoryUID) { //Get panel props EDeckType type = ramDeck.eDeckPropType; //Find polylines of deck in RAM Model //get count of deck polygons double deckPolyCount = ramDeck.GetNumFinalPolygons(ramStoryUID); if (deckPolyCount == 0) { Engine.Base.Compute.RecordWarning($"Floor with RAM lUID {ramDeck.lUID} contains no edges."); return(null); } //Initial only gets first outline poly for exterior edge, rest for openings IPoints pplPoints = ramDeck.GetFinalPolygon(ramStoryUID, 0); //Re-add first point to close Polygon IPoint first = pplPoints.GetAt(0); SCoordinate firstCoord = new SCoordinate(); first.GetCoordinate(ref firstCoord); pplPoints.Add(firstCoord); //Create outline polyline Polyline outline = ToPolyline(pplPoints); //Create opening outlines List <ICurve> openingPLs = new List <ICurve>(); for (int i = 1; i < deckPolyCount; i++) { IPoints openingPts = ramDeck.GetFinalPolygon(ramStoryUID, i); //Re-add first point to close Polygon IPoint firstOPt = openingPts.GetAt(0); SCoordinate firstOCoord = new SCoordinate(); firstOPt.GetCoordinate(ref firstOCoord); openingPts.Add(firstOCoord); ICurve openingOutline = ToPolyline(openingPts); //Create openings per outline polylines openingPLs.Add(openingOutline); } //Create panel per outline polyline List <Opening> bhomOpenings = new List <Opening>(); Panel bhomPanel = Engine.Structure.Create.Panel(outline, bhomOpenings); //Create openings per openings polylines int numOpenings = openingPLs.Count(); //Create openings for (int i = 0; i < numOpenings; i++) { Opening bhomOpening = Engine.Structure.Create.Opening(openingPLs[i]); bhomOpenings.Add(bhomOpening); } //Create panel and add attributes; bhomPanel.Openings = bhomOpenings; HashSet <String> tag = new HashSet <string>(); tag.Add("Floor"); bhomPanel.Tags = tag; bhomPanel.Name = type.ToString(); RAMId RAMId = new RAMId(); RAMId.Id = ramDeck.lUID; bhomPanel.SetAdapterId(RAMId); return(bhomPanel); }
/***************************************************/ public static Bar ToBHoMObject(this IBeam ramBeam, ILayoutBeam ramLayoutBeam, double dElevation) { // Get coordinates from IBeam SCoordinate startPt = new SCoordinate(); SCoordinate endPt = new SCoordinate(); ramBeam.GetCoordinates(EBeamCoordLoc.eBeamEnds, ref startPt, ref endPt); Node startNode = new Node { Position = startPt.PointFromRAM() }; Node endNode = new Node { Position = endPt.PointFromRAM() }; //Assign section property per bar string sectionName = ramBeam.strSectionLabel; ISectionProperty sectionProperty = ToBHoMSection(ramBeam); // Create bars with section properties Bar bhomBar = new Bar { StartNode = startNode, EndNode = endNode, SectionProperty = sectionProperty, Name = sectionName }; // Set Properties bhomBar.OrientationAngle = 0; // Unique RAM ID RAMId RAMId = new RAMId(); RAMId.Id = ramBeam.lUID; bhomBar.SetAdapterId(RAMId); RAMFrameData ramFrameData = new RAMFrameData(); ramFrameData.FrameNumber = ramBeam.lLabel; ramFrameData.StartCantilever = ramBeam.dStartCantilever.FromInch(); ramFrameData.EndCantilever = ramBeam.dEndCantilever.FromInch(); ramFrameData.IsStubCantilever = (ramLayoutBeam.IsStubCantilever() == 1); ramFrameData.FrameType = ramBeam.eFramingType.ToString(); ramFrameData.Material = ramBeam.eMaterial.ToString(); bhomBar.Tags.Add("Beam"); // Get Steel beam results ISteelBeamDesignResult Result = ramBeam.GetSteelDesignResult(); DAArray ppalNumStuds = Result.GetNumStudsInSegments(); int numStudSegments = new int(); ppalNumStuds.GetSize(ref numStudSegments); double camber = ramBeam.dCamber; int studCount = 0; IAnalyticalResult AnalyticalResult = ramBeam.GetAnalyticalResult(); COMBO_MATERIAL_TYPE Steel_Grav = COMBO_MATERIAL_TYPE.GRAV_STEEL; IMemberForces IMemberForces = AnalyticalResult.GetMaximumComboReactions(Steel_Grav); //Add studs to custom Data by total stud count only for (int i = 0; i < numStudSegments; i++) { var segStudCount = new object(); ppalNumStuds.GetAt(i, ref segStudCount); string segStudStr = segStudCount.ToString(); int segStudNum = System.Convert.ToInt16(segStudStr); studCount += segStudNum; ramFrameData.Studs = studCount; } // Add camber to Custom Data if (camber > Double.MinValue) { ramFrameData.Camber = camber.FromInch(); } // Translate RAM Releases to BHoM Releases (in progress; logic not yet complete since it is difficult map Maj/Min axes to global XYZ axes for every member) // May be better to just do in custom data, although if we can do this mapping it may be useful bhomBar.Release = new BarRelease(); bhomBar.Release.StartRelease = new Constraint6DOF(); bhomBar.Release.EndRelease = new Constraint6DOF(); bhomBar.Release.StartRelease.RotationX = new DOFType(); bhomBar.Release.EndRelease.RotationX = new DOFType(); bhomBar.Release.StartRelease.RotationY = new DOFType(); bhomBar.Release.EndRelease.RotationY = new DOFType(); if (ramBeam.bMajAxisBendFixedStart == 1) { bhomBar.Release.StartRelease.RotationX = DOFType.Fixed; } else { bhomBar.Release.StartRelease.RotationX = DOFType.Free; } if (ramBeam.bMajAxisBendFixedEnd == 1) { bhomBar.Release.EndRelease.RotationX = DOFType.Fixed; } else { bhomBar.Release.EndRelease.RotationX = DOFType.Free; } if (ramBeam.bMinAxisBendFixedStart == 1) { bhomBar.Release.StartRelease.RotationY = DOFType.Fixed; } else { bhomBar.Release.StartRelease.RotationY = DOFType.Free; } if (ramBeam.bMinAxisBendFixedEnd == 1) { bhomBar.Release.EndRelease.RotationY = DOFType.Fixed; } else { bhomBar.Release.EndRelease.RotationY = DOFType.Free; } double DCI = Result.dDesignCapacityInteraction; double CDI = Result.dCriticalDeflectionInteraction; // Add DCI and CDI data ramFrameData.DesignCapacityInteraction = DCI; ramFrameData.CriticalDeflectionInteraction = CDI; bhomBar.Fragments.Add(ramFrameData); return(bhomBar); }
/***************************************************/ public static Bar ToBHoMObject(this IColumn ramColumn) { // Get the column name string section = ramColumn.strSectionLabel; // Get the start and end pts of every column SCoordinate startPt = new SCoordinate(); SCoordinate endPt = new SCoordinate(); ramColumn.GetEndCoordinates(ref startPt, ref endPt); Node startNode = new Node { Position = startPt.PointFromRAM() }; Node endNode = new Node { Position = endPt.PointFromRAM() }; //Assign section property per bar string sectionName = ramColumn.strSectionLabel; ISectionProperty sectionProperty = ToBHoMSection(ramColumn); // Create bars with section properties Bar bhomBar = new Bar { StartNode = startNode, EndNode = endNode, SectionProperty = sectionProperty, Name = sectionName }; // Translate RAM Releases to BHoM Releases (in progress; logic not yet complete since it is difficult map Maj/Min axes to global XYZ axes for every member) // May be better to just do in custom data, although if we can do this mapping it may be useful bhomBar.Release = new BarRelease(); bhomBar.Release.StartRelease = new Constraint6DOF(); bhomBar.Release.EndRelease = new Constraint6DOF(); bhomBar.Release.StartRelease.RotationX = new DOFType(); bhomBar.Release.EndRelease.RotationX = new DOFType(); bhomBar.Release.StartRelease.RotationY = new DOFType(); bhomBar.Release.EndRelease.RotationY = new DOFType(); if (ramColumn.bMajAxisBendFixedTop == 1) { bhomBar.Release.StartRelease.RotationX = DOFType.Fixed; } else { bhomBar.Release.StartRelease.RotationX = DOFType.Free; } if (ramColumn.bMajAxisBendFixedBot == 1) { bhomBar.Release.EndRelease.RotationX = DOFType.Fixed; } else { bhomBar.Release.EndRelease.RotationX = DOFType.Free; } if (ramColumn.bMinAxisBendFixedTop == 1) { bhomBar.Release.StartRelease.RotationY = DOFType.Fixed; } else { bhomBar.Release.StartRelease.RotationY = DOFType.Free; } if (ramColumn.bMinAxisBendFixedBot == 1) { bhomBar.Release.EndRelease.RotationY = DOFType.Fixed; } else { bhomBar.Release.EndRelease.RotationY = DOFType.Free; } bhomBar.OrientationAngle = 0; // Add RAM Unique ID, custom Data RAMId RAMId = new RAMId(); RAMId.Id = ramColumn.lUID; bhomBar.SetAdapterId(RAMId); //Add Frame Data fragment RAMFrameData ramFrameData = new RAMFrameData(); ramFrameData.FrameNumber = ramColumn.lLabel; ramFrameData.FrameType = ramColumn.eFramingType.ToString(); ramFrameData.Material = ramColumn.eMaterial.ToString(); ramFrameData.IsHangingColumn = (ramColumn.bHanger == 1); bhomBar.Fragments.Add(ramFrameData); bhomBar.Tags.Add("Column"); return(bhomBar); }