/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static ILayoutBeam ToRAM(this Bar bar, ILayoutBeams iLayoutBeams) { ILayoutBeam iLayoutBeam = iLayoutBeams.GetAt(0); SCoordinate start = bar.StartNode.Position.ToRAM(); SCoordinate end = bar.EndNode.Position.ToRAM(); //Set support coordinates and name //CAUTION: different from actual end points and cantilevers hardcoded iLayoutBeam.SetLayoutCoordinates(start.dXLoc, start.dYLoc, 0, end.dXLoc, end.dYLoc, 0, 0, 0); iLayoutBeam.strSectionLabel = bar.SectionProperty.DescriptionOrName(); return(iLayoutBeam); }
/***************************************************/ /**** Private method ****/ /***************************************************/ // Essentially the same as the create method; experimenting with when it gets called by the BHoM "push" component protected bool Update(IEnumerable <Bar> bars) { //Access model IDBIO1 RAMDataAccIDBIO = m_Application.GetDispInterfacePointerByEnum(EINTERFACES.IDBIO1_INT); IModel IModel = m_Application.GetDispInterfacePointerByEnum(EINTERFACES.IModel_INT); foreach (Bar bar in bars) { //Extract ID int ID = (int)GetAdapterId(bar); if (BH.Engine.Structure.Query.IsVertical(bar)) { IColumn IColumn = IModel.GetColumn(ID); ILayoutColumn ILayoutColumn = IModel.GetLayoutColumn(ID); // Move column double xStart = bar.StartNode.Position.X; double yStart = bar.StartNode.Position.Y; double zStart = bar.StartNode.Position.Z; double xEnd = bar.EndNode.Position.X; double yEnd = bar.EndNode.Position.Y; double zEnd = bar.EndNode.Position.Z; // Need level rather than offset for setting (still in progress) ILayoutColumn.SetLayoutCoordinates2(xStart, yStart, zStart, xEnd, yEnd, zEnd); // Change section property of column IColumn.strSectionLabel = bar.Name; } else { IBeam IBeam = IModel.GetBeam(ID); ILayoutBeam ILayoutBeam = IModel.GetLayoutBeam(ID); // Change section property of column IBeam.strSectionLabel = bar.Name; } } return(true); }
/***************************************************/ /**** Private methods ****/ /***************************************************/ private List <Bar> ReadBars(List <string> ids = null) { //Implement code for reading bars List <Bar> bhomBars = new List <Bar>(); // Get stories IStories IStories = m_Model.GetStories(); int numStories = IStories.GetCount(); // Get all elements on each story for (int i = 0; i < numStories; i++) { //Get Columns IColumns IColumns = IStories.GetAt(i).GetColumns(); int numColumns = IColumns.GetCount(); //Get Beams IFloorType IFloorType = IStories.GetAt(i).GetFloorType(); ILayoutBeams ILayoutBeams = IFloorType.GetLayoutBeams(); IBeams IBeams = IStories.GetAt(i).GetBeams(); int numLayoutBeams = ILayoutBeams.GetCount(); int numBeams = IBeams.GetCount(); //Get Vertical Braces IVerticalBraces IVBraces = IStories.GetAt(i).GetVerticalBraces(); int numVBraces = IVBraces.GetCount(); //Get Horizontal Braces ILayoutHorizBraces ILayoutHorizBraces = IStories.GetAt(i).GetFloorType().GetLayoutHorizBraces(); IHorizBraces IHorizBraces = IStories.GetAt(i).GetHorizBraces(); int numHBraces = ILayoutHorizBraces.GetCount(); //Get Elevation double dElevation = IStories.GetAt(i).dElevation; // Convert Columns for (int j = 0; j < numColumns; j++) { IColumn IColumn = IColumns.GetAt(j); Bar bhomBar = BH.Adapter.RAM.Convert.ToBHoMObject(IColumn); RAMFrameData ramFrameData = bhomBar.FindFragment <RAMFrameData>(typeof(RAMFrameData)); if (ramFrameData != null) { ramFrameData.FloorType = IFloorType.strLabel; bhomBar.Fragments.AddOrReplace(ramFrameData); } bhomBars.Add(bhomBar); } // Convert Beams for (int j = 0; j < numBeams; j++) { IBeam IBeam = IBeams.GetAt(j); ILayoutBeam ILayoutBeam = ILayoutBeams.GetAt(j); Bar bhomBar = BH.Adapter.RAM.Convert.ToBHoMObject(IBeam, ILayoutBeam, dElevation); RAMFrameData ramFrameData = bhomBar.FindFragment <RAMFrameData>(typeof(RAMFrameData)); if (ramFrameData != null) { ramFrameData.FloorType = IFloorType.strLabel; bhomBar.Fragments.AddOrReplace(ramFrameData); } bhomBars.Add(bhomBar); } // Convert Vertical Braces for (int j = 0; j < numVBraces; j++) { IVerticalBrace IVerticalBrace = IVBraces.GetAt(j); Bar bhomBar = BH.Adapter.RAM.Convert.ToBHoMObject(IVerticalBrace); RAMFrameData ramFrameData = bhomBar.FindFragment <RAMFrameData>(typeof(RAMFrameData)); if (ramFrameData != null) { ramFrameData.FloorType = IFloorType.strLabel; bhomBar.Fragments.AddOrReplace(ramFrameData); } bhomBars.Add(bhomBar); } // Convert Horizontal Braces for (int j = 0; j < numHBraces; j++) { IHorizBrace IHorizBrace = IHorizBraces.GetAt(j); ILayoutHorizBrace ILayoutHorizBrace = ILayoutHorizBraces.GetAt(j); Bar bhomBar = BH.Adapter.RAM.Convert.ToBHoMObject(IHorizBrace, ILayoutHorizBrace, dElevation); RAMFrameData ramFrameData = bhomBar.FindFragment <RAMFrameData>(typeof(RAMFrameData)); if (ramFrameData != null) { ramFrameData.FloorType = IFloorType.strLabel; bhomBar.Fragments.AddOrReplace(ramFrameData); } bhomBars.Add(bhomBar); } } return(bhomBars); }
/***************************************************/ 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); }