/***************************************************/ /**** Private Methods ****/ /***************************************************/ private static oM.Physical.Elements.Roof SolidRoofFromRevit(this RoofBase roof, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { ISurface location = null; List <BH.oM.Physical.Elements.IOpening> openings = new List <oM.Physical.Elements.IOpening>(); Dictionary <PlanarSurface, List <PlanarSurface> > surfaces = null; BoundingBoxXYZ bbox = roof.get_BoundingBox(null); if (bbox != null) { BoundingBoxIntersectsFilter bbif = new BoundingBoxIntersectsFilter(new Outline(bbox.Min, bbox.Max)); IList <ElementId> insertIds = (roof as HostObject).FindInserts(true, true, true, true); List <Element> inserts; if (insertIds.Count == 0) { inserts = new List <Element>(); } else { inserts = new FilteredElementCollector(roof.Document, insertIds).WherePasses(bbif).ToList(); } List <FamilyInstance> windows = inserts.Where(x => x is FamilyInstance && x.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Windows).Cast <FamilyInstance>().ToList(); List <FamilyInstance> doors = inserts.Where(x => x is FamilyInstance && x.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Doors).Cast <FamilyInstance>().ToList(); surfaces = roof.PanelSurfaces(windows.Union(doors).Select(x => x.Id), settings); if (surfaces != null) { List <ISurface> locations = new List <ISurface>(surfaces.Keys); if (locations.Count == 1) { location = locations[0]; } else { location = new PolySurface { Surfaces = locations } }; foreach (List <PlanarSurface> ps in surfaces.Values) { openings.AddRange(ps.Select(x => new BH.oM.Physical.Elements.Void { Location = x })); } foreach (FamilyInstance window in windows) { BH.oM.Physical.Elements.Window bHoMWindow = window.WindowFromRevit(roof, settings, refObjects); if (bHoMWindow != null) { openings.Add(bHoMWindow); } } foreach (FamilyInstance door in doors) { BH.oM.Physical.Elements.Door bHoMDoor = door.DoorFromRevit(roof, settings, refObjects); if (bHoMDoor != null) { openings.Add(bHoMDoor); } } } } if (surfaces == null || surfaces.Count == 0) { roof.NoPanelLocationError(); } return(new oM.Physical.Elements.Roof { Location = location, Openings = openings }); }
/***************************************************/ public static List <oM.Environment.Elements.Panel> EnvironmentPanelsFromRevit(this RoofBase roofBase, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { settings = settings.DefaultIfNull(); List <oM.Environment.Elements.Panel> panels = refObjects.GetValues <oM.Environment.Elements.Panel>(roofBase.Id); if (panels != null && panels.Count > 0) { return(panels); } Dictionary <PlanarSurface, List <PlanarSurface> > surfaces = roofBase.PanelSurfaces(roofBase.FindInserts(true, true, true, true), settings); if (surfaces == null) { return(panels); } BH.oM.Physical.Constructions.Construction construction = roofBase.RoofType.ConstructionFromRevit(null, settings, refObjects); panels = new List <oM.Environment.Elements.Panel>(); foreach (PlanarSurface surface in surfaces.Keys) { //Create the BuildingElement oM.Environment.Elements.Panel panel = new oM.Environment.Elements.Panel() { ExternalEdges = surface.ExternalBoundary.ToEdges(), Name = roofBase.FamilyTypeFullName(), }; //Set ExtendedProperties OriginContextFragment originContext = new OriginContextFragment() { ElementID = roofBase.Id.IntegerValue.ToString(), TypeName = roofBase.FamilyTypeFullName() }; originContext.SetProperties(roofBase.RoofType, settings.ParameterSettings); originContext.SetProperties(roofBase, settings.ParameterSettings); panel.AddFragment(originContext); PanelAnalyticalFragment panelAnalytical = new PanelAnalyticalFragment(); panelAnalytical.SetProperties(roofBase.RoofType, settings.ParameterSettings); panelAnalytical.SetProperties(roofBase, settings.ParameterSettings); panel.AddFragment(panelAnalytical); PanelContextFragment panelContext = new PanelContextFragment(); panelContext.SetProperties(roofBase.RoofType, settings.ParameterSettings); panelContext.SetProperties(roofBase, settings.ParameterSettings); panel.AddFragment(panelContext); BuildingResultFragment buildingResults = new BuildingResultFragment(); buildingResults.SetProperties(roofBase.RoofType, settings.ParameterSettings); buildingResults.SetProperties(roofBase, settings.ParameterSettings); panel.AddFragment(buildingResults); panel.Construction = construction; panel.Type = oM.Environment.Elements.PanelType.Roof; //Set identifiers, parameters & custom data panel.SetIdentifiers(roofBase); panel.CopyParameters(roofBase, settings.ParameterSettings); panel.SetProperties(roofBase, settings.ParameterSettings); refObjects.AddOrReplace(roofBase.Id, panel); panels.Add(panel); } return(panels); }