Exemplo n.º 1
0
        /***************************************************/

        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);
        }
Exemplo n.º 2
0
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        private bool CreateCollection(IEnumerable <Grid> bhomGrid)
        {
            // Register GridSystems
            IGridSystems ramGridSystems = m_Model.GetGridSystems();

            // Register FloorTypes
            IFloorTypes ramFloorTypes = m_Model.GetFloorTypes();

            // initializa a BhoM grid
            List <Grid> Grids = bhomGrid.ToList();

            //Split grids by gridtypes
            List <Grid> XGrids    = new List <Grid>();
            List <Grid> YGrids    = new List <Grid>();
            List <Grid> skewGrids = new List <Grid>();
            List <Grid> circGrids = new List <Grid>();
            Grid        grid      = new Grid();
            Polyline    gridLine  = new Polyline();

            //create different names for the gridSystem based on if there are items in the list
            double      gridSystemRotation = 0;
            string      gridSystemLabel    = "";
            IGridSystem ramGridSystemXY    = null;
            //IGridSystem ramGridSystemRad = null;
            //IGridSystem ramGridSystemSk = null;
            IModelGrids ramModelGridsXY = null;

            //IModelGrids ramModelGridsRad = null;
            //IModelGrids ramModelGridsSk = null;


            //Loop through the BHoM grids and sort per type (x,y,radial, circular, skewed)
            for (int i = 0; i < Grids.Count(); i++)
            {
                grid = Grids[i];

                if (grid.Curve is Circle)
                {
                    circGrids.Add(grid);
                }
                else
                {
                    gridLine = Engine.Geometry.Modify.CollapseToPolyline(grid.Curve as dynamic, 10);
                    //add lines to corresponding lists (XGrids, YGrids) based on their  orientation
                    if (Math.Abs(gridLine.StartPoint().X - gridLine.EndPoint().X) < 0.1)
                    {
                        YGrids.Add(grid);
                    }
                    else if (Math.Abs(gridLine.StartPoint().Y - gridLine.EndPoint().Y) < 0.1)
                    {
                        XGrids.Add(grid);
                    }
                    else
                    {
                        skewGrids.Add(grid);
                    }
                }
            }


            //Create grid systems per grid lists

            //XYGrids
            if (YGrids.Count() != 0 || XGrids.Count() != 0)
            {
                gridSystemLabel = "XY_grid";
                ramGridSystemXY = ramGridSystems.Add(gridSystemLabel);
                ramGridSystemXY.eOrientationType = SGridSysType.eGridOrthogonal;
                ramGridSystemXY.dRotation        = gridSystemRotation;
                ramModelGridsXY = ramGridSystemXY.GetGrids();
            }


            // NOTE: Radial and Skewed Not Yet Implemented but code framework is below

            ////Radial Circular Grid
            //if (circGrids.Count() != 0)
            //{
            //    gridSystemLabel = "Radial_grid";
            //    ramGridSystemRad = ramGridSystems.Add(gridSystemLabel);
            //    ramGridSystemRad.dXOffset = gridOffsetX;
            //    ramGridSystemRad.dYOffset = gridOffsetY;
            //    ramGridSystemRad.eOrientationType = SGridSysType.eGridRadial;
            //    ramGridSystemRad.dRotation = gridSystemRotation;
            //    ramModelGridsRad = ramGridSystemRad.GetGrids();
            //}
            //// Skewed grid
            //if (skewGrids.Count() != 0) {
            //    gridSystemLabel = "Skew_gird";
            //    ramGridSystemSk = ramGridSystems.Add(gridSystemLabel);
            //    ramGridSystemSk.dXOffset = 0;
            //    ramGridSystemSk.dYOffset = 0;
            //    ramGridSystemSk.eOrientationType = SGridSysType.eGridSkewed;
            //    ramGridSystemSk.dRotation = gridSystemRotation;
            //    ramModelGridsSk = ramGridSystemSk.GetGrids();

            //}


            //  Get Grid System Offset
            double minY = XGrids[0].Curve.IStartPoint().Y.ToInch();
            double minX = YGrids[0].Curve.IStartPoint().X.ToInch();

            foreach (Grid XGrid in XGrids)
            {
                double gridY = XGrid.Curve.IStartPoint().Y.ToInch();
                if (gridY < minY)
                {
                    minY = gridY;
                }
            }

            foreach (Grid YGrid in YGrids)
            {
                double gridX = YGrid.Curve.IStartPoint().X.ToInch();
                if (gridX < minX)
                {
                    minX = gridX;
                }
            }
            ramGridSystemXY.dXOffset = minX;
            ramGridSystemXY.dYOffset = minY;


            // Create Grids in GridSystem
            foreach (Grid XGrid in XGrids)
            {
                gridLine = Engine.Geometry.Modify.CollapseToPolyline(XGrid.Curve as dynamic, 10);
                ramModelGridsXY.Add(XGrid.Name, EGridAxis.eGridYorCircularAxis, gridLine.StartPoint().Y.ToInch() - minY);
            }

            foreach (Grid YGrid in YGrids)
            {
                gridLine = Engine.Geometry.Modify.CollapseToPolyline(YGrid.Curve as dynamic, 10);
                ramModelGridsXY.Add(YGrid.Name, EGridAxis.eGridXorRadialAxis, gridLine.StartPoint().X.ToInch() - minX);
            }

            foreach (Grid cGrid in circGrids)
            {
                // TODO: add code to implement circular grids
                // Create GridSystem in RAM for each unique centerpt of circGrids
            }

            foreach (Grid skGrid in skewGrids)
            {
                // TODO: add code to implement skewed grids
                // Create GridSystem in RAM for each unique angle of skewGrids
            }

            //get the ID of the gridsystem
            int gridSystemID = ramGridSystemXY.lUID;

            //Cycle through floortypes, access the existing floortype/story, place grids on those stories
            for (int i = 0; i < ramFloorTypes.GetCount(); i++)
            {
                IFloorType ramFloorType = ramFloorTypes.GetAt(i);
                DAArray    gsID         = ramFloorType.GetGridSystemIDArray();
                gsID.Add(ramGridSystemXY.lUID, 0);
                ramFloorType.SetGridSystemIDArray(gsID);
            }

            //Save file
            m_IDBIO.SaveDatabase();

            return(true);
        }