/***************************************************/ public static BH.oM.Geometry.SettingOut.Grid GridFromRevit(this MultiSegmentGrid revitGrid, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { settings = settings.DefaultIfNull(); oM.Geometry.SettingOut.Grid grid = refObjects.GetValue <oM.Geometry.SettingOut.Grid>(revitGrid.Id); if (grid != null) { return(grid); } List <Grid> gridSegments = revitGrid.GetGridIds().Select(x => revitGrid.Document.GetElement(x) as Grid).ToList(); if (gridSegments.Count == 0) { return(null); } else if (gridSegments.Count == 1) { return(gridSegments[0].GridFromRevit(settings, refObjects)); } else { List <BH.oM.Geometry.PolyCurve> joinedGridCurves = BH.Engine.Geometry.Compute.IJoin(gridSegments.Select(x => x.Curve.IFromRevit()).ToList()); if (joinedGridCurves.Count != 1) { BH.Engine.Reflection.Compute.RecordError(String.Format("Revit grid consists of disjoint segments. Element id: {0}", revitGrid.Id)); return(null); } grid = BH.Engine.Geometry.SettingOut.Create.Grid(joinedGridCurves[0]); grid.Name = revitGrid.Name; } //Set identifiers, parameters & custom data grid.SetIdentifiers(revitGrid); grid.CopyParameters(revitGrid, settings.ParameterSettings); grid.SetProperties(revitGrid, settings.ParameterSettings); refObjects.AddOrReplace(revitGrid.Id, grid); return(grid); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static BH.oM.Geometry.SettingOut.Grid GridFromRevit(this Grid revitGrid, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { settings = settings.DefaultIfNull(); oM.Geometry.SettingOut.Grid grid = refObjects.GetValue <oM.Geometry.SettingOut.Grid>(revitGrid.Id); if (grid != null) { return(grid); } grid = BH.Engine.Geometry.SettingOut.Create.Grid(revitGrid.Curve.IFromRevit()); grid.Name = revitGrid.Name; //Set identifiers, parameters & custom data grid.SetIdentifiers(revitGrid); grid.CopyParameters(revitGrid, settings.ParameterSettings); grid.SetProperties(revitGrid, settings.ParameterSettings); refObjects.AddOrReplace(revitGrid.Id, grid); return(grid); }