Пример #1
0
        /// <summary>
        /// This method get all openings surfaces from current model
        /// </summary>
        /// <returns>XElement that places openings surfaces</returns>
        public XElement GetAnalyticalOpenings()
        {
            // openings for the first EnergyAnalysisDetailModel whose openings should not be merged
            XElement openingsNode = new XElement("OpeningsModels");

            openingsNode.Add(new XAttribute("Name", "OpeningsModels"));

            // get EnergyAnalysisOpenings from Model1
            IList <EnergyAnalysisOpening> openings = m_energyAnalysisDetailModel.GetAnalyticalOpenings();

            foreach (EnergyAnalysisOpening opening in openings)
            {
                XElement openNode = new XElement("Open");
                openNode.Add(new XAttribute("Name", opening.Name));
                // add individual opening node to whol openings node
                openingsNode.Add(openNode);

                // get surfaces from opening
                EnergyAnalysisSurface openingSurface = opening.GetAnalyticalSurface();
                if (null == openingSurface)
                {
                    continue;
                }
                XElement surfaceNode = new XElement("Surface");
                surfaceNode.Add(new XAttribute("Name", openingSurface.Name));
                openNode.Add(surfaceNode);
            }

            // return the whole openings node
            return(openingsNode);
        }
Пример #2
0
        /***************************************************/

        public static IBHoMObject FromRevit(this EnergyAnalysisSurface energyAnalysisSurface, Discipline discipline, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            switch (discipline)
            {
            case Discipline.Environmental:
            case Discipline.Architecture:
            case Discipline.Physical:
                return(energyAnalysisSurface.EnvironmentPanelFromRevit(settings, refObjects));

            default:
                return(null);
            }
        }
Пример #3
0
        /***************************************************/

        public static IBHoMObject FromRevit(this EnergyAnalysisSurface energyAnalysisSurface, Discipline discipline, Transform transform = null, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            IElement2D result = null;

            switch (discipline)
            {
            case Discipline.Facade:
            case Discipline.Environmental:
            case Discipline.Architecture:
            case Discipline.Physical:
                result = energyAnalysisSurface.EnvironmentPanelFromRevit(settings, refObjects);
                break;
            }

            if (result != null && transform?.IsIdentity == false)
            {
                TransformMatrix bHoMTransform = transform.FromRevit();
                result = result.ITransform(bHoMTransform);
            }

            return(result as IBHoMObject);
        }
        /// <summary>Creates IFC connection surface geometry from a surface object.</summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="surface">The EnergyAnalysisSurface.</param>
        /// <param name="openings">List of EnergyAnalysisOpenings.</param>
        /// <param name="offset">The offset of the geometry.</param>
        /// <returns>The connection geometry handle.</returns>
        static IFCAnyHandle CreateConnectionSurfaceGeometry(ExporterIFC exporterIFC, EnergyAnalysisSurface surface, IList<EnergyAnalysisOpening> openings, XYZ offset)
        {
            IFCFile file = exporterIFC.GetFile();

            Polyloop outerLoop = surface.GetPolyloop();
            IList<XYZ> outerLoopPoints = outerLoop.GetPoints();

            IList<XYZ> newOuterLoopPoints = new List<XYZ>();
            foreach (XYZ point in outerLoopPoints)
            {
                newOuterLoopPoints.Add(UnitUtil.ScaleLength(point.Subtract(offset)));
            }

            IList<IList<XYZ>> innerLoopPoints = new List<IList<XYZ>>();
            foreach (EnergyAnalysisOpening opening in openings)
            {
                IList<XYZ> openingPoints = opening.GetPolyloop().GetPoints();
                List<XYZ> newOpeningPoints = new List<XYZ>();
                foreach (XYZ openingPoint in openingPoints)
                {
                    newOpeningPoints.Add(UnitUtil.ScaleLength(openingPoint.Subtract(offset)));
                }
                innerLoopPoints.Add(newOpeningPoints);
            }

            IFCAnyHandle hnd = ExporterUtil.CreateCurveBoundedPlane(file, newOuterLoopPoints, innerLoopPoints);

            return IFCInstanceExporter.CreateConnectionSurfaceGeometry(file, hnd, null);
        }
Пример #5
0
        private void Stream( ArrayList data, EnergyAnalysisSurface eaSurface )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( EnergyAnalysisSurface ) ) );

              data.Add( new Snoop.Data.Double( "Azimuth", eaSurface.Azimuth ) );
              data.Add( new Snoop.Data.String( "CAD Link Unique Id", eaSurface.CADLinkUniqueId ) );
              data.Add( new Snoop.Data.String( "CAD Object Unique Id", eaSurface.CADObjectUniqueId ) );
              data.Add( new Snoop.Data.Xyz( "Corner", eaSurface.Corner ) );
              data.Add( new Snoop.Data.Object( "Adjacent Analytical Space", eaSurface.GetAdjacentAnalyticalSpace() ) );
              data.Add( new Snoop.Data.Object( "Analytical Space", eaSurface.GetAnalyticalSpace() ) );
              data.Add( new Snoop.Data.Object( "Poly loop", eaSurface.GetPolyloop() ) );
              data.Add( new Snoop.Data.Double( "Height", eaSurface.Height ) );
              data.Add( new Snoop.Data.String( "Originating Element Description", eaSurface.OriginatingElementDescription ) );
              data.Add( new Snoop.Data.String( "Surface Id", eaSurface.SurfaceId ) );
              data.Add( new Snoop.Data.String( "Surface Name", eaSurface.SurfaceName ) );
              data.Add( new Snoop.Data.Object( "Surface Type", eaSurface.SurfaceType ) );
              data.Add( new Snoop.Data.Double( "Tilt", eaSurface.Tilt ) );
              data.Add( new Snoop.Data.Double( "Width", eaSurface.Width ) );
        }
        /// <summary>
        /// Create IFC connection surface geometry from a surface object.
        /// </summary>
        /// <param name="file">
        /// The IFC file.
        /// </param>
        /// <param name="surface">
        /// The EnergyAnalysisSurface.
        /// </param>
        /// <param name="openings">
        /// List of EnergyAnalysisOpenings.
        /// </param>
        /// <param name="offset">
        /// The offset of the geometry.
        /// </param>
        /// <returns>
        /// The connection geometry handle.
        /// </returns>
        static IFCAnyHandle CreateConnectionSurfaceGeometry(IFCFile file, EnergyAnalysisSurface surface, IList<EnergyAnalysisOpening> openings)
        {
            Polyloop outerLoop = surface.GetPolyloop();
            IList<XYZ> outerLoopPoints = outerLoop.GetPoints();

            IList<IList<XYZ>> innerLoopPoints = new List<IList<XYZ>>();
            foreach (EnergyAnalysisOpening opening in openings)
            {
                innerLoopPoints.Add(opening.GetPolyloop().GetPoints());
            }

            IFCAnyHandle hnd = file.CreateCurveBoundedPlane(outerLoopPoints, innerLoopPoints);

            IFCAnyHandle ifcOptionalHnd = IFCAnyHandle.Create();
            return file.CreateConnectionSurfaceGeometry(hnd, ifcOptionalHnd);
        }
Пример #7
0
        public static Panel ToSAM(this EnergyAnalysisSurface energyAnalysisSurface, Core.Revit.ConvertSettings convertSettings, Shell shell = null, double silverSpacing = Core.Tolerance.MacroDistance, double tolerance = Core.Tolerance.Distance)
        {
            if (energyAnalysisSurface == null)
            {
                return(null);
            }

            Panel result = convertSettings?.GetObject <Panel>(energyAnalysisSurface.Id);

            if (result != null)
            {
                return(result);
            }

            Document document = energyAnalysisSurface.Document;

            Polygon3D polygon3D = energyAnalysisSurface.GetPolyloop().ToSAM();

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

            if (shell != null)
            {
                Geometry.Spatial.Plane plane = polygon3D.GetPlane();

                if (plane != null)
                {
                    Point3D point3D = polygon3D.InternalPoint3D();
                    if (point3D != null)
                    {
                        Vector3D normal = shell.Normal(polygon3D.InternalPoint3D(), true, silverSpacing, tolerance);
                        if (!normal.SameHalf(plane.AxisZ))
                        {
                            plane.FlipZ();
                            polygon3D = new Polygon3D(plane, polygon3D.GetPoints().ConvertAll(x => plane.Convert(x)));
                        }
                    }
                }
            }

            HostObject hostObject = Core.Revit.Query.Element(document, energyAnalysisSurface.CADObjectUniqueId, energyAnalysisSurface.CADLinkUniqueId) as HostObject;

            if (hostObject == null)
            {
                return(new Panel(null, PanelType.Air, new Face3D(polygon3D)));
            }

            ElementId elementId_Type = hostObject.GetTypeId();

            if (elementId_Type == null || elementId_Type == ElementId.InvalidElementId)
            {
                return(null);
            }

            PanelType    panelType    = Query.PanelType(hostObject);
            Construction construction = ((HostObjAttributes)hostObject.Document.GetElement(elementId_Type)).ToSAM(convertSettings);

            if (construction == null)
            {
                construction = Analytical.Query.DefaultConstruction(panelType); //Default Construction
            }
            PanelType panelType_Temp = Query.PanelType(construction);

            if (panelType_Temp != PanelType.Undefined)
            {
                panelType = panelType_Temp;
            }

            Face3D face3D = new Face3D(polygon3D);

            result = new Panel(construction, panelType, face3D);

            IEnumerable <EnergyAnalysisOpening> energyAnalysisOpenings = energyAnalysisSurface.GetAnalyticalOpenings();

            if (energyAnalysisOpenings != null && energyAnalysisOpenings.Count() != 0)
            {
                foreach (EnergyAnalysisOpening energyAnalysisOpening in energyAnalysisOpenings)
                {
                    Aperture aperture = energyAnalysisOpening.ToSAM(convertSettings);
                    if (aperture != null)
                    {
                        result.AddAperture(aperture);
                    }
                }
            }

            result.UpdateParameterSets(energyAnalysisSurface, ActiveSetting.Setting.GetValue <Core.TypeMap>(Core.Revit.ActiveSetting.Name.ParameterMap));

            convertSettings?.Add(energyAnalysisSurface.Id, result);

            return(result);
        }
Пример #8
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);
        }