示例#1
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);
        }
示例#2
0
        protected override void TrySolveInstance(IGH_DataAccess dataAccess)
        {
            int index = -1;

            bool run = false;

            index = Params.IndexOfInputParam("_run");
            if (index == -1 || !dataAccess.GetData(index, ref run) || !run)
            {
                return;
            }

            Document document = RhinoInside.Revit.Revit.ActiveDBDocument;

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

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

            index = Params.IndexOfInputParam("_panels_");
            if (index == -1 || !dataAccess.GetDataList(index, panels))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            ConstructionLibrary constructionLibrary = null;

            index = Params.IndexOfInputParam("constructionLibrary_");
            if (index != -1)
            {
                dataAccess.GetData(index, ref constructionLibrary);
            }

            if (constructionLibrary == null)
            {
                constructionLibrary = ActiveSetting.Setting.GetValue <ConstructionLibrary>(AnalyticalSettingParameter.DefaultConstructionLibrary);
            }

            ApertureConstructionLibrary apertureConstructionLibrary = null;

            index = Params.IndexOfInputParam("apertureConstructionLibrary_");
            if (index != -1)
            {
                dataAccess.GetData(index, ref apertureConstructionLibrary);
            }

            if (apertureConstructionLibrary == null)
            {
                apertureConstructionLibrary = ActiveSetting.Setting.GetValue <ApertureConstructionLibrary>(AnalyticalSettingParameter.DefaultApertureConstructionLibrary);
            }

            Core.DelimitedFileTable delimitedFileTable = null;
            index = Params.IndexOfInputParam("_delimitedFileTable");
            if (index == -1 || !dataAccess.GetData(index, ref delimitedFileTable) || delimitedFileTable == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            string sourceColumn = null;

            index = Params.IndexOfInputParam("_sourceColumn_");
            if (index == -1 || !dataAccess.GetData(index, ref sourceColumn) || string.IsNullOrWhiteSpace(sourceColumn))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            string templateColumn = null;

            index = Params.IndexOfInputParam("_defaultColumn_");
            if (index == -1 || !dataAccess.GetData(index, ref templateColumn) || string.IsNullOrWhiteSpace(templateColumn))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            string destinationColumn = null;

            index = Params.IndexOfInputParam("_destinationColumn_");
            if (index == -1 || !dataAccess.GetData(index, ref destinationColumn) || string.IsNullOrWhiteSpace(destinationColumn))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            string typeColumn = null;

            index = Params.IndexOfInputParam("_typeColumn_");
            if (index == -1 || !dataAccess.GetData(index, ref typeColumn) || string.IsNullOrWhiteSpace(typeColumn))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            string thicknessColumn = null;

            index = Params.IndexOfInputParam("_thicknessColumn_");
            if (index != -1)
            {
                dataAccess.GetData(index, ref thicknessColumn);
            }

            ConstructionLibrary         constructionLibrary_Result         = null;
            ApertureConstructionLibrary apertureConstructionLibrary_Result = null;

            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>();

            StartTransaction(document);

            Analytical.Revit.Modify.UpdateConstructions(
                document,
                panels,
                delimitedFileTable,
                constructionLibrary,
                apertureConstructionLibrary,
                out panels_Result,
                out apertures_Result,
                out elementTypes_Panels,
                out elementTypes_Apertures,
                out constructionLibrary_Result,
                out apertureConstructionLibrary_Result,
                sourceColumn,
                destinationColumn,
                templateColumn,
                typeColumn,
                thicknessColumn);

            index = Params.IndexOfOutputParam("elementTypes_Panels");
            if (index != -1)
            {
                dataAccess.SetDataList(index, elementTypes_Panels);
            }

            index = Params.IndexOfOutputParam("elementTypes_Apertures");
            if (index != -1)
            {
                dataAccess.SetDataList(index, elementTypes_Apertures);
            }

            index = Params.IndexOfOutputParam("panels");
            if (index != -1)
            {
                dataAccess.SetDataList(index, panels_Result.ConvertAll(x => new GooPanel(x)));
            }

            index = Params.IndexOfOutputParam("apertures");
            if (index != -1)
            {
                dataAccess.SetDataList(index, apertures_Result.ConvertAll(x => new GooAperture(x)));
            }

            index = Params.IndexOfOutputParam("constructionLibrary");
            if (index != -1)
            {
                dataAccess.SetData(index, new GooConstructionLibrary(constructionLibrary_Result));
            }

            index = Params.IndexOfOutputParam("apertureConstructionLibrary");
            if (index != -1)
            {
                dataAccess.SetData(index, new GooApertureConstructionLibrary(apertureConstructionLibrary_Result));
            }
        }
示例#3
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));
        }