예제 #1
0
        /***************************************************/

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