Пример #1
0
        public static BHX.Surface ToGBXML(this BHE.Panel element)
        {
            BHP.OriginContextFragment contextProperties = element.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment));

            BHX.Surface surface = new BHX.Surface();
            surface.CADObjectID       = element.CADObjectID();
            surface.ConstructionIDRef = (contextProperties == null ? element.ConstructionID() : contextProperties.TypeName.CleanName());

            BHX.RectangularGeometry geom       = element.ToGBXMLGeometry();
            BHX.PlanarGeometry      planarGeom = new BHX.PlanarGeometry();
            planarGeom.ID = "PlanarGeometry-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);

            BHG.Polyline pLine = element.Polyline();
            planarGeom.PolyLoop = pLine.ToGBXML();

            surface.PlanarGeometry      = planarGeom;
            surface.RectangularGeometry = geom;

            surface.Opening = new BHX.Opening[element.Openings.Count];
            for (int x = 0; x < element.Openings.Count; x++)
            {
                if (element.Openings[x].Polyline().IControlPoints().Count != 0)
                {
                    surface.Opening[x] = element.Openings[x].ToGBXML();
                }
            }

            return(surface);
        }
Пример #2
0
        public static BHX.RectangularGeometry ToGBXMLGeometry(this BHE.Panel element)
        {
            BHX.RectangularGeometry geom = new BHX.RectangularGeometry();

            BHG.Polyline pLine = element.Polyline();

            geom.Tilt           = Math.Round(element.Tilt(), 3);
            geom.Azimuth        = Math.Round(element.Azimuth(BHG.Vector.YAxis), 3);
            geom.Height         = Math.Round(element.Height(), 3);
            geom.Width          = Math.Round(element.Width(), 3);
            geom.CartesianPoint = pLine.ControlPoints.First().ToGBXML();
            geom.ID             = "geom-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);

            if (geom.Height == 0)
            {
                geom.Height = Math.Round(element.Area() / geom.Width, 3);
            }
            if (geom.Width == 0)
            {
                geom.Width = Math.Round(element.Area() / geom.Height, 3);
            }

            return(geom);
        }