Example #1
0
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        private List <ContourLoadSet> ReadContourLoadSets(List <string> ids = null)
        {
            //Implement code for reading Contour Load Sets
            List <ContourLoadSet>            bhomContourLoadSets = new List <ContourLoadSet>();
            Dictionary <int, UniformLoadSet> bhomUniformLoadSets = ReadUniformLoadSets().ToDictionary(x => (int)GetAdapterId(x));

            //Get stories
            IStories IStories   = m_Model.GetStories();
            int      numStories = IStories.GetCount();

            // Get all elements on each story
            for (int i = 0; i < numStories; i++)
            {
                IFloorType floorType = IStories.GetAt(i).GetFloorType();
                //Get contour load sets per story
                ISurfaceLoadSets srfLoadSets = floorType.GetSurfaceLoadSets2();
                int numSrfLoads = srfLoadSets.GetCount();

                for (int j = 0; j < numSrfLoads; j++)
                {
                    ISurfaceLoadSet srfLoadSet = srfLoadSets.GetAt(j);
                    ContourLoadSet  srfLoad    = srfLoadSet.ToBHoMObject(IStories.GetAt(i));
                    int             propUID    = srfLoadSet.lPropertySetUID;
                    srfLoad.UniformLoadSet = bhomUniformLoadSets[propUID];
                    bhomContourLoadSets.Add(srfLoad);
                }
            }

            return(bhomContourLoadSets);
        }
Example #2
0
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        private bool CreateCollection(IEnumerable <ContourLoadSet> loads)
        {
            foreach (ContourLoadSet load in loads)
            {
                try
                {
                    //Ensure points describe a closed polyline
                    List <Point> loadPoints = load.Contour.ControlPoints();
                    if (loadPoints.First() != loadPoints.Last())
                    {
                        loadPoints.Add(loadPoints.Last().DeepClone());
                    }

                    //Find the layout to apply to
                    IStories   ramStories = m_Model.GetStories();
                    IStory     loadStory  = loadPoints.First().GetStory(ramStories);
                    double     storyElev  = loadStory.dElevation;
                    IFloorType floorType  = loadStory.GetFloorType();

                    ISurfaceLoadSets floorLoads   = floorType.GetSurfaceLoadSets2();
                    int             nextId        = floorLoads.GetCount();
                    ISurfaceLoadSet ramLoad       = floorLoads.Add(nextId, loadPoints.Count());
                    IPoints         verticePoints = ramLoad.GetPoints();

                    List <SCoordinate> checkList = new List <SCoordinate>();
                    SCoordinate        verticeCoord;

                    for (int i = 0; i < loadPoints.Count(); i++)
                    {
                        verticeCoord = loadPoints[i].ToRAM();
                        verticePoints.Delete(i);
                        verticePoints.InsertAt2(i, verticeCoord.dXLoc, verticeCoord.dYLoc, 0);
                        checkList.Add(verticeCoord);
                    }
                    ramLoad.SetPoints(verticePoints);

                    ramLoad.lPropertySetUID = (int)GetAdapterId(load.UniformLoadSet);
                }

                catch
                {
                    CreateElementError("UniformLoadSet", load.Name);
                }
            }



            //Save file
            m_IDBIO.SaveDatabase();

            return(true);
        }
Example #3
0
        /***************************************************/

        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);
        }