Exemplo n.º 1
0
        public static Panel ToSAM(this gbXMLSerializer.Surface surface, double tolerance = Tolerance.MicroDistance)
        {
            if (surface == null)
            {
                return(null);
            }

            Polygon3D polygon3D = surface.PlanarGeometry.ToSAM(tolerance);

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

            PanelType panelType = Query.PanelType(surface.surfaceType);

            Construction construction = new Construction(surface.Name);

            Panel result = new Panel(construction, panelType, new Face3D(polygon3D));

            Opening[] openings = surface.Opening;
            if (openings != null)
            {
                foreach (Opening opening in openings)
                {
                    Aperture aperture = opening.ToSAM(tolerance);
                    if (aperture != null)
                    {
                        result.AddAperture(aperture);
                    }
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public static MemorySafe_Surface convert2MemorySafeSurface(Surface surface)
        {
            List<MemorySafe_CartCoord> surfaceCoords = new List<MemorySafe_CartCoord>();
            foreach (CartCoord coord in surface.SurfaceCoords)
            {
                MemorySafe_CartCoord surfaceCoord = new MemorySafe_CartCoord(coord.X, coord.Y, coord.Z);
                surfaceCoords.Add(surfaceCoord);
            }

            MemorySafe_Surface memSurface = new MemorySafe_Surface(surface.name, surface.multiplier, surface.surfaceType, surface.constructionName,
                surface.outsideBoundary, surface.zoneName, surface.outsideBoundaryCondition, surface.sunExposureVar, surface.windExposureVar,
                surface.viewFactor, surface.numVertices, surfaceCoords, surface.tilt, surface.azimuth);

            return memSurface;
        }
Exemplo n.º 3
0
        public static Surface SetUpSurfaceFromIDF(EPObj.MemorySafe_Surface epsurface, PlanarGeometry pg)
        {
            Surface retsurface = new Surface();
            retsurface.PlanarGeometry = pg;
            if (epsurface._sunExposureVar == "SunExposed")
            {
                retsurface.AdjacentSpaceId = new AdjacentSpaceId[1];
                if (epsurface.tilt > 45 && epsurface.tilt < 135)
                {
                    Dictionary<string, double> WH = new Dictionary<string, double>();
                    //it can be considered an exterior wall
                    retsurface.surfaceType = surfaceTypeEnum.ExteriorWall;
                    retsurface.constructionIdRef = "something";
                    retsurface.Name = epsurface.name;
                    AdjacentSpaceId adj = new AdjacentSpaceId();
                    adj.spaceIdRef = epsurface.zoneName;
                    retsurface.AdjacentSpaceId[0] = adj;

                    RectangularGeometry rg = new RectangularGeometry();
                    rg.Azimuth = gb.FormatDoubleToString(epsurface.azimuth);
                    //find lower left hand corner of exterior wall
                    //for now, we will just arbitrarily choose a point
                    rg.CartesianPoint = pg.PolyLoop.Points[0];
                    rg.Tilt = gb.FormatDoubleToString(epsurface.tilt);
                    //get width and height
                    WH = GetWidthandHeight(epsurface, retsurface.surfaceType);
                    rg.Width = gb.FormatDoubleToString(WH["width"]);
                    rg.Height = gb.FormatDoubleToString(WH["height"]);
                    retsurface.RectangularGeometry = rg;

                    retsurface.PlanarGeometry = pg;
                    retsurface.exposedToSunField = true;
                }
                //it can be a roof
                else if (epsurface.tilt >= 0 && epsurface.tilt <= 45)
                {
                    Dictionary<string, double> WH = new Dictionary<string, double>();
                    //it can be considered an exterior wall
                    retsurface.surfaceType = surfaceTypeEnum.Roof;
                    retsurface.constructionIdRef = "something";
                    retsurface.Name = epsurface.name;
                    AdjacentSpaceId adj = new AdjacentSpaceId();
                    adj.spaceIdRef = epsurface.zoneName;
                    retsurface.AdjacentSpaceId[0] = adj;

                    RectangularGeometry rg = new RectangularGeometry();
                    rg.Azimuth = gb.FormatDoubleToString(epsurface.azimuth);
                    //find lower left hand corner of exterior wall
                    //for now, we will just arbitrarily choose a point
                    rg.CartesianPoint = pg.PolyLoop.Points[0];
                    rg.Tilt = gb.FormatDoubleToString(epsurface.tilt);
                    //get width and height
                    WH = GetWidthandHeight(epsurface, retsurface.surfaceType);
                    rg.Width = gb.FormatDoubleToString(WH["width"]);
                    rg.Height = gb.FormatDoubleToString(WH["height"]);
                    retsurface.RectangularGeometry = rg;

                    retsurface.PlanarGeometry = pg;
                    retsurface.exposedToSunField = true;
                }
                //it can be an exposed floor
                else
                {
                    Dictionary<string, double> WH = new Dictionary<string, double>();
                    //it can be considered an exterior wall
                    retsurface.surfaceType = surfaceTypeEnum.UndergroundSlab;
                    retsurface.constructionIdRef = "something";
                    retsurface.Name = epsurface.name;
                    AdjacentSpaceId adj = new AdjacentSpaceId();
                    adj.spaceIdRef = epsurface.zoneName;
                    retsurface.AdjacentSpaceId[0] = adj;

                    RectangularGeometry rg = new RectangularGeometry();
                    rg.Azimuth = gb.FormatDoubleToString(epsurface.azimuth);
                    //find lower left hand corner of exterior wall
                    //for now, we will just arbitrarily choose a point
                    rg.CartesianPoint = pg.PolyLoop.Points[0];
                    rg.Tilt = gb.FormatDoubleToString(epsurface.tilt);
                    //get width and height
                    WH = GetWidthandHeight(epsurface, retsurface.surfaceType);
                    rg.Width = gb.FormatDoubleToString(WH["width"]);
                    rg.Height = gb.FormatDoubleToString(WH["height"]);
                    retsurface.RectangularGeometry = rg;

                    retsurface.PlanarGeometry = pg;
                    retsurface.exposedToSunField = true;
                }
            }
            else if (epsurface._sunExposureVar == "NoSun" && epsurface._outsideBoundaryCondition == "Ground")
            {
                if (epsurface.tilt > 45 && epsurface.tilt < 135)
                {
                    Dictionary<string, double> WH = new Dictionary<string, double>();
                    //it can be considered an underground wall
                    retsurface.surfaceType = surfaceTypeEnum.UndergroundWall;
                    retsurface.constructionIdRef = "something";
                    retsurface.Name = epsurface.name;
                    AdjacentSpaceId adj1 = new AdjacentSpaceId();
                    adj1.spaceIdRef = epsurface.zoneName;
                    AdjacentSpaceId adj2 = new AdjacentSpaceId();
                    adj2.spaceIdRef = epsurface.zoneName;
                    retsurface.AdjacentSpaceId[0] = adj1;
                    retsurface.AdjacentSpaceId[1] = adj2;

                    RectangularGeometry rg = new RectangularGeometry();
                    rg.Azimuth = gb.FormatDoubleToString(epsurface.azimuth);
                    //find lower left hand corner of exterior wall
                    //for now, we will just arbitrarily choose a point
                    rg.CartesianPoint = pg.PolyLoop.Points[0];
                    rg.Tilt = gb.FormatDoubleToString(epsurface.tilt);
                    //get width and height
                    WH = GetWidthandHeight(epsurface, retsurface.surfaceType);
                    rg.Width = gb.FormatDoubleToString(WH["width"]);
                    rg.Height = gb.FormatDoubleToString(WH["height"]);
                    retsurface.RectangularGeometry = rg;

                    retsurface.PlanarGeometry = pg;
                    retsurface.exposedToSunField = false;
                }
                else if (epsurface.tilt >= 0 && epsurface.tilt <= 45)
                {
                    Dictionary<string, double> WH = new Dictionary<string, double>();
                    //it can be considered an underground ceiling
                    retsurface.surfaceType = surfaceTypeEnum.UndergroundCeiling;
                    retsurface.constructionIdRef = "something";
                    retsurface.Name = epsurface.name;
                    AdjacentSpaceId adj1 = new AdjacentSpaceId();
                    adj1.spaceIdRef = epsurface.zoneName;
                    AdjacentSpaceId adj2 = new AdjacentSpaceId();
                    adj2.spaceIdRef = epsurface.zoneName;
                    retsurface.AdjacentSpaceId[0] = adj1;
                    retsurface.AdjacentSpaceId[1] = adj2;

                    RectangularGeometry rg = new RectangularGeometry();
                    rg.Azimuth = gb.FormatDoubleToString(epsurface.azimuth);
                    //find lower left hand corner of exterior wall
                    //for now, we will just arbitrarily choose a point
                    rg.CartesianPoint = pg.PolyLoop.Points[0];
                    rg.Tilt = gb.FormatDoubleToString(epsurface.tilt);
                    //get width and height
                    WH = GetWidthandHeight(epsurface, retsurface.surfaceType);
                    rg.Width = gb.FormatDoubleToString(WH["width"]);
                    rg.Height = gb.FormatDoubleToString(WH["height"]);
                    retsurface.RectangularGeometry = rg;

                    retsurface.PlanarGeometry = pg;
                    retsurface.exposedToSunField = false;
                }
                else
                {
                    Dictionary<string, double> WH = new Dictionary<string, double>();
                    //it can be considered an underground slab or slab on grade

                    retsurface.surfaceType = surfaceTypeEnum.UndergroundSlab;
                    retsurface.constructionIdRef = "something";
                    retsurface.Name = epsurface.name;
                    AdjacentSpaceId adj1 = new AdjacentSpaceId();
                    adj1.spaceIdRef = epsurface.zoneName;
                    AdjacentSpaceId adj2 = new AdjacentSpaceId();
                    adj2.spaceIdRef = epsurface.zoneName;
                    retsurface.AdjacentSpaceId[0] = adj1;
                    retsurface.AdjacentSpaceId[1] = adj2;

                    RectangularGeometry rg = new RectangularGeometry();
                    rg.Azimuth = gb.FormatDoubleToString(epsurface.azimuth);
                    //find lower left hand corner of exterior wall
                    //for now, we will just arbitrarily choose a point
                    rg.CartesianPoint = pg.PolyLoop.Points[0];
                    rg.Tilt = gb.FormatDoubleToString(epsurface.tilt);
                    //get width and height
                    WH = GetWidthandHeight(epsurface, retsurface.surfaceType);
                    rg.Width = gb.FormatDoubleToString(WH["width"]);
                    rg.Height = gb.FormatDoubleToString(WH["height"]);
                    retsurface.RectangularGeometry = rg;

                    retsurface.PlanarGeometry = pg;
                    retsurface.exposedToSunField = false;
                }
            }
            else
            {
                retsurface.AdjacentSpaceId = new AdjacentSpaceId[2];
                //some new code associated with finding the order of the two spaces
                if (epsurface.tilt > 45 && epsurface.tilt < 135)
                {
                    Dictionary<string, double> WH = new Dictionary<string, double>();
                    //it can be considered an underground wall
                    retsurface.surfaceType = surfaceTypeEnum.UndergroundWall;
                    retsurface.constructionIdRef = "something";
                    retsurface.Name = epsurface.name;
                    //this is wrong
                    AdjacentSpaceId adj1 = new AdjacentSpaceId();
                    adj1.spaceIdRef = epsurface.zoneName;
                    AdjacentSpaceId adj2 = new AdjacentSpaceId();
                    adj2.spaceIdRef = epsurface.zoneName;
                    retsurface.AdjacentSpaceId[0] = adj1;
                    retsurface.AdjacentSpaceId[1] = adj2;

                    RectangularGeometry rg = new RectangularGeometry();
                    rg.Azimuth = gb.FormatDoubleToString(epsurface.azimuth);
                    //find lower left hand corner of exterior wall
                    //for now, we will just arbitrarily choose a point
                    rg.CartesianPoint = pg.PolyLoop.Points[0];
                    rg.Tilt = gb.FormatDoubleToString(epsurface.tilt);
                    //get width and height
                    WH = GetWidthandHeight(epsurface, retsurface.surfaceType);
                    rg.Width = gb.FormatDoubleToString(WH["width"]);
                    rg.Height = gb.FormatDoubleToString(WH["height"]);
                    retsurface.RectangularGeometry = rg;

                    retsurface.PlanarGeometry = pg;
                    retsurface.exposedToSunField = false;
                }
                else if (epsurface.tilt >= 0 && epsurface.tilt <= 45)
                {
                    Dictionary<string, double> WH = new Dictionary<string, double>();
                    //it can be considered an underground ceiling
                    retsurface.surfaceType = surfaceTypeEnum.UndergroundCeiling;
                    retsurface.constructionIdRef = "something";
                    retsurface.Name = epsurface.name;
                    //this is wrong
                    AdjacentSpaceId adj1 = new AdjacentSpaceId();
                    adj1.spaceIdRef = epsurface.zoneName;
                    AdjacentSpaceId adj2 = new AdjacentSpaceId();
                    adj2.spaceIdRef = epsurface.zoneName;
                    retsurface.AdjacentSpaceId[0] = adj1;
                    retsurface.AdjacentSpaceId[1] = adj2;

                    RectangularGeometry rg = new RectangularGeometry();
                    rg.Azimuth = gb.FormatDoubleToString(epsurface.azimuth);
                    //find lower left hand corner of exterior wall
                    //for now, we will just arbitrarily choose a point
                    rg.CartesianPoint = pg.PolyLoop.Points[0];
                    rg.Tilt = gb.FormatDoubleToString(epsurface.tilt);
                    //get width and height
                    WH = GetWidthandHeight(epsurface, retsurface.surfaceType);
                    rg.Width = gb.FormatDoubleToString(WH["width"]);
                    rg.Height = gb.FormatDoubleToString(WH["height"]);
                    retsurface.RectangularGeometry = rg;

                    retsurface.PlanarGeometry = pg;
                    retsurface.exposedToSunField = false;
                }
                else
                {
                    Dictionary<string, double> WH = new Dictionary<string, double>();
                    //it can be considered an underground slab or slab on grade

                    retsurface.surfaceType = surfaceTypeEnum.UndergroundSlab;
                    retsurface.constructionIdRef = "something";
                    retsurface.Name = epsurface.name;
                    //this is wrong
                    AdjacentSpaceId adj1 = new AdjacentSpaceId();
                    adj1.spaceIdRef = epsurface.zoneName;
                    AdjacentSpaceId adj2 = new AdjacentSpaceId();
                    adj2.spaceIdRef = epsurface.zoneName;
                    retsurface.AdjacentSpaceId[0] = adj1;
                    retsurface.AdjacentSpaceId[1] = adj2;

                    RectangularGeometry rg = new RectangularGeometry();
                    rg.Azimuth = gb.FormatDoubleToString(epsurface.azimuth);
                    //find lower left hand corner of exterior wall
                    //for now, we will just arbitrarily choose a point
                    rg.CartesianPoint = pg.PolyLoop.Points[0];
                    rg.Tilt = gb.FormatDoubleToString(epsurface.tilt);
                    //get width and height
                    WH = GetWidthandHeight(epsurface, retsurface.surfaceType);
                    rg.Width = gb.FormatDoubleToString(WH["width"]);
                    rg.Height = gb.FormatDoubleToString(WH["height"]);
                    retsurface.RectangularGeometry = rg;

                    retsurface.PlanarGeometry = pg;
                    retsurface.exposedToSunField = false;
                }
            }
            return retsurface;
        }
        public static List<Space> MakeSpacesFromEPObj(List<EPObj.MemorySafe_Spaces> myspace)
        {
            List<Space> retspaces = new List<Space>();
            int spacecount = 0;
            foreach (EPObj.MemorySafe_Spaces space in myspace)
            {
                //foreach Space space in your ListofSpaces
                Space zespace = new Space();
                zespace.id = "Space-1";
                zespace.lightScheduleIdRef = "lightSchedule-1";
                zespace.equipmentScheduleIdRef = "equipmentSchedule-1";
                zespace.peopleScheduleIdRef = "peopleSchedule-1";
                zespace.conditionType = "HeatedAndCooled";
                zespace.buildingStoreyIdRef = "bldg-story-1";
                zespace.Name = "Test Space-" + spacecount;
                zespace.peoplenum = 12;
                zespace.totalpeoplegain = 450;
                zespace.senspeoplegain = 250;
                zespace.latpeoplegain = 200;
                zespace.PeopleHeatGains = new PeopleHeatGain[3];
                zespace.lpd = 1.2;
                zespace.epd = 1.5;
                zespace.Area = 2450;
                zespace.Volume = 24500;
                zespace.PlanarGeo = new PlanarGeometry();
                zespace.ShellGeo = new ShellGeometry();

                PeopleNumber pn = new PeopleNumber();
                pn.unit = peopleNumberUnitEnum.NumberOfPeople;

                string people = gb.FormatDoubleToString(zespace.peoplenum);
                pn.valuefield = people;
                zespace.PeopleNumber = pn;

                PeopleHeatGain phg = new PeopleHeatGain();
                phg.unit = peopleHeatGainUnitEnum.BtuPerHourPerson;
                phg.heatGainType = peopleHeatGainTypeEnum.Total;
                string totalpopload = gb.FormatDoubleToString(zespace.totalpeoplegain);
                phg.value = totalpopload;
                zespace.PeopleHeatGains[0] = phg;

                PeopleHeatGain shg = new PeopleHeatGain();
                shg.unit = peopleHeatGainUnitEnum.BtuPerHourPerson;
                shg.heatGainType = peopleHeatGainTypeEnum.Sensible;
                string senspopload = gb.FormatDoubleToString(zespace.senspeoplegain);
                shg.value = senspopload;
                zespace.PeopleHeatGains[1] = shg;

                PeopleHeatGain lhg = new PeopleHeatGain();
                lhg.unit = peopleHeatGainUnitEnum.BtuPerHourPerson;
                lhg.heatGainType = peopleHeatGainTypeEnum.Latent;
                string latpopload = gb.FormatDoubleToString(zespace.latpeoplegain);
                lhg.value = latpopload;
                zespace.PeopleHeatGains[2] = lhg;

                LightPowerPerArea lpd = new LightPowerPerArea();
                lpd.unit = powerPerAreaUnitEnum.WattPerSquareFoot;
                lpd.lpd = gb.FormatDoubleToString(zespace.lpd);
                zespace.LightPowerPerArea = lpd;

                EquipPowerPerArea epd = new EquipPowerPerArea();
                epd.unit = powerPerAreaUnitEnum.WattPerSquareFoot;
                epd.epd = gb.FormatDoubleToString(zespace.epd);
                zespace.EquipPowerPerArea = epd;

                Area spacearea = new Area();
                spacearea.val = gb.FormatDoubleToString(zespace.Area);
                zespace.spacearea = spacearea;

                Volume spacevol = new Volume();
                spacevol.val = gb.FormatDoubleToString(zespace.Volume);
                zespace.spacevol = spacevol;

                //same as the planar geometry of the floor planes above
                PlanarGeometry spaceplpoly = new PlanarGeometry();
                //get a list of points that makes up the polyloop
                List<List<double>> spacepoints = prod.MakeFakeList(3);
                //make polyloop with points
                spaceplpoly.PolyLoop = new PolyLoop();
                spaceplpoly.PolyLoop = prod.makePolyLoopsFromDbleList(spaceplpoly.PolyLoop, spacepoints);
                zespace.PlanarGeo = spaceplpoly;
                //@@
                //ShellGeometry
                //similar to planar geometry, but with more planes
                ShellGeometry sg = new ShellGeometry();
                sg.unit = lengthUnitEnum.Feet;
                sg.id = "sg" + space.name;
                sg.ClosedShell = new ClosedShell();
                //up to 100 surfaces per space?  base on the space instance surfaces
                sg.ClosedShell.PolyLoops = new PolyLoop[space.spaceSurfaces.Count()];
                //I would have a list of surface elements that make up the space surfaces.
                //each surface would consist of a series of points that defines the surface.
                for (int i = 0; i < space.spaceSurfaces.Count(); i++)
                {
                    //get points from the space surfaces
                    List<List<double>> epluspoints = new List<List<double>>();
                    epluspoints = EnergyPlusClass.GetCoordinDoubles(space.spaceSurfaces[i].SurfaceCoords);
                    sg.ClosedShell.PolyLoops[i] = new PolyLoop();
                    sg.ClosedShell.PolyLoops[i] = prod.makePolyLoopsFromDbleList(sg.ClosedShell.PolyLoops[i], epluspoints);
                }
                zespace.ShellGeo = sg;

                zespace.cadid = new CADObjectId();
                zespace.cadid.id = "990099-" + spacecount;
                //make surface boundaries..special code needed so that space boundaries are not duplicated...
                //option 1 : the surfaces already declared as internal somehow and how shared.
                //option 2:  the api tries to figure it out
                zespace.spbound = new SpaceBoundary[space.spaceSurfaces.Count()];
                int psurfacecount = 0;
                for (int i = 0; i < space.spaceSurfaces.Count(); i++)
                {
                    //get points from the space surfaces
                    List<List<double>> epluspoints = new List<List<double>>();
                    epluspoints = EnergyPlusClass.GetCoordinDoubles(space.spaceSurfaces[i].SurfaceCoords);
                    //if surface is exterior
                    SpaceBoundary sb = new SpaceBoundary();
                    zespace.spbound[i] = prod.MakeSpaceBoundary(sb, epluspoints, psurfacecount);

                    psurfacecount++;
                    //else if surface is interior and it has not been listed before
                    //then do the same
                    //else do nothing because it is interior and it has already been listed

                    //I also would like to keep track of all the surfaces that I create to better prepare me for the surface definition
                    uniquesurf.Add(zespace.spbound[i].PlanarGeometry);
                    //make a dictionary that stores the name of a surface and its planar geometry?
                    uniqueplanes.Add(zespace.spbound[i].surfaceIdRef, zespace.spbound[i].PlanarGeometry);
                    //make a dictionary that stores the name of a surface and create a surface as the value

                    Surface newsurface = new Surface();
                    //this took a lot of customization...a user would have to make their own code to attach to my object here
                    newsurface = prod.SetUpSurfaceFromIDF(space.spaceSurfaces[i], zespace.spbound[i].PlanarGeometry);
                    uniquesurfaces.Add(zespace.spbound[i].surfaceIdRef, newsurface);
                }

                retspaces.Add(zespace);
                spacecount++;
            }
            return retspaces;
        }
        public static bool CreateSerial(string filepath)
        {
            //place an in memory object here that represents your class representation of the building
            List<EPObj.MemorySafe_Spaces> myspace = new List<EPObj.MemorySafe_Spaces>();
            myspace = EnergyPlusClass.EPlusSpacestoObjectList(@"C:\Users\Chiensi\Documents\C\Buro Happold\Oregon Sustainability Center\Run 1 + Daylighting Only\Run 1 new.idf");

            gb.gbci = new CultureInfo(String.Empty);

            bool ret = false;

            //the basics
            //constructor to define the basics
            gbXML gbx = new gbXML();
            gbx.lengthUnit = lengthUnitEnum.Feet;
            gbx.temperatureUnit = temperatureUnitEnum.F;
            string id = "cmps-1";
            Campus cmp = CreateCampus(id);
            cmp.Buildings = new Building[10000];
            gbx.Campus = cmp;

            //where does this location information from?  it could be smartly inferred somehow, but otherwise specified by the user/programmer
            Location zeloc = new Location();
            zeloc.Name = "San Francisco, CA";
            zeloc.Latitude = "37.795";
            zeloc.Longitude = "-122.394";
            //end the basics
            //tie location and campus back to the gbXML file
            cmp.Location = zeloc;

            //Define the building(s) on the site
            //CHarriman Septempber 19 2013
            cmp.Buildings[0] = MakeBuilding(2000,"bldg-1",buildingTypeEnum.DiningBarLoungeOrLeisure);

            //CHarriman September 19 2013
            //define the stories for each building
            //several ways to do this
            List<List<double>> points = prod.MakeFakeList(5);
            BuildingStorey bs = MakeStorey(1, points);

            //CHarriman Jan 15 2014
            //define the spaces for each building (these come from a space object elsewhere
            List<Space> gbSpaces = new List<Space>();
            gbSpaces = MakeSpacesFromEPObj(myspace);

            for (int spacecount = 0; spacecount < gbSpaces.Count(); spacecount++)
            {
                cmp.Buildings[0].Spaces[spacecount] = gbSpaces[spacecount];
            }

            //after making all the spaces, I make the surfaces
            cmp.Surface = new Surface[uniquesurfaces.Count()];
            int surfcount = 0;
            foreach (KeyValuePair<string, Surface> pair in uniquesurfaces)
            {
                Surface surf = new Surface();
                surf.id = pair.Key;
                //this is a hard one, how to deal with this?  For now, everything is external, and idf can sort of tell me
                surf.surfaceType = pair.Value.surfaceType;
                surf.constructionIdRef = pair.Value.constructionIdRef;
                surf.Name = pair.Value.Name;
                AdjacentSpaceId[] adjspaces = new AdjacentSpaceId[pair.Value.AdjacentSpaceId.Count()];
                int counter = 0;
                foreach (AdjacentSpaceId adj in pair.Value.AdjacentSpaceId)
                {
                    adjspaces[counter] = adj;
                    counter++;
                }
                surf.AdjacentSpaceId = adjspaces;
                RectangularGeometry rg = new RectangularGeometry();
                rg = pair.Value.RectangularGeometry;
                surf.RectangularGeometry = rg;
                surf.PlanarGeometry = pair.Value.PlanarGeometry;
                cmp.Surface[surfcount] = surf;
                surfcount++;
            }

            cmp.Buildings[0].bldgStories[0] = bs;

            //write xml to the file
            XmlSerializer szer = new XmlSerializer(typeof(gbXML));
            TextWriter tw = new StreamWriter(filepath);
            szer.Serialize(tw, gbx);
            tw.Close();

            return ret;
        }