Example #1
0
        /***************************************************/

        internal static oM.Environment.Elements.Panel EnvironmentPanelFromRevit(this EnergyAnalysisSurface energyAnalysisSurface, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            settings = settings.DefaultIfNull();

            oM.Environment.Elements.Panel panel = refObjects.GetValue <oM.Environment.Elements.Panel>(energyAnalysisSurface.Id);
            if (panel != null)
            {
                return(panel);
            }

            //Get the geometry Curve
            ICurve curve = null;

            if (energyAnalysisSurface != null)
            {
                curve = energyAnalysisSurface.GetPolyloop().FromRevit();
            }

            //Get the name and element type
            Element     element     = energyAnalysisSurface.Document.Element(energyAnalysisSurface.CADObjectUniqueId, energyAnalysisSurface.CADLinkUniqueId);
            ElementType elementType = null;

            if (element == null)
            {
                return(panel);
            }

            elementType = element.Document.GetElement(element.GetTypeId()) as ElementType;
            panel       = new oM.Environment.Elements.Panel()
            {
                ExternalEdges = curve.ToEdges(),
                Name          = element.FamilyTypeFullName(),
            };

            //Set ExtendedProperties
            OriginContextFragment originContext = new OriginContextFragment()
            {
                ElementID = element.Id.IntegerValue.ToString(), TypeName = element.FamilyTypeFullName()
            };

            originContext.SetProperties(element, settings.ParameterSettings);
            originContext.SetProperties(elementType, settings.ParameterSettings);
            panel.AddFragment(originContext);

            PanelAnalyticalFragment panelAnalytical = new PanelAnalyticalFragment();

            panelAnalytical.SetProperties(elementType, settings.ParameterSettings);
            panelAnalytical.SetProperties(element, settings.ParameterSettings);
            panel.AddFragment(panelAnalytical);

            PanelContextFragment panelContext = new PanelContextFragment();

            List <string>       connectedSpaces     = new List <string>();
            EnergyAnalysisSpace energyAnalysisSpace = null;

            energyAnalysisSpace = energyAnalysisSurface.GetAnalyticalSpace();
            if (energyAnalysisSpace != null)
            {
                SpatialElement spatialElement = energyAnalysisSpace.Document.Element(energyAnalysisSpace.CADObjectUniqueId) as SpatialElement;
                connectedSpaces.Add(Query.Name(spatialElement));
            }

            energyAnalysisSpace = energyAnalysisSurface.GetAdjacentAnalyticalSpace();
            if (energyAnalysisSpace != null)
            {
                SpatialElement spatialElement = energyAnalysisSpace.Document.Element(energyAnalysisSpace.CADObjectUniqueId) as SpatialElement;
                if (spatialElement != null)
                {
                    connectedSpaces.Add(Query.Name(spatialElement));

                    if (spatialElement is Autodesk.Revit.DB.Mechanical.Space)
                    {
                        Autodesk.Revit.DB.Mechanical.Space space = (Autodesk.Revit.DB.Mechanical.Space)spatialElement;

                        BuildingResultFragment buildingResultsProperties = new BuildingResultFragment();
                        buildingResultsProperties.PeakCooling = space.DesignCoolingLoad.ToSI(UnitType.UT_HVAC_Cooling_Load);
                        buildingResultsProperties.PeakHeating = space.DesignHeatingLoad.ToSI(UnitType.UT_HVAC_Heating_Load);
                        panel.AddFragment(buildingResultsProperties);
                    }
                }
            }

            panel.ConnectedSpaces = connectedSpaces;
            panelContext.SetProperties(elementType, settings.ParameterSettings);
            panelContext.SetProperties(element, settings.ParameterSettings);
            panel.AddFragment(panelContext);

            oM.Environment.Elements.PanelType?panelType = element.Category.PanelType();
            if (panelType.HasValue)
            {
                panel.Type = panelType.Value;
            }
            else
            {
                panel.Type = oM.Environment.Elements.PanelType.Undefined;
            }

            panel.Construction = Convert.ConstructionFromRevit(elementType as dynamic, null, settings, refObjects);

            //Set identifiers, parameters & custom data
            panel.SetIdentifiers(element);
            panel.CopyParameters(element, settings.ParameterSettings);
            panel.SetProperties(element, settings.ParameterSettings);

            refObjects.AddOrReplace(energyAnalysisSurface.Id, panel);
            return(panel);
        }
Example #2
0
        /***************************************************/
        /****               Public Methods              ****/
        /***************************************************/

        public static oM.Environment.Elements.Panel EnvironmentPanelFromRevit(this FamilyInstance familyInstance, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            //Create a BuildingElement from the familyInstance geometry
            settings = settings.DefaultIfNull();

            oM.Environment.Elements.Panel panel = refObjects.GetValue <oM.Environment.Elements.Panel>(familyInstance.Id);
            if (panel != null)
            {
                return(panel);
            }

            PlanarSurface openingSurface = familyInstance.OpeningSurface(null, settings) as PlanarSurface;
            ICurve        outline        = openingSurface?.ExternalBoundary;

            if (outline == null)
            {
                return(null);
            }

            panel = new oM.Environment.Elements.Panel()
            {
                ExternalEdges = outline.ToEdges(),
                Name          = familyInstance.FamilyTypeFullName(),
            };

            //Set ExtendedProperties
            OriginContextFragment originContext = new OriginContextFragment()
            {
                ElementID = familyInstance.Id.IntegerValue.ToString(), TypeName = familyInstance.FamilyTypeFullName()
            };

            originContext.SetProperties(familyInstance.Symbol, settings.ParameterSettings);
            originContext.SetProperties(familyInstance, settings.ParameterSettings);
            panel.Fragments.Add(originContext);

            PanelAnalyticalFragment panelAnalytical = new PanelAnalyticalFragment();

            panelAnalytical.SetProperties(familyInstance.Symbol, settings.ParameterSettings);
            panelAnalytical.SetProperties(familyInstance, settings.ParameterSettings);
            panel.Fragments.Add(panelAnalytical);

            PanelContextFragment panelContext = new PanelContextFragment();

            panelContext.SetProperties(familyInstance.Symbol, settings.ParameterSettings);
            panelContext.SetProperties(familyInstance, settings.ParameterSettings);
            panel.Fragments.Add(panelContext);

            BuildingResultFragment buildingResults = new BuildingResultFragment();

            buildingResults.SetProperties(familyInstance.Symbol, settings.ParameterSettings);
            buildingResults.SetProperties(familyInstance, settings.ParameterSettings);
            panel.Fragments.Add(buildingResults);

            oM.Environment.Elements.PanelType?panelType = familyInstance.Category.PanelType();
            if (panelType.HasValue)
            {
                panel.Type = panelType.Value;
            }
            else
            {
                panel.Type = oM.Environment.Elements.PanelType.Undefined;
            }

            //Set identifiers, parameters & custom data
            panel.SetIdentifiers(familyInstance);
            panel.CopyParameters(familyInstance, settings.ParameterSettings);
            panel.SetProperties(familyInstance, settings.ParameterSettings);

            refObjects.AddOrReplace(familyInstance.Id, panel);
            return(panel);
        }
Example #3
0
        /***************************************************/
        /****             Internal Methods              ****/
        /***************************************************/

        internal static oM.Environment.Elements.Panel EnvironmentPanelFromRevit(this Element element, ICurve crv, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            settings = settings.DefaultIfNull();

            oM.Environment.Elements.Panel panel = refObjects.GetValue <oM.Environment.Elements.Panel>(element.Id);
            if (panel != null)
            {
                return(panel);
            }

            ElementType elementType = element.Document.GetElement(element.GetTypeId()) as ElementType;

            panel = new oM.Environment.Elements.Panel()
            {
                ExternalEdges = crv.ToEdges(),
                Name          = element.FamilyTypeFullName(),
            };

            //Set ExtendedProperties
            OriginContextFragment originContext = new OriginContextFragment()
            {
                ElementID = element.Id.IntegerValue.ToString(), TypeName = element.FamilyTypeFullName()
            };

            originContext.SetProperties(element, settings.ParameterSettings);
            originContext.SetProperties(elementType, settings.ParameterSettings);
            panel.Fragments.Add(originContext);

            PanelAnalyticalFragment panelAnalytical = new PanelAnalyticalFragment();

            panelAnalytical.SetProperties(element, settings.ParameterSettings);
            panelAnalytical.SetProperties(elementType, settings.ParameterSettings);
            panel.Fragments.Add(panelAnalytical);

            PanelContextFragment panelContext = new PanelContextFragment();

            panelContext.SetProperties(element, settings.ParameterSettings);
            panelContext.SetProperties(elementType, settings.ParameterSettings);
            panel.Fragments.Add(panelContext);

            BuildingResultFragment buildingResults = new BuildingResultFragment();

            buildingResults.SetProperties(element, settings.ParameterSettings);
            buildingResults.SetProperties(elementType, settings.ParameterSettings);
            panel.Fragments.Add(buildingResults);

            oM.Environment.Elements.PanelType?panelType = element.Category.PanelType();
            if (panelType.HasValue)
            {
                panel.Type = panelType.Value;
            }
            else
            {
                panel.Type = oM.Environment.Elements.PanelType.Undefined;
            }

            //Set identifiers, parameters & custom data
            panel.SetIdentifiers(element);
            panel.CopyParameters(element, settings.ParameterSettings);
            panel.SetProperties(element, settings.ParameterSettings);

            refObjects.AddOrReplace(element.Id, panel);
            return(panel);
        }
Example #4
0
        /***************************************************/

        public static List <oM.Environment.Elements.Panel> EnvironmentPanelsFromRevit(this Wall wall, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            settings = settings.DefaultIfNull();

            List <oM.Environment.Elements.Panel> panels = refObjects.GetValues <oM.Environment.Elements.Panel>(wall.Id);

            if (panels != null && panels.Count > 0)
            {
                return(panels);
            }

            if (wall.StackedWallOwnerId != null && wall.StackedWallOwnerId != ElementId.InvalidElementId)
            {
                return(null);
            }

            Dictionary <PlanarSurface, List <PlanarSurface> > surfaces = wall.PanelSurfaces(wall.FindInserts(true, true, true, true), settings);

            if (surfaces == null)
            {
                return(panels);
            }

            BH.oM.Physical.Constructions.Construction constrtuction = wall.WallType.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          = wall.FamilyTypeFullName(),
                };

                //Set ExtendedProperties
                OriginContextFragment originContext = new OriginContextFragment()
                {
                    ElementID = wall.Id.IntegerValue.ToString(), TypeName = wall.FamilyTypeFullName()
                };
                originContext.SetProperties(wall.WallType, settings.ParameterSettings);
                originContext.SetProperties(wall, settings.ParameterSettings);
                panel.AddFragment(originContext);

                PanelAnalyticalFragment panelAnalytical = new PanelAnalyticalFragment();
                panelAnalytical.SetProperties(wall.WallType, settings.ParameterSettings);
                panelAnalytical.SetProperties(wall, settings.ParameterSettings);
                panel.AddFragment(panelAnalytical);

                PanelContextFragment panelContext = new PanelContextFragment();
                panelContext.SetProperties(wall.WallType, settings.ParameterSettings);
                panelContext.SetProperties(wall, settings.ParameterSettings);
                panel.AddFragment(panelContext);

                BuildingResultFragment buildingResults = new BuildingResultFragment();
                buildingResults.SetProperties(wall.WallType, settings.ParameterSettings);
                buildingResults.SetProperties(wall, settings.ParameterSettings);
                panel.AddFragment(buildingResults);

                panel.Construction = constrtuction;
                panel.Type         = oM.Environment.Elements.PanelType.Wall;

                //Set identifiers, parameters & custom data
                panel.SetIdentifiers(wall);
                panel.CopyParameters(wall, settings.ParameterSettings);
                panel.SetProperties(wall, settings.ParameterSettings);

                refObjects.AddOrReplace(wall.Id, panel);

                panels.Add(panel);
            }

            return(panels);
        }