/***************************************************/ /**** Public methods ****/ /***************************************************/ public static List <BH.oM.Geometry.Line> CeilingPattern(this Ceiling ceiling, RevitSettings settings, PlanarSurface surface = null) { CeilingType ceilingType = ceiling.Document.GetElement(ceiling.GetTypeId()) as CeilingType; CompoundStructure comStruct = ceilingType.GetCompoundStructure(); Material material = null; if (comStruct != null && comStruct.GetLayers().Count > 0) { material = ceiling.Document.GetElement(comStruct.GetLayers().Last().MaterialId) as Material; } else { ElementId materialId = ceiling.GetMaterialIds(false)?.FirstOrDefault(); if (materialId != null) { material = ceiling.Document.GetElement(materialId) as Material; } } if (material == null) { BH.Engine.Reflection.Compute.RecordWarning(String.Format("Ceiling patterns could not be pulled because there is no material assigned to the ceiling. Revit ElementId: {0}", ceiling.Id)); return(new List <oM.Geometry.Line>()); } double rotation; XYZ alignment = ceiling.CeilingPatternAlignment(material, settings, out rotation); List <oM.Geometry.Line> result = new List <oM.Geometry.Line>(); if (surface == null) { //This would need to be extended to take openings from Values into account foreach (PlanarSurface srf in ceiling.PanelSurfaces(ceiling.FindInserts(true, true, true, true), settings).Keys) { result.AddRange(material.CeilingPattern(srf, settings, alignment, rotation)); } } else { result.AddRange(material.CeilingPattern(surface, settings, alignment, rotation)); } return(result); }
/***************************************************/ public static List <oM.Environment.Elements.Panel> EnvironmentPanelsFromRevit(this Ceiling ceiling, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { settings = settings.DefaultIfNull(); List <oM.Environment.Elements.Panel> panels = refObjects.GetValues <oM.Environment.Elements.Panel>(ceiling.Id); if (panels != null && panels.Count != 0) { return(panels); } Dictionary <PlanarSurface, List <PlanarSurface> > surfaces = ceiling.PanelSurfaces(ceiling.FindInserts(true, true, true, true), settings); if (surfaces == null) { return(panels); } CeilingType ceilingType = ceiling.Document.GetElement(ceiling.GetTypeId()) as CeilingType; BH.oM.Physical.Constructions.Construction construction = ceilingType.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 = ceiling.FamilyTypeFullName(), }; //Set ExtendedProperties OriginContextFragment originContext = new OriginContextFragment() { ElementID = ceiling.Id.IntegerValue.ToString(), TypeName = ceiling.FamilyTypeFullName() }; originContext.SetProperties(ceilingType, settings.ParameterSettings); originContext.SetProperties(ceiling, settings.ParameterSettings); panel.AddFragment(originContext); PanelAnalyticalFragment panelAnalytical = new PanelAnalyticalFragment(); panelAnalytical.SetProperties(ceilingType, settings.ParameterSettings); panelAnalytical.SetProperties(ceiling, settings.ParameterSettings); panel.AddFragment(panelAnalytical); PanelContextFragment panelContext = new PanelContextFragment(); panelContext.SetProperties(ceilingType, settings.ParameterSettings); panelContext.SetProperties(ceiling, settings.ParameterSettings); panel.AddFragment(panelContext); BuildingResultFragment buildingResults = new BuildingResultFragment(); buildingResults.SetProperties(ceilingType, settings.ParameterSettings); buildingResults.SetProperties(ceiling, settings.ParameterSettings); panel.AddFragment(buildingResults); panel.Construction = construction; panel.Type = oM.Environment.Elements.PanelType.Ceiling; //Set identifiers, parameters & custom data panel.SetIdentifiers(ceiling); panel.CopyParameters(ceiling, settings.ParameterSettings); panel.SetProperties(ceiling, settings.ParameterSettings); refObjects.AddOrReplace(ceiling.Id, panel); panels.Add(panel); } return(panels); }