Exemple #1
0
        /***************************************************/

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