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