示例#1
0
        public static BHX.WindowType ToGBXMLWindow(this BHC.Construction construction, BHE.Opening opening)
        {
            BHX.WindowType window = new BHX.WindowType();

            BHP.PanelAnalyticalFragment extraProperties   = opening.FindFragment <BHP.PanelAnalyticalFragment>(typeof(BHP.PanelAnalyticalFragment));
            BHP.OriginContextFragment   contextProperties = opening.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment));

            window.ID                             = "window-" + (contextProperties == null ? construction.Name.CleanName() : contextProperties.TypeName.CleanName());
            window.Name                           = (contextProperties == null ? construction.Name : contextProperties.TypeName);
            window.UValue.Value                   = (extraProperties == null || extraProperties.UValue == 0 ? construction.UValue().ToString() : extraProperties.UValue.ToString());
            window.Transmittance.Value            = (extraProperties == null ? "0" : extraProperties.LTValue.ToString());
            window.SolarHeatGainCoefficient.Value = (extraProperties == null ? "0" : extraProperties.GValue.ToString());
            if (construction.Layers.Count > 0)
            {
                window.InternalGlaze = (construction.Layers[0]).ToGBXGlazed();
            }
            if (construction.Layers.Count > 1)
            {
                window.Gap = (construction.Layers[1]).ToGBXGap();
            }
            if (construction.Layers.Count > 2)
            {
                window.ExternalGlaze = (construction.Layers[2]).ToGBXGlazed();
            }

            return(window);
        }
示例#2
0
        /***************************************************/

        public static string CADObjectID(this BHE.Opening opening)
        {
            BHP.OriginContextFragment contextProp = opening.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment));
            if (contextProp == null)
            {
                return("WinInst: SIM_EXT_GLZ [000000]");
            }

            string cadID = "";

            if (contextProp.TypeName == "")
            {
                cadID += "WinInst: SIM_EXT_GLZ";
            }
            else
            {
                cadID += contextProp.TypeName;
            }

            cadID += " [";

            if (contextProp.ElementID == "")
            {
                cadID += "000000";
            }
            else
            {
                cadID += contextProp.ElementID;
            }

            cadID += "]";

            return(cadID);
        }
示例#3
0
        public static BHX.Opening ToGBXML(this BHE.Opening opening, List <BHE.Panel> space)
        {
            BHX.Opening gbOpening = opening.ToGBXML();

            BHG.Polyline pLine = opening.Polyline();
            if (pLine.NormalAwayFromSpace(space))
            {
                gbOpening.PlanarGeometry.PolyLoop = pLine.Flip().ToGBXML();
            }

            BHP.OriginContextFragment contextProperties = opening.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment));

            if (contextProperties != null)
            {
                string elementID  = contextProperties.ElementID;
                string familyName = contextProperties.TypeName;

                gbOpening.CADObjectID = opening.CADObjectID();
                gbOpening.OpeningType = opening.Type.ToGBXML();

                if (familyName == "System Panel") //No SAM_BuildingElementType for this one atm
                {
                    gbOpening.OpeningType = "FixedWindow";
                }

                if (gbOpening.OpeningType.Contains("Window") && opening.OpeningConstruction.Name.Contains("SLD")) //Change windows with SLD construction into doors
                {
                    gbOpening.OpeningType = "NonSlidingDoor";
                }
            }

            return(gbOpening);
        }
示例#4
0
        public static BHX.Opening ToGBXML(this BHE.Opening opening, BHE.Panel hostPanel, GBXMLSettings settings)
        {
            BHX.Opening gbOpening = new BHX.Opening();

            BHG.Polyline pLine = opening.Polyline();

            gbOpening.Name = opening.Name;
            gbOpening.ID   = "opening" + opening.BHoM_Guid.ToString().Replace("-", "").Substring(0, 5);
            gbOpening.PlanarGeometry.PolyLoop            = pLine.ToGBXML(settings);
            gbOpening.PlanarGeometry.ID                  = "openingPGeom-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5);
            gbOpening.RectangularGeometry.CartesianPoint = BH.Engine.Geometry.Query.Centroid(pLine).ToGBXML(settings);
            gbOpening.RectangularGeometry.Height         = Math.Round(opening.Height(), settings.RoundingSettings.GeometryHeight);
            //TODO: temporary solution to get valid file to be replaced with correct height
            if (opening.Height() == 0)
            {
                gbOpening.RectangularGeometry.Height = 0.1;
            }
            gbOpening.RectangularGeometry.Width = Math.Round(opening.Width(), settings.RoundingSettings.GeometryWidth);
            gbOpening.RectangularGeometry.ID    = "rGeomOpening-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5);

            pLine = pLine.CleanPolyline(minimumSegmentLength: settings.DistanceTolerance);
            double openingArea = pLine.Area();
            double panelArea   = hostPanel.Polyline().Area();

            if (openingArea >= panelArea)
            {
                pLine = BH.Engine.Geometry.Modify.Offset(pLine, settings.OffsetDistance);

                if (pLine == null)
                {
                    pLine = opening.Polyline(); //Reset the polyline if something went wrong with the offset
                }
                gbOpening.PlanarGeometry.PolyLoop = pLine.ToGBXML(settings);
            }

            //Normals away from space
            //if (!BH.Engine.Environment.Query.NormalAwayFromSpace(pLine, hostSpace, settings.PlanarTolerance))
            //gbOpening.PlanarGeometry.PolyLoop = pLine.Flip().ToGBXML();

            gbOpening.CADObjectID = opening.CADObjectID();
            gbOpening.OpeningType = opening.Type.ToGBXML();

            BHP.OriginContextFragment contextProperties = opening.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment));
            string elementID  = "";
            string familyName = "";

            if (contextProperties != null)
            {
                elementID  = contextProperties.ElementID;
                familyName = contextProperties.TypeName;
            }

            if (gbOpening.OpeningType.ToLower() == "fixedwindow" && contextProperties != null && contextProperties.TypeName.ToLower().Contains("skylight"))
            {
                gbOpening.OpeningType = "FixedSkylight";
            }

            if (familyName == "System Panel") //No SAM_BuildingElementType for this one atm
            {
                gbOpening.OpeningType = "FixedWindow";
            }

            if (settings.ReplaceSolidOpeningsIntoDoors && gbOpening.OpeningType.Contains("Window") && (opening.OpeningConstruction != null && opening.OpeningConstruction.Name.Contains("SLD"))) //Change windows with SLD construction into doors for IES
            {
                gbOpening.OpeningType = "NonSlidingDoor";
            }

            if (settings.IncludeConstructions)
            {
                gbOpening.WindowTypeIDRef = "window-" + (contextProperties != null ? contextProperties.TypeName.CleanName() : (opening.OpeningConstruction != null ? opening.OpeningConstruction.Name.CleanName() : ""));
            }
            else
            {
                gbOpening.WindowTypeIDRef = null;
            }

            gbOpening.ConstructionIDRef = null; //ToDo review having this property on an opening?

            return(gbOpening);
        }