public static string DefaultConstructionName(this ApertureType apertureType, bool @internal = false)
        {
            if (apertureType == ApertureType.Undefined)
            {
                return(null);
            }

            GlobalConstructionSet globalConstructionSet = GlobalConstructionSet.Default;

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

            switch (apertureType)
            {
            case ApertureType.Window:
                return(@internal ? globalConstructionSet.ApertureSet.InteriorConstruction : globalConstructionSet.ApertureSet.OperableConstruction);

            case ApertureType.Door:
                return(@internal ? globalConstructionSet.DoorSet.InteriorConstruction : globalConstructionSet.DoorSet.ExteriorConstruction);
            }

            return(null);
        }
Exemple #2
0
        public static int BEType(this ApertureType apertureType, bool frame = false)
        {
            switch (apertureType)
            {
            case Analytical.ApertureType.Door:
                return(BEType("Door"));

            case Analytical.ApertureType.Window:
                return(frame ? BEType("Frame") : BEType("Glazing"));
            }

            return(-1);
        }
Exemple #3
0
        public static BuiltInCategory BuiltInCategory(this ApertureType apertureType)
        {
            switch (apertureType)
            {
            case Analytical.ApertureType.Door:
                return(Autodesk.Revit.DB.BuiltInCategory.OST_Doors);

            case Analytical.ApertureType.Window:
                return(Autodesk.Revit.DB.BuiltInCategory.OST_Windows);
            }

            return(Autodesk.Revit.DB.BuiltInCategory.INVALID);
        }
        public static openingTypeEnum OpeningTypeEnum(this ApertureType apertureType)
        {
            if (apertureType == Analytical.ApertureType.Undefined)
            {
                return(openingTypeEnum.Air);
            }

            switch (apertureType)
            {
            case Analytical.ApertureType.Door:
                return(openingTypeEnum.NonSlidingDoor);

            case Analytical.ApertureType.Window:
                return(openingTypeEnum.OperableWindow);
            }

            return(openingTypeEnum.Air);
        }
Exemple #5
0
        public static Aperture ToSAM(this gbXMLSerializer.Opening opening, double tolerance = Tolerance.MicroDistance)
        {
            if (opening == null)
            {
                return(null);
            }

            Polygon3D polygon3D = opening.pg.ToSAM(tolerance);

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

            ApertureType apertureType = Query.ApertureType(opening.openingType);

            ApertureConstruction apertureConstruction = new ApertureConstruction(opening.Name, apertureType);

            Aperture result = new Aperture(apertureConstruction, polygon3D);

            return(result);
        }
        public static ApertureConstruction ToSAM_ApertureConstruction(this FamilySymbol familySymbol, ConvertSettings convertSettings)
        {
            if (familySymbol == null)
            {
                return(null);
            }

            ApertureConstruction result = convertSettings?.GetObject <ApertureConstruction>(familySymbol.Id);

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

            string name = familySymbol.FullName();

            ApertureType apertureType = familySymbol.ApertureType();

            List <ApertureConstruction> apertureConstructions = Analytical.ActiveSetting.Setting.GetValue <ApertureConstructionLibrary>(AnalyticalSettingParameter.DefaultApertureConstructionLibrary).GetApertureConstructions(apertureType);

            if (apertureConstructions != null)
            {
                result = apertureConstructions.Find(x => name.Equals(x.UniqueName()) || name.Equals(x.Name));
            }

            if (result == null)
            {
                result = new ApertureConstruction(name, apertureType);
            }

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

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

            return(result);
        }
Exemple #7
0
        private static string ToGEM(this Panel panel, List <Point3D> point3Ds, double tolerance = Core.Tolerance.Distance)
        {
            string result = string.Empty;

            List <Point3D> externalEdge = Query.ExternalEdgePoint3Ds(panel, tolerance)?.ToList();

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

            Plane plane = null;

            //Handling Panels with Air PanelType and CurtainWall PanelType
            if (panel.PanelType == PanelType.Air || panel.PanelType == PanelType.CurtainWall)
            {
                plane = panel.ReferencePlane(tolerance);
                if (plane != null)
                {
                    List <List <Point2D> > openings = new List <List <Point2D> >();

                    openings.Add(externalEdge.ConvertAll(x => plane.Convert(x)));

                    result += string.Format("{0} {1}\n", externalEdge.Count, string.Join(" ", externalEdge.ConvertAll(x => point3Ds.IndexOf(x) + 1)));
                    result += string.Format("{0}\n", openings.Count);

                    OpeningType openingType = OpeningType.Undefined;
                    if (panel.PanelType == PanelType.Air)
                    {
                        openingType = OpeningType.Hole;
                    }
                    else
                    {
                        openingType = OpeningType.Window;
                    }

                    foreach (List <Point2D> opening in openings)
                    {
                        result += ToGEM(opening, openingType);
                    }
                }

                return(result);
            }

            List <List <Point2D> > holes = new List <List <Point2D> >();

            List <List <Point3D> > internalEdgesPoint3Ds = Query.InternalEdgesPoint3Ds(panel, tolerance);

            if (internalEdgesPoint3Ds != null)
            {
                plane = panel.ReferencePlane(tolerance);
                if (plane != null)
                {
                    foreach (List <Point3D> internalEdge in internalEdgesPoint3Ds)
                    {
                        holes.Add(internalEdge.ConvertAll(x => plane.Convert(x)));
                    }
                }
            }

            List <List <Point2D> > windows = new List <List <Point2D> >();
            List <List <Point2D> > doors   = new List <List <Point2D> >();

            List <Aperture> apertures = panel.Apertures;

            if (apertures != null && apertures.Count != 0)
            {
                foreach (Aperture aperture in apertures)
                {
                    ApertureConstruction apertureConstruction = aperture?.ApertureConstruction;
                    if (apertureConstruction == null)
                    {
                        continue;
                    }

                    ApertureType apertureType = apertureConstruction.ApertureType;
                    if (apertureType == ApertureType.Undefined)
                    {
                        continue;
                    }

                    List <Point3D> externalEdge_Aperture = aperture.ExternalEdgePoint3Ds(tolerance)?.ToList();
                    if (externalEdge_Aperture == null || externalEdge_Aperture.Count == 0)
                    {
                        continue;
                    }

                    List <List <Point2D> > point2Ds_Apertures = null;
                    switch (apertureType)
                    {
                    case ApertureType.Door:
                        point2Ds_Apertures = doors;
                        break;

                    case ApertureType.Window:
                        point2Ds_Apertures = windows;
                        break;
                    }

                    if (point2Ds_Apertures == null)
                    {
                        continue;
                    }

                    if (plane == null)
                    {
                        plane = panel.ReferencePlane(tolerance);
                    }

                    if (plane == null)
                    {
                        break;
                    }

                    point2Ds_Apertures.Add(externalEdge_Aperture.ConvertAll(x => plane.Convert(x)));
                }
            }

            result += string.Format("{0} {1}\n", externalEdge.Count, string.Join(" ", externalEdge.ConvertAll(x => point3Ds.IndexOf(x) + 1)));

            result += string.Format("{0}\n", windows.Count + doors.Count + holes.Count);

            foreach (List <Point2D> hole in holes)
            {
                result += ToGEM(hole, OpeningType.Hole);
            }

            foreach (List <Point2D> window in windows)
            {
                result += ToGEM(window, OpeningType.Window);
            }

            foreach (List <Point2D> door in doors)
            {
                result += ToGEM(door, OpeningType.Door);
            }

            return(result);
        }
Exemple #8
0
        public static ApertureConstruction ToSAM_ApertureConstruction(this AnyOf <OpaqueConstructionAbridged, WindowConstructionAbridged, ShadeConstruction, AirBoundaryConstructionAbridged> construction, Core.MaterialLibrary materialLibrary = null)
        {
            if (construction == null)
            {
                return(null);
            }

            string        name          = null;
            List <string> materialNames = null;
            ApertureType  apertureType  = ApertureType.Undefined;


            if (construction.Obj is OpaqueConstructionAbridged)
            {
                name          = ((OpaqueConstructionAbridged)construction.Obj).Identifier;
                materialNames = ((OpaqueConstructionAbridged)construction.Obj).Materials;
                apertureType  = ApertureType.Door;
            }
            else if (construction.Obj is WindowConstructionAbridged)
            {
                name          = ((WindowConstructionAbridged)construction.Obj).Identifier;
                materialNames = ((WindowConstructionAbridged)construction.Obj).Materials;
                apertureType  = ApertureType.Window;
            }
            else if (construction.Obj is ShadeConstruction)
            {
                name         = ((ShadeConstruction)construction.Obj).Identifier;
                apertureType = ApertureType.Door;
            }
            else if (construction.Obj is AirBoundaryConstructionAbridged)
            {
                name         = ((AirBoundaryConstructionAbridged)construction.Obj).Identifier;
                apertureType = ApertureType.Window;
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                return(null);
            }

            List <ConstructionLayer> constructionLayers = null;

            if (materialNames != null)
            {
                constructionLayers = new List <ConstructionLayer>();
                foreach (string materialName in materialNames)
                {
                    double thickness = 0;

                    AnyOf <EnergyMaterial, EnergyMaterialNoMass, EnergyWindowMaterialGlazing, EnergyWindowMaterialGas> material_Honeybee = SAM.Core.LadybugTools.Query.DefaultMaterial(materialName);
                    if (material_Honeybee != null)
                    {
                        if (material_Honeybee.Obj is EnergyMaterial)
                        {
                            thickness = ((EnergyMaterial)material_Honeybee.Obj).Thickness;
                        }
                        else if (material_Honeybee.Obj is EnergyMaterialNoMass)
                        {
                        }
                        else if (material_Honeybee.Obj is EnergyWindowMaterialGlazing)
                        {
                            thickness = ((EnergyWindowMaterialGlazing)material_Honeybee.Obj).Thickness;
                        }
                        else if (material_Honeybee.Obj is EnergyWindowMaterialGas)
                        {
                            thickness = ((EnergyWindowMaterialGas)material_Honeybee.Obj).Thickness;
                        }
                    }

                    constructionLayers.Add(new ConstructionLayer(materialName, thickness));
                }
            }

            return(new ApertureConstruction(System.Guid.NewGuid(), name, apertureType, constructionLayers));
        }
Exemple #9
0
        public static bool UpdateConstructions(
            this Document document,
            IEnumerable <Panel> panels,
            Core.DelimitedFileTable delimitedFileTable,
            ConstructionLibrary constructionLibrary,
            ApertureConstructionLibrary apertureConstructionLibrary,
            out List <Panel> panels_Result,
            out List <Aperture> apertures_Result,
            out List <ElementType> elementTypes_Panels,
            out List <ElementType> elementTypes_Apertures,
            out ConstructionLibrary constructionLibrary_Result,
            out ApertureConstructionLibrary apertureConstructionLibrary_Result,
            string sourceColumnName,
            string destinationColumnName,
            string templateColumnName,
            string typeColumnName,
            string thicknessColumnName = null)
        {
            panels_Result                      = null;
            apertures_Result                   = null;
            elementTypes_Panels                = null;
            elementTypes_Apertures             = null;
            constructionLibrary_Result         = null;
            apertureConstructionLibrary_Result = null;

            if (document == null || panels == null || delimitedFileTable == null || constructionLibrary == null || apertureConstructionLibrary == null)
            {
                return(false);
            }

            int index_Source = delimitedFileTable.GetColumnIndex(sourceColumnName);

            if (index_Source == -1)
            {
                return(false);
            }

            int index_Template = delimitedFileTable.GetColumnIndex(templateColumnName);

            if (index_Template == -1)
            {
                return(false);
            }

            int index_Destination = delimitedFileTable.GetColumnIndex(destinationColumnName);

            if (index_Destination == -1)
            {
                return(false);
            }

            int index_Type = delimitedFileTable.GetColumnIndex(typeColumnName);

            if (index_Type == -1)
            {
                return(false);
            }

            panels_Result          = new List <Panel>();
            apertures_Result       = new List <Aperture>();
            elementTypes_Panels    = new List <ElementType>();
            elementTypes_Apertures = new List <ElementType>();

            int index_Thickness = delimitedFileTable.GetColumnIndex(thicknessColumnName);

            constructionLibrary_Result         = new ConstructionLibrary(constructionLibrary.Name);
            apertureConstructionLibrary_Result = new ApertureConstructionLibrary(apertureConstructionLibrary.Name);

            Core.Revit.ConvertSettings convertSettings = Core.Revit.Query.ConvertSettings();

            foreach (Panel panel in panels)
            {
                Construction construction = panel?.Construction;
                if (construction == null)
                {
                    continue;
                }

                string name = construction.Name;
                if (name == null)
                {
                    continue;
                }

                string    name_Destination = null;
                string    name_Template    = null;
                string    name_Source      = null;
                PanelType panelType        = PanelType.Undefined;
                double    thickness        = double.NaN;
                for (int i = 0; i < delimitedFileTable.RowCount; i++)
                {
                    string typeName = null;
                    if (delimitedFileTable.TryConvert(i, index_Type, out typeName))
                    {
                        ApertureType apertureType = Analytical.Query.ApertureType(typeName);
                        if (apertureType != ApertureType.Undefined)
                        {
                            continue;
                        }

                        panelType = Analytical.Query.PanelType(typeName as object);
                    }

                    if (!delimitedFileTable.TryConvert(i, index_Source, out name_Source))
                    {
                        continue;
                    }

                    if (!name.Equals(name_Source))
                    {
                        continue;
                    }

                    if (!delimitedFileTable.TryConvert(i, index_Destination, out name_Destination))
                    {
                        name_Destination = null;
                        continue;
                    }

                    if (!delimitedFileTable.TryConvert(i, index_Template, out name_Template))
                    {
                        name_Template = null;
                    }

                    if (index_Thickness != -1)
                    {
                        if (!delimitedFileTable.TryConvert(i, index_Thickness, out thickness))
                        {
                            thickness = double.NaN;
                        }
                    }

                    break;
                }

                if (string.IsNullOrWhiteSpace(name_Destination))
                {
                    name_Destination = name_Template;
                }

                if (string.IsNullOrWhiteSpace(name_Destination))
                {
                    continue;
                }

                if (panelType == PanelType.Undefined)
                {
                    panelType = panel.PanelType;
                }

                Construction construction_New = constructionLibrary_Result.GetConstructions(name_Destination)?.FirstOrDefault();
                if (construction_New == null)
                {
                    Construction construction_Temp = constructionLibrary.GetConstructions(name_Template)?.FirstOrDefault();
                    if (construction_Temp == null)
                    {
                        continue;
                    }

                    if (name_Destination.Equals(name_Template))
                    {
                        construction_New = construction_Temp;
                    }
                    else
                    {
                        construction_New = new Construction(construction_Temp, name_Destination);
                    }

                    construction_New.SetValue(ConstructionParameter.Description, construction.Name);
                    construction_New.RemoveValue(ConstructionParameter.DefaultPanelType);

                    if (!double.IsNaN(thickness))
                    {
                        construction_New.SetValue(ConstructionParameter.DefaultThickness, thickness);
                    }

                    constructionLibrary_Result.Add(construction_New);
                }

                HostObjAttributes hostObjAttributes = Convert.ToRevit(construction_New, document, panelType, panel.Normal, convertSettings);
                if (hostObjAttributes == null)
                {
                    if (string.IsNullOrWhiteSpace(name_Template))
                    {
                        Construction construction_Default = Analytical.Query.DefaultConstruction(panelType);
                        if (construction_Default != null)
                        {
                            name_Template = construction_Default.Name;
                        }
                    }

                    if (string.IsNullOrWhiteSpace(name_Template))
                    {
                        continue;
                    }

                    hostObjAttributes = DuplicateByType(document, name_Template, panelType, construction_New) as HostObjAttributes;
                }

                Construction construction_New_Temp = new Construction(hostObjAttributes.ToSAM(new Core.Revit.ConvertSettings(false, true, false)), construction_New.Guid);
                construction_New_Temp = new Construction(construction_New_Temp, construction_New.ConstructionLayers);
                constructionLibrary_Result.Add(construction_New_Temp);

                Panel panel_New = Analytical.Create.Panel(panel, construction_New_Temp);
                if (panel_New.PanelType != panelType)
                {
                    panel_New = Analytical.Create.Panel(panel_New, panelType);
                }

                List <Aperture> apertures = panel_New.Apertures;
                if (apertures != null && apertures.Count != 0)
                {
                    foreach (Aperture aperture in apertures)
                    {
                        panel_New.RemoveAperture(aperture.Guid);

                        ApertureConstruction apertureConstruction = aperture?.ApertureConstruction;
                        if (apertureConstruction == null)
                        {
                            continue;
                        }

                        name = apertureConstruction.Name;
                        if (name == null)
                        {
                            continue;
                        }

                        name_Destination = null;
                        name_Template    = null;
                        name_Source      = null;
                        ApertureType apertureType = ApertureType.Undefined;
                        for (int i = 0; i < delimitedFileTable.RowCount; i++)
                        {
                            string typeName = null;
                            if (!delimitedFileTable.TryGetValue(i, index_Type, out typeName) || string.IsNullOrWhiteSpace(typeName))
                            {
                                continue;
                            }

                            apertureType = Analytical.Query.ApertureType(typeName);
                            if (apertureType == ApertureType.Undefined)
                            {
                                if (typeName.Trim().Equals("Curtain Panels"))
                                {
                                    apertureType = ApertureType.Window;
                                }
                            }

                            if (apertureType == ApertureType.Undefined)
                            {
                                continue;
                            }

                            if (!delimitedFileTable.TryGetValue(i, index_Source, out name_Source) || string.IsNullOrWhiteSpace(name_Source))
                            {
                                continue;
                            }

                            if (!name.Equals(name_Source))
                            {
                                continue;
                            }

                            if (!delimitedFileTable.TryGetValue(i, index_Destination, out name_Destination))
                            {
                                name_Destination = null;
                                continue;
                            }

                            if (!delimitedFileTable.TryGetValue(i, index_Template, out name_Template))
                            {
                                name_Template = null;
                            }

                            break;
                        }


                        if (string.IsNullOrWhiteSpace(name_Destination))
                        {
                            name_Destination = name_Template;
                        }

                        if (string.IsNullOrWhiteSpace(name_Destination))
                        {
                            continue;
                        }

                        if (apertureType == ApertureType.Undefined)
                        {
                            continue;
                        }

                        ApertureConstruction apertureConstruction_New = apertureConstructionLibrary_Result.GetApertureConstructions(name_Destination, Core.TextComparisonType.Equals, true, apertureType)?.FirstOrDefault();
                        if (apertureConstruction_New == null)
                        {
                            ApertureConstruction apertureConstruction_Temp = apertureConstructionLibrary.GetApertureConstructions(name_Template, Core.TextComparisonType.Equals, true, apertureType)?.FirstOrDefault();
                            if (apertureConstruction_Temp == null)
                            {
                                continue;
                            }

                            if (name_Destination.Equals(name_Template))
                            {
                                apertureConstruction_New = apertureConstruction_Temp;
                            }
                            else
                            {
                                apertureConstruction_New = new ApertureConstruction(apertureConstruction_Temp, name_Destination);
                            }

                            apertureConstruction_New.SetValue(ApertureConstructionParameter.Description, apertureConstruction.Name);

                            apertureConstructionLibrary_Result.Add(apertureConstruction_New);
                        }

                        FamilySymbol familySymbol = Convert.ToRevit(apertureConstruction_New, document, convertSettings);
                        if (familySymbol == null)
                        {
                            if (string.IsNullOrWhiteSpace(name_Template))
                            {
                                ApertureConstruction apertureConstruction_Default = Analytical.Query.DefaultApertureConstruction(panelType, apertureType);
                                if (apertureConstruction_Default != null)
                                {
                                    name_Template = apertureConstruction_Default.Name;
                                }
                            }

                            if (string.IsNullOrWhiteSpace(name_Template))
                            {
                                continue;
                            }

                            familySymbol = DuplicateByType(document, name_Template, apertureConstruction_New) as FamilySymbol;
                        }

                        Aperture aperture_New = new Aperture(aperture, apertureConstruction_New);
                        if (panel_New.AddAperture(aperture_New))
                        {
                            elementTypes_Apertures.Add(familySymbol);
                            apertures_Result.Add(aperture_New);
                        }
                    }
                }

                elementTypes_Panels.Add(hostObjAttributes);
                panels_Result.Add(panel_New);
            }

            return(true);
        }
        public static AnyOf <OpaqueConstructionAbridged, WindowConstructionAbridged, ShadeConstruction, AirBoundaryConstructionAbridged> DefaultApertureConstruction(this ApertureType apertureType, bool @internal)
        {
            string name = DefaultConstructionName(apertureType, @internal);

            if (string.IsNullOrEmpty(name))
            {
                return(null);
            }

            GlobalConstructionSet globalConstructionSet = GlobalConstructionSet.Default;

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


            List <AnyOf <OpaqueConstructionAbridged, WindowConstructionAbridged, ShadeConstruction, AirBoundaryConstructionAbridged> > constructions = globalConstructionSet.Constructions;

            foreach (AnyOf <OpaqueConstructionAbridged, WindowConstructionAbridged, ShadeConstruction, AirBoundaryConstructionAbridged> construction in constructions)
            {
                string name_Temp = null;

                if (construction.Obj is OpaqueConstructionAbridged)
                {
                    name_Temp = ((OpaqueConstructionAbridged)construction.Obj).Identifier;
                }
                else if (construction.Obj is WindowConstructionAbridged)
                {
                    name_Temp = ((WindowConstructionAbridged)construction.Obj).Identifier;
                }
                else if (construction.Obj is ShadeConstruction)
                {
                    name_Temp = ((ShadeConstruction)construction.Obj).Identifier;
                }
                else if (construction.Obj is AirBoundaryConstructionAbridged)
                {
                    name_Temp = ((AirBoundaryConstructionAbridged)construction.Obj).Identifier;
                }

                if (string.IsNullOrWhiteSpace(name))
                {
                    continue;
                }

                if (name.Equals(name_Temp))
                {
                    return(construction);
                }
            }


            return(null);
        }
Exemple #11
0
        protected override void TrySolveInstance(IGH_DataAccess dataAccess)
        {
            bool run = false;

            if (!dataAccess.GetData(9, ref run))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                dataAccess.SetData(3, false);
                return;
            }
            if (!run)
            {
                return;
            }

            Document document = RhinoInside.Revit.Revit.ActiveDBDocument;

            if (document == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            List <Panel> panels = new List <Panel>();

            if (!dataAccess.GetDataList(0, panels))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            ConstructionLibrary constructionLibrary = null;

            dataAccess.GetData(1, ref constructionLibrary);
            if (constructionLibrary == null)
            {
                constructionLibrary = ActiveSetting.Setting.GetValue <ConstructionLibrary>(AnalyticalSettingParameter.DefaultConstructionLibrary);
            }

            ApertureConstructionLibrary apertureConstructionLibrary = null;

            dataAccess.GetData(2, ref apertureConstructionLibrary);
            if (apertureConstructionLibrary == null)
            {
                apertureConstructionLibrary = ActiveSetting.Setting.GetValue <ApertureConstructionLibrary>(AnalyticalSettingParameter.DefaultApertureConstructionLibrary);
            }

            string csvOrPath = null;

            if (!dataAccess.GetData(3, ref csvOrPath) || string.IsNullOrWhiteSpace(csvOrPath))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            string sourceColumn = null;

            if (!dataAccess.GetData(4, ref sourceColumn) || string.IsNullOrWhiteSpace(sourceColumn))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            string templateColumn = null;

            if (!dataAccess.GetData(5, ref templateColumn) || string.IsNullOrWhiteSpace(templateColumn))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            string destinationColumn = null;

            if (!dataAccess.GetData(6, ref destinationColumn) || string.IsNullOrWhiteSpace(destinationColumn))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            string typeColumn = null;

            if (!dataAccess.GetData(7, ref typeColumn) || string.IsNullOrWhiteSpace(typeColumn))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            string thicknessColumn = null;

            dataAccess.GetData(8, ref thicknessColumn);

            Core.DelimitedFileTable delimitedFileTable = null;
            if (Core.Query.ValidFilePath(csvOrPath))
            {
                delimitedFileTable = new Core.DelimitedFileTable(new Core.DelimitedFileReader(Core.DelimitedFileType.Csv, csvOrPath));
            }
            else
            {
                string[] lines = csvOrPath.Split('\n');
                delimitedFileTable = new Core.DelimitedFileTable(new Core.DelimitedFileReader(Core.DelimitedFileType.Csv, lines));
            }

            if (delimitedFileTable == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            int index_Source = delimitedFileTable.GetColumnIndex(sourceColumn);

            if (index_Source == -1)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            int index_Template = delimitedFileTable.GetColumnIndex(templateColumn);

            if (index_Template == -1)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            int index_Destination = delimitedFileTable.GetColumnIndex(destinationColumn);

            if (index_Destination == -1)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            int index_Type = delimitedFileTable.GetColumnIndex(typeColumn);

            if (index_Type == -1)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            int index_Thickness = -1;

            if (!string.IsNullOrWhiteSpace(thicknessColumn))
            {
                index_Thickness = delimitedFileTable.GetColumnIndex(thicknessColumn);
            }

            Core.Revit.ConvertSettings convertSettings = null;

            if (convertSettings == null)
            {
                convertSettings = Core.Revit.Query.ConvertSettings();
            }

            ConstructionLibrary         constructionLibrary_Result         = new ConstructionLibrary(constructionLibrary.Name);
            ApertureConstructionLibrary apertureConstructionLibrary_Result = new ApertureConstructionLibrary(apertureConstructionLibrary.Name);

            List <Panel>       panels_Result          = new List <Panel>();
            List <Aperture>    apertures_Result       = new List <Aperture>();
            List <ElementType> elementTypes_Panels    = new List <ElementType>();
            List <ElementType> elementTypes_Apertures = new List <ElementType>();

            foreach (Panel panel in panels)
            {
                Construction construction = panel?.Construction;
                if (construction == null)
                {
                    continue;
                }

                string name = construction.Name;
                if (name == null)
                {
                    //result.Add(construction);
                    continue;
                }

                string    name_Destination = null;
                string    name_Template    = null;
                string    name_Source      = null;
                PanelType panelType        = PanelType.Undefined;
                double    thickness        = double.NaN;
                for (int i = 0; i < delimitedFileTable.RowCount; i++)
                {
                    string typeName = null;
                    if (delimitedFileTable.TryGetValue(i, index_Type, out typeName))
                    {
                        ApertureType apertureType = Analytical.Query.ApertureType(typeName);
                        if (apertureType != ApertureType.Undefined)
                        {
                            continue;
                        }

                        panelType = Analytical.Query.PanelType(typeName as object);
                    }

                    if (!delimitedFileTable.TryGetValue(i, index_Source, out name_Source))
                    {
                        continue;
                    }

                    if (!name.Equals(name_Source))
                    {
                        continue;
                    }

                    if (!delimitedFileTable.TryGetValue(i, index_Destination, out name_Destination))
                    {
                        name_Destination = null;
                        continue;
                    }

                    if (!delimitedFileTable.TryGetValue(i, index_Template, out name_Template))
                    {
                        name_Template = null;
                    }

                    if (index_Thickness != -1)
                    {
                        if (!delimitedFileTable.TryConvert(i, index_Thickness, out thickness))
                        {
                            thickness = double.NaN;
                        }
                    }

                    break;
                }

                if (string.IsNullOrWhiteSpace(name_Destination))
                {
                    name_Destination = name_Template;
                }

                if (string.IsNullOrWhiteSpace(name_Destination))
                {
                    continue;
                }

                if (panelType == PanelType.Undefined)
                {
                    panelType = panel.PanelType;
                }

                Construction construction_New = constructionLibrary_Result.GetConstructions(name_Destination)?.FirstOrDefault();
                if (construction_New == null)
                {
                    Construction construction_Temp = constructionLibrary.GetConstructions(name_Template)?.FirstOrDefault();
                    if (construction_Temp == null)
                    {
                        continue;
                    }

                    if (name_Destination.Equals(name_Template))
                    {
                        construction_New = construction_Temp;
                    }
                    else
                    {
                        construction_New = new Construction(construction_Temp, name_Destination);
                    }

                    construction_New.SetValue(ConstructionParameter.Description, construction.Name);
                    construction_New.RemoveValue(ConstructionParameter.DefaultPanelType);
                    //construction_New.SetValue(ConstructionParameter.DefaultPanelType, panelType.Text());

                    if (!double.IsNaN(thickness))
                    {
                        construction_New.SetValue(ConstructionParameter.DefaultThickness, thickness);
                    }

                    constructionLibrary_Result.Add(construction_New);
                }

                HostObjAttributes hostObjAttributes = Analytical.Revit.Convert.ToRevit(construction_New, document, panelType, panel.Normal, convertSettings);
                if (hostObjAttributes == null)
                {
                    if (string.IsNullOrWhiteSpace(name_Template))
                    {
                        Construction construction_Default = Analytical.Query.DefaultConstruction(panelType);
                        if (construction_Default != null)
                        {
                            name_Template = construction_Default.Name;
                        }
                    }

                    if (string.IsNullOrWhiteSpace(name_Template))
                    {
                        continue;
                    }

                    hostObjAttributes = Analytical.Revit.Modify.DuplicateByType(document, name_Template, panelType, construction_New) as HostObjAttributes;
                    if (hostObjAttributes == null)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, string.Format("Skipped - Could not duplicate construction for panel ({2}). Element Type Name for: {0}, could not be assinged from {1}", name, name_Template, panel.PanelType));
                        continue;
                    }
                }

                Panel panel_New = new Panel(panel, construction_New);
                if (panel_New.PanelType != panelType)
                {
                    panel_New = new Panel(panel_New, panelType);
                }

                List <Aperture> apertures = panel_New.Apertures;
                if (apertures != null && apertures.Count != 0)
                {
                    foreach (Aperture aperture in apertures)
                    {
                        panel_New.RemoveAperture(aperture.Guid);

                        ApertureConstruction apertureConstruction = aperture?.ApertureConstruction;
                        if (apertureConstruction == null)
                        {
                            continue;
                        }

                        name = apertureConstruction.Name;
                        if (name == null)
                        {
                            continue;
                        }

                        name_Destination = null;
                        name_Template    = null;
                        name_Source      = null;
                        ApertureType apertureType = ApertureType.Undefined;
                        for (int i = 0; i < delimitedFileTable.RowCount; i++)
                        {
                            string typeName = null;
                            if (!delimitedFileTable.TryGetValue(i, index_Type, out typeName))
                            {
                                continue;
                            }

                            apertureType = Analytical.Query.ApertureType(typeName);
                            if (apertureType == ApertureType.Undefined)
                            {
                                continue;
                            }

                            if (!delimitedFileTable.TryGetValue(i, index_Source, out name_Source))
                            {
                                continue;
                            }

                            if (!name.Equals(name_Source))
                            {
                                continue;
                            }

                            if (!delimitedFileTable.TryGetValue(i, index_Destination, out name_Destination))
                            {
                                name_Destination = null;
                                continue;
                            }

                            if (!delimitedFileTable.TryGetValue(i, index_Template, out name_Template))
                            {
                                name_Template = null;
                            }

                            break;
                        }


                        if (string.IsNullOrWhiteSpace(name_Destination))
                        {
                            name_Destination = name_Template;
                        }

                        if (string.IsNullOrWhiteSpace(name_Destination))
                        {
                            continue;
                        }

                        if (apertureType == ApertureType.Undefined)
                        {
                            continue;
                        }

                        ApertureConstruction apertureConstruction_New = apertureConstructionLibrary_Result.GetApertureConstructions(name_Destination, Core.TextComparisonType.Equals, true, apertureType)?.FirstOrDefault();
                        if (apertureConstruction_New == null)
                        {
                            ApertureConstruction apertureConstruction_Temp = apertureConstructionLibrary.GetApertureConstructions(name_Template, Core.TextComparisonType.Equals, true, apertureType)?.FirstOrDefault();
                            if (apertureConstruction_Temp == null)
                            {
                                continue;
                            }

                            if (name_Destination.Equals(name_Template))
                            {
                                apertureConstruction_New = apertureConstruction_Temp;
                            }
                            else
                            {
                                apertureConstruction_New = new ApertureConstruction(apertureConstruction_Temp, name_Destination);
                            }

                            apertureConstruction_New.SetValue(ApertureConstructionParameter.Description, apertureConstruction.Name);

                            apertureConstructionLibrary_Result.Add(apertureConstruction_New);
                        }

                        FamilySymbol familySymbol = Analytical.Revit.Convert.ToRevit(apertureConstruction_New, document, convertSettings);
                        if (familySymbol == null)
                        {
                            if (string.IsNullOrWhiteSpace(name_Template))
                            {
                                ApertureConstruction apertureConstruction_Default = Analytical.Query.DefaultApertureConstruction(panelType, apertureType);
                                if (apertureConstruction_Default != null)
                                {
                                    name_Template = apertureConstruction_Default.Name;
                                }
                            }

                            if (string.IsNullOrWhiteSpace(name_Template))
                            {
                                continue;
                            }

                            familySymbol = Analytical.Revit.Modify.DuplicateByType(document, name_Template, apertureConstruction_New) as FamilySymbol;
                            if (familySymbol == null)
                            {
                                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, string.Format("Skipped - Could not duplicate construction for panel ({2}). Element Type Name for: {0}, could not be assinged from {1}", name, name_Template, panel.PanelType));
                                continue;
                            }
                        }

                        Aperture aperture_New = new Aperture(aperture, apertureConstruction_New);
                        if (panel_New.AddAperture(aperture_New))
                        {
                            elementTypes_Apertures.Add(familySymbol);
                            apertures_Result.Add(aperture_New);
                        }
                    }
                }

                elementTypes_Panels.Add(hostObjAttributes);
                panels_Result.Add(panel_New);
            }

            dataAccess.SetDataList(0, elementTypes_Panels);
            dataAccess.SetDataList(1, elementTypes_Apertures);
            dataAccess.SetDataList(2, panels_Result.ConvertAll(x => new GooPanel(x)));
            dataAccess.SetDataList(3, apertures_Result.ConvertAll(x => new GooAperture(x)));
            dataAccess.SetData(4, new GooConstructionLibrary(constructionLibrary_Result));
            dataAccess.SetData(5, new GooApertureConstructionLibrary(apertureConstructionLibrary_Result));
        }
Exemple #12
0
        public static TBD.Building ToTBD(this AnalyticalModel analyticalModel, TBD.TBDDocument tBDDocument)
        {
            if (analyticalModel == null)
            {
                return(null);
            }

            TBD.Building result = tBDDocument.Building;
            if (result == null)
            {
                return(null);
            }

            AdjacencyCluster adjacencyCluster = analyticalModel.AdjacencyCluster;

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

            List <Space> spaces = adjacencyCluster.GetSpaces();

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

            MaterialLibrary materialLibrary = analyticalModel.MaterialLibrary;

            Plane plane = Plane.WorldXY;

            List <TBD.DaysShade> daysShades = new List <TBD.DaysShade>();

            result.ClearShadingData();

            Dictionary <System.Guid, List <TBD.zoneSurface> > dictionary_Panel    = new Dictionary <System.Guid, List <TBD.zoneSurface> >();
            Dictionary <System.Guid, List <TBD.zoneSurface> > dictionary_Aperture = new Dictionary <System.Guid, List <TBD.zoneSurface> >();

            foreach (Space space in spaces)
            {
                Shell shell = adjacencyCluster.Shell(space);
                if (shell == null)
                {
                    return(null);
                }

                TBD.zone zone = result.AddZone();
                zone.name   = space.Name;
                zone.volume = System.Convert.ToSingle(shell.Volume());

                if (space.TryGetValue(SpaceParameter.Color, out SAMColor sAMColor) && sAMColor != null)
                {
                    zone.colour = Core.Convert.ToUint(sAMColor.ToColor());
                }

                List <Face3D> face3Ds = Geometry.Spatial.Query.Section(shell, 0.01, false);
                if (face3Ds != null && face3Ds.Count != 0)
                {
                    face3Ds.RemoveAll(x => x == null || !x.IsValid());
                    zone.floorArea        = System.Convert.ToSingle(face3Ds.ConvertAll(x => x.GetArea()).Sum());
                    zone.exposedPerimeter = System.Convert.ToSingle(face3Ds.ConvertAll(x => Geometry.Planar.Query.Perimeter(x.ExternalEdge2D)).Sum());
                    zone.length           = System.Convert.ToSingle(face3Ds.ConvertAll(x => Geometry.Tas.Query.Length(x)).Sum());
                }

                TBD.room room = zone.AddRoom();

                List <TBD.buildingElement> buildingElements = result.BuildingElements();
                List <TBD.Construction>    constructions    = result.Constructions();

                List <Panel> panels = adjacencyCluster?.GetPanels(space);
                if (panels != null || panels.Count != 0)
                {
                    foreach (Panel panel in panels)
                    {
                        string name_Panel = panel.Name;
                        if (string.IsNullOrWhiteSpace(name_Panel))
                        {
                            continue;
                        }

                        Face3D face3D_Panel = panel.Face3D;
                        if (face3D_Panel == null)
                        {
                            continue;
                        }

                        BoundingBox3D boundingBox3D_Panel = face3D_Panel.GetBoundingBox();

                        TBD.zoneSurface zoneSurface_Panel = zone.AddSurface();
                        zoneSurface_Panel.orientation = System.Convert.ToSingle(Geometry.Spatial.Query.Azimuth(panel, Vector3D.WorldY));
                        zoneSurface_Panel.inclination = System.Convert.ToSingle(Geometry.Spatial.Query.Tilt(panel));

                        zoneSurface_Panel.altitude              = System.Convert.ToSingle(boundingBox3D_Panel.GetCentroid().Z);
                        zoneSurface_Panel.altitudeRange         = System.Convert.ToSingle(boundingBox3D_Panel.Max.Z - boundingBox3D_Panel.Min.Z);
                        zoneSurface_Panel.area                  = System.Convert.ToSingle(face3D_Panel.GetArea());
                        zoneSurface_Panel.planHydraulicDiameter = System.Convert.ToSingle(Geometry.Tas.Query.HydraulicDiameter(face3D_Panel));

                        TBD.RoomSurface roomSurface_Panel = room.AddSurface();
                        roomSurface_Panel.area        = zoneSurface_Panel.area;
                        roomSurface_Panel.zoneSurface = zoneSurface_Panel;

                        Geometry.SolarCalculator.SolarFaceSimulationResult solarFaceSimulationResult = analyticalModel.GetResults <Geometry.SolarCalculator.SolarFaceSimulationResult>(panel)?.FirstOrDefault();
                        if (solarFaceSimulationResult != null)
                        {
                            List <TBD.SurfaceShade> surfaceShades = Modify.UpdateSurfaceShades(result, daysShades, zoneSurface_Panel, analyticalModel, solarFaceSimulationResult);
                        }

                        TBD.Perimeter perimeter_Panel = Geometry.Tas.Convert.ToTBD(panel.GetFace3D(true), roomSurface_Panel);
                        if (perimeter_Panel == null)
                        {
                            continue;
                        }

                        PanelType panelType = panel.PanelType;

                        TBD.buildingElement buildingElement_Panel = buildingElements.Find(x => x.name == name_Panel);
                        if (buildingElement_Panel == null)
                        {
                            TBD.Construction construction_TBD = null;

                            Construction construction = panel.Construction;
                            if (construction != null)
                            {
                                construction_TBD = constructions.Find(x => x.name == construction.Name);
                                if (construction_TBD == null)
                                {
                                    construction_TBD      = result.AddConstruction(null);
                                    construction_TBD.name = construction.Name;

                                    if (construction.Transparent(materialLibrary))
                                    {
                                        construction_TBD.type = TBD.ConstructionTypes.tcdTransparentConstruction;
                                    }

                                    List <ConstructionLayer> constructionLayers = construction.ConstructionLayers;
                                    if (constructionLayers != null && constructionLayers.Count != 0)
                                    {
                                        int index = 1;
                                        foreach (ConstructionLayer constructionLayer in constructionLayers)
                                        {
                                            Material material = analyticalModel?.MaterialLibrary?.GetMaterial(constructionLayer.Name) as Core.Material;
                                            if (material == null)
                                            {
                                                continue;
                                            }

                                            TBD.material material_TBD = construction_TBD.AddMaterial(material);
                                            if (material_TBD != null)
                                            {
                                                material_TBD.width = System.Convert.ToSingle(constructionLayer.Thickness);
                                                construction_TBD.materialWidth[index] = System.Convert.ToSingle(constructionLayer.Thickness);
                                                index++;
                                            }
                                        }
                                    }

                                    constructions.Add(construction_TBD);
                                }

                                if (panelType == PanelType.Undefined && construction != null)
                                {
                                    panelType = construction.PanelType();
                                    if (panelType == PanelType.Undefined && construction.TryGetValue(ConstructionParameter.DefaultPanelType, out string panelTypeString))
                                    {
                                        panelType = Core.Query.Enum <PanelType>(panelTypeString);
                                    }
                                }
                            }

                            buildingElement_Panel        = result.AddBuildingElement();
                            buildingElement_Panel.name   = name_Panel;
                            buildingElement_Panel.colour = Core.Convert.ToUint(Analytical.Query.Color(panelType));
                            buildingElement_Panel.BEType = Query.BEType(panelType.Text());
                            buildingElement_Panel.AssignConstruction(construction_TBD);
                            buildingElements.Add(buildingElement_Panel);
                        }

                        if (buildingElement_Panel != null)
                        {
                            zoneSurface_Panel.buildingElement = buildingElement_Panel;
                        }

                        zoneSurface_Panel.type = TBD.SurfaceType.tbdExposed;

                        List <Aperture> apertures = panel.Apertures;
                        if (apertures != null && apertures.Count != 0)
                        {
                            bool @internal = adjacencyCluster.Internal(panel);

                            foreach (Aperture aperture in apertures)
                            {
                                string name_Aperture = aperture.Name;
                                if (string.IsNullOrWhiteSpace(name_Aperture))
                                {
                                    continue;
                                }

                                name_Aperture = string.Format("{0} -pane", aperture.Name);

                                Face3D face3D_Aperture = aperture.Face3D;
                                if (face3D_Aperture == null)
                                {
                                    continue;
                                }

                                BoundingBox3D boundingBox3D_Aperture = face3D_Aperture.GetBoundingBox();

                                float area = System.Convert.ToSingle(face3D_Aperture.GetArea());

                                TBD.zoneSurface zoneSurface_Aperture = zoneSurface_Panel.AddChildSurface(area);
                                if (zoneSurface_Aperture == null)
                                {
                                    continue;
                                }

                                zoneSurface_Aperture.orientation           = zoneSurface_Panel.orientation;
                                zoneSurface_Aperture.inclination           = zoneSurface_Panel.inclination;
                                zoneSurface_Aperture.altitude              = System.Convert.ToSingle(boundingBox3D_Aperture.GetCentroid().Z);
                                zoneSurface_Aperture.altitudeRange         = System.Convert.ToSingle(boundingBox3D_Aperture.Max.Z - boundingBox3D_Aperture.Min.Z);
                                zoneSurface_Aperture.planHydraulicDiameter = System.Convert.ToSingle(Geometry.Tas.Query.HydraulicDiameter(face3D_Aperture));
                                //zoneSurface_Aperture.area = System.Convert.ToSingle(face3D_Aperture.GetArea());

                                zoneSurface_Aperture.type = @internal ? TBD.SurfaceType.tbdLink : zoneSurface_Panel.type;

                                TBD.RoomSurface roomSurface_Aperture = room.AddSurface();
                                roomSurface_Aperture.area        = zoneSurface_Aperture.area;
                                roomSurface_Aperture.zoneSurface = zoneSurface_Aperture;

                                TBD.Perimeter perimeter_Aperture = Geometry.Tas.Convert.ToTBD(face3D_Aperture, roomSurface_Aperture);
                                if (perimeter_Aperture == null)
                                {
                                    continue;
                                }

                                TBD.buildingElement buildingElement_Aperture = buildingElements.Find(x => x.name == name_Aperture);
                                if (buildingElement_Aperture == null)
                                {
                                    TBD.Construction construction_TBD = null;

                                    ApertureConstruction apertureConstruction = aperture.ApertureConstruction;
                                    if (apertureConstruction != null)
                                    {
                                        construction_TBD = constructions.Find(x => x.name == apertureConstruction.Name);
                                        if (construction_TBD == null)
                                        {
                                            construction_TBD      = result.AddConstruction(null);
                                            construction_TBD.name = name_Aperture;

                                            if (apertureConstruction.Transparent(materialLibrary))
                                            {
                                                construction_TBD.type = TBD.ConstructionTypes.tcdTransparentConstruction;
                                            }

                                            List <ConstructionLayer> constructionLayers = apertureConstruction.PaneConstructionLayers;
                                            if (constructionLayers != null && constructionLayers.Count != 0)
                                            {
                                                int index = 1;
                                                foreach (ConstructionLayer constructionLayer in constructionLayers)
                                                {
                                                    Core.Material material = materialLibrary?.GetMaterial(constructionLayer.Name) as Material;
                                                    if (material == null)
                                                    {
                                                        continue;
                                                    }

                                                    TBD.material material_TBD = construction_TBD.AddMaterial(material);
                                                    if (material_TBD != null)
                                                    {
                                                        material_TBD.width = System.Convert.ToSingle(constructionLayer.Thickness);
                                                        construction_TBD.materialWidth[index] = System.Convert.ToSingle(constructionLayer.Thickness);
                                                        index++;
                                                    }
                                                }
                                            }

                                            constructions.Add(construction_TBD);
                                        }
                                    }

                                    ApertureType apertureType = aperture.ApertureType;

                                    buildingElement_Aperture        = result.AddBuildingElement();
                                    buildingElement_Aperture.name   = name_Aperture;
                                    buildingElement_Aperture.colour = Core.Convert.ToUint(Analytical.Query.Color(apertureType));
                                    buildingElement_Aperture.BEType = Query.BEType(apertureType, false);
                                    buildingElement_Aperture.AssignConstruction(construction_TBD);
                                    buildingElements.Add(buildingElement_Aperture);
                                }

                                if (buildingElement_Aperture != null)
                                {
                                    zoneSurface_Aperture.buildingElement = buildingElement_Aperture;
                                }

                                if (!dictionary_Aperture.TryGetValue(aperture.Guid, out List <TBD.zoneSurface> zoneSurfaces_Aperture) || zoneSurfaces_Aperture == null)
                                {
                                    zoneSurfaces_Aperture = new List <TBD.zoneSurface>();
                                    dictionary_Aperture[aperture.Guid] = zoneSurfaces_Aperture;
                                }

                                zoneSurfaces_Aperture.Add(zoneSurface_Aperture);
                            }
                        }

                        zoneSurface_Panel.type = Query.SurfaceType(panelType);

                        if (!dictionary_Panel.TryGetValue(panel.Guid, out List <TBD.zoneSurface> zoneSurfaces_Panel) || zoneSurfaces_Panel == null)
                        {
                            zoneSurfaces_Panel           = new List <TBD.zoneSurface>();
                            dictionary_Panel[panel.Guid] = zoneSurfaces_Panel;
                        }

                        zoneSurfaces_Panel.Add(zoneSurface_Panel);
                    }
                }
            }

            foreach (KeyValuePair <System.Guid, List <TBD.zoneSurface> > keyValuePair in dictionary_Panel)
            {
                if (keyValuePair.Value == null || keyValuePair.Value.Count <= 1)
                {
                    continue;
                }

                keyValuePair.Value[1].linkSurface = keyValuePair.Value[0];
                keyValuePair.Value[0].linkSurface = keyValuePair.Value[1];

                if (keyValuePair.Value[0].inclination == 0 || keyValuePair.Value[0].inclination == 180)
                {
                    float inclination = keyValuePair.Value[1].inclination;
                    inclination -= 180;
                    if (inclination < 0)
                    {
                        inclination += 360;
                    }

                    keyValuePair.Value[1].inclination = inclination;
                    keyValuePair.Value[1].reversed    = 1;
                }
                else
                {
                    float orientation = keyValuePair.Value[1].orientation;
                    orientation += 180;
                    if (orientation >= 360)
                    {
                        orientation -= 360;
                    }

                    keyValuePair.Value[1].orientation = orientation;
                    keyValuePair.Value[1].reversed    = 1;

                    float inclination = keyValuePair.Value[1].inclination;
                    if (inclination > 180)
                    {
                        inclination -= 180;
                    }
                    keyValuePair.Value[1].inclination = inclination;
                }
            }

            foreach (KeyValuePair <System.Guid, List <TBD.zoneSurface> > keyValuePair in dictionary_Aperture)
            {
                if (keyValuePair.Value == null || keyValuePair.Value.Count <= 1)
                {
                    continue;
                }

                keyValuePair.Value[1].linkSurface = keyValuePair.Value[0];
                keyValuePair.Value[0].linkSurface = keyValuePair.Value[1];

                if (keyValuePair.Value[0].inclination == 0 || keyValuePair.Value[0].inclination == 180)
                {
                    float inclination = keyValuePair.Value[0].inclination;
                    inclination -= 180;
                    if (inclination < 0)
                    {
                        inclination += 360;
                    }

                    keyValuePair.Value[0].inclination = inclination;
                    keyValuePair.Value[0].reversed    = 1;
                }
                else
                {
                    float orientation = keyValuePair.Value[1].orientation;
                    orientation += 180;
                    if (orientation >= 360)
                    {
                        orientation -= 360;
                    }

                    keyValuePair.Value[1].orientation = orientation;
                    keyValuePair.Value[1].reversed    = 1;
                }
            }

            return(result);
        }