/// <summary>
        /// Method to convert a list of loads into dictionaries containing GsaAPI objects
        /// </summary>
        /// <param name="loads"></param>
        /// <param name="gravityLoads"></param>
        /// <param name="nodeLoads_node"></param>
        /// <param name="nodeLoads_displ"></param>
        /// <param name="nodeLoads_settle"></param>
        /// <param name="beamLoads"></param>
        /// <param name="faceLoads"></param>
        /// <param name="gridPointLoads"></param>
        /// <param name="gridLineLoads"></param>
        /// <param name="gridAreaLoads"></param>
        /// <param name="existingAxes"></param>
        /// <param name="existingGridPlanes"></param>
        /// <param name="existingGridSurfaces"></param>
        /// <param name="gp_guid"></param>
        /// <param name="gs_guid"></param>
        /// <param name="workerInstance"></param>
        /// <param name="ReportProgress"></param>
        public static void ConvertLoad(List <GsaLoad> loads,
                                       ref List <GravityLoad> gravityLoads,
                                       ref List <NodeLoad> nodeLoads_node, ref List <NodeLoad> nodeLoads_displ, ref List <NodeLoad> nodeLoads_settle,
                                       ref List <BeamLoad> beamLoads, ref List <FaceLoad> faceLoads,
                                       ref List <GridPointLoad> gridPointLoads, ref List <GridLineLoad> gridLineLoads, ref List <GridAreaLoad> gridAreaLoads,
                                       ref Dictionary <int, Axis> existingAxes,
                                       ref Dictionary <int, GridPlane> existingGridPlanes,
                                       ref Dictionary <int, GridSurface> existingGridSurfaces,
                                       ref Dictionary <Guid, int> gp_guid, ref Dictionary <Guid, int> gs_guid,
                                       GrasshopperAsyncComponent.WorkerInstance workerInstance = null,
                                       Action <string, double> ReportProgress = null)
        {
            if (loads != null)
            {
                if (workerInstance != null)
                {
                    ReportProgress("Initiating Loads assembly", -2);
                }

                // create a counter for creating new axes, gridplanes and gridsurfaces
                int axisidcounter        = (existingAxes.Count > 0) ? existingAxes.Keys.Max() + 1 : 1;
                int gridplaneidcounter   = (existingGridPlanes.Count > 0) ? existingGridPlanes.Keys.Max() + 1 : 1;
                int gridsurfaceidcounter = (existingGridSurfaces.Count > 0) ? existingGridSurfaces.Keys.Max() + 1 : 1;

                // get the highest gridplaneID+1 and gridsurfaceID+1
                GetGridPlaneSurfaceCounters(loads, ref gridplaneidcounter, ref gridsurfaceidcounter);

                for (int i = 0; i < loads.Count; i++)
                {
                    if (workerInstance != null)
                    {
                        if (workerInstance.CancellationToken.IsCancellationRequested)
                        {
                            return;
                        }
                        ReportProgress("Assembling Loads ", (double)i / (loads.Count - 1));
                    }

                    if (loads[i] != null)
                    {
                        GsaLoad load = loads[i];
                        ConvertLoad(load, ref gravityLoads, ref nodeLoads_node, ref nodeLoads_displ, ref nodeLoads_settle,
                                    ref beamLoads, ref faceLoads, ref gridPointLoads, ref gridLineLoads, ref gridAreaLoads,
                                    ref existingAxes, ref axisidcounter, ref existingGridPlanes, ref gridplaneidcounter,
                                    ref existingGridSurfaces, ref gridsurfaceidcounter, ref gp_guid, ref gs_guid);
                    }
                }
            }
            if (workerInstance != null)
            {
                ReportProgress("Loads assembled", -2);
            }
        }
Пример #2
0
        public static void ConvertNode(List <GsaNode> nodes, ref Dictionary <int, Node> existingNodes,
                                       ref Dictionary <int, Axis> existingAxes,
                                       GrasshopperAsyncComponent.WorkerInstance workerInstance = null,
                                       Action <string, double> ReportProgress = null)
        {
            int nodeidcounter = (existingNodes.Count > 0) ? existingNodes.Keys.Max() + 1 : 1;

            // Add/Set Nodes
            if (nodes != null)
            {
                if (nodes.Count > 0)
                {
                    // update counter if new nodes have set ID higher than existing max
                    int existingNodeMaxID = nodes.Max(x => x.ID); // max ID in new nodes
                    if (existingNodeMaxID > nodeidcounter)
                    {
                        nodeidcounter = existingNodeMaxID + 1;
                    }

                    for (int i = 0; i < nodes.Count; i++)
                    {
                        // if method is called by a Async component check for cancellation and report progress
                        if (workerInstance != null)
                        {
                            if (workerInstance.CancellationToken.IsCancellationRequested)
                            {
                                return;
                            }
                            ReportProgress("Nodes ", (double)i / (nodes.Count - 1));
                        }

                        if (nodes[i] != null)
                        {
                            GsaNode node = nodes[i];

                            // Add / Set node in dictionary
                            ConvertNode(node, ref existingNodes, ref existingAxes, ref nodeidcounter);
                        }
                    }
                }
            }
            if (workerInstance != null)
            {
                ReportProgress("Nodes assembled", -2);
            }
        }
        /// <summary>
        /// Method to convert a list of GridPlaneSurfaces and set Axes, GridPlanes and GridSurfaces in ref Dictionaries
        /// </summary>
        /// <param name="gridPlaneSurfaces"></param>
        /// <param name="existingAxes"></param>
        /// <param name="existingGridPlanes"></param>
        /// <param name="existingGridSurfaces"></param>
        /// <param name="gp_guid"></param>
        /// <param name="gs_guid"></param>
        /// <param name="workerInstance"></param>
        /// <param name="ReportProgress"></param>
        public static void ConvertGridPlaneSurface(List <GsaGridPlaneSurface> gridPlaneSurfaces,
                                                   ref Dictionary <int, Axis> existingAxes, ref Dictionary <int, GridPlane> existingGridPlanes,
                                                   ref Dictionary <int, GridSurface> existingGridSurfaces,
                                                   ref Dictionary <Guid, int> gp_guid, ref Dictionary <Guid, int> gs_guid,
                                                   GrasshopperAsyncComponent.WorkerInstance workerInstance = null,
                                                   Action <string, double> ReportProgress = null)
        {
            if (gridPlaneSurfaces != null)
            {
                if (workerInstance != null)
                {
                    ReportProgress("Initiating GridPlaneSurfaces assembly", -2);
                }

                // create a counter for creating new axes, gridplanes and gridsurfaces
                int axisidcounter        = (existingAxes.Count > 0) ? existingAxes.Keys.Max() + 1 : 1;
                int gridplaneidcounter   = (existingGridPlanes.Count > 0) ? existingGridPlanes.Keys.Max() + 1 : 1;
                int gridsurfaceidcounter = (existingGridSurfaces.Count > 0) ? existingGridSurfaces.Keys.Max() + 1 : 1;

                // get the highest gridplaneID+1 and gridsurfaceID+1
                GetGridPlaneSurfaceCounters(gridPlaneSurfaces, ref gridplaneidcounter, ref gridsurfaceidcounter);

                for (int i = 0; i < gridPlaneSurfaces.Count; i++)
                {
                    if (gridPlaneSurfaces[i] != null)
                    {
                        GsaGridPlaneSurface gps = gridPlaneSurfaces[i];

                        if (gps.GridPlane != null)
                        {
                            // add / set Axis and set the id in the grid plane
                            gps.GridPlane.AxisProperty = SetAxis(ref gps, ref existingAxes, ref axisidcounter);

                            // add / set Grid Plane and set the id in the grid surface
                            gps.GridSurface.GridPlane = SetGridPlane(ref gps, ref existingGridPlanes, ref gridplaneidcounter, ref gp_guid, existingAxes);
                        }
                        // add / set Grid Surface
                        SetGridSurface(ref gps, ref existingGridSurfaces, ref gridsurfaceidcounter, ref gs_guid, existingGridPlanes, existingAxes);
                    }
                }
            }
            if (workerInstance != null)
            {
                ReportProgress("GridPlaneSurfaces assembled", -2);
            }
        }
Пример #4
0
        public static void ConvertElement2D(List <GsaElement2d> element2ds,
                                            ref Dictionary <int, Element> existingElements, ref int elementidcounter,
                                            ref Dictionary <int, Node> existingNodes,
                                            ref Dictionary <int, Prop2D> existingProp2Ds, ref Dictionary <Guid, int> prop2d_guid,
                                            GrasshopperAsyncComponent.WorkerInstance workerInstance = null,
                                            Action <string, double> ReportProgress = null)
        {
            // create a counter for creating new elements, nodes and properties
            int nodeidcounter   = (existingNodes.Count > 0) ? existingNodes.Keys.Max() + 1 : 1;
            int prop2didcounter = (existingProp2Ds.Count > 0) ? existingProp2Ds.Keys.Max() + 1 : 1; //checking the existing model

            // Elem2ds
            if (element2ds != null)
            {
                for (int i = 0; i < element2ds.Count; i++)
                {
                    if (workerInstance != null)
                    {
                        if (workerInstance.CancellationToken.IsCancellationRequested)
                        {
                            return;
                        }
                        ReportProgress("Elem2D ", (double)i / (element2ds.Count - 1));
                    }


                    if (element2ds[i] != null)
                    {
                        GsaElement2d element2d = element2ds[i];

                        ConvertElement2D(element2d,
                                         ref existingElements, ref elementidcounter,
                                         ref existingNodes, ref nodeidcounter,
                                         ref existingProp2Ds, ref prop2d_guid);
                    }
                }
            }
            if (workerInstance != null)
            {
                ReportProgress("Elem2D assembled", -2);
            }
        }
Пример #5
0
        public static void ConvertMember2D(List <GsaMember2d> member2ds,
                                           ref Dictionary <int, Member> existingMembers, ref int memberidcounter,
                                           ref Dictionary <int, Node> existingNodes,
                                           ref Dictionary <int, Prop2D> existingProp2Ds, ref Dictionary <Guid, int> prop2d_guid,
                                           GrasshopperAsyncComponent.WorkerInstance workerInstance = null,
                                           Action <string, double> ReportProgress = null)
        {
            // create a counter for creating new elements, nodes and properties
            int nodeidcounter = (existingNodes.Count > 0) ? existingNodes.Keys.Max() + 1 : 1;

            if (member2ds != null)
            {
                for (int i = 0; i < member2ds.Count; i++)
                {
                    if (workerInstance != null)
                    {
                        if (workerInstance.CancellationToken.IsCancellationRequested)
                        {
                            return;
                        }
                        ReportProgress("Mem2D ", (double)i / (member2ds.Count - 1));
                    }


                    if (member2ds[i] != null)
                    {
                        GsaMember2d member2d = member2ds[i];

                        ConvertMember2D(member2d,
                                        ref existingMembers, ref memberidcounter,
                                        ref existingNodes, ref nodeidcounter,
                                        ref existingProp2Ds, ref prop2d_guid);
                    }
                }
            }
            if (workerInstance != null)
            {
                ReportProgress("Mem2D assembled", -2);
            }
        }
Пример #6
0
        public static void ConvertElement1D(List <GsaElement1d> element1ds,
                                            ref Dictionary <int, Element> existingElements, ref int elementidcounter,
                                            ref Dictionary <int, Node> existingNodes,
                                            ref Dictionary <int, Section> existingSections, ref Dictionary <Guid, int> sections_guid,
                                            GrasshopperAsyncComponent.WorkerInstance workerInstance = null,
                                            Action <string, double> ReportProgress = null)
        {
            int nodeidcounter = (existingNodes.Count > 0) ? existingNodes.Keys.Max() + 1 : 1;

            // Elem1ds
            if (element1ds != null)
            {
                for (int i = 0; i < element1ds.Count; i++)
                {
                    if (workerInstance != null)
                    {
                        if (workerInstance.CancellationToken.IsCancellationRequested)
                        {
                            return;
                        }
                        ReportProgress("Elem1D ", (double)i / (element1ds.Count - 1));
                    }


                    if (element1ds[i] != null)
                    {
                        GsaElement1d element1d = element1ds[i];

                        // Add/set element
                        ConvertElement1D(element1d, ref existingElements, ref elementidcounter,
                                         ref existingNodes, ref nodeidcounter, ref existingSections, ref sections_guid);
                    }
                }
            }
            if (workerInstance != null)
            {
                ReportProgress("Elem1D assembled", -2);
            }
        }
Пример #7
0
        public static void ConvertMember1D(List <GsaMember1d> member1ds,
                                           ref Dictionary <int, Member> existingMembers, ref int memberidcounter,
                                           ref Dictionary <int, Node> existingNodes,
                                           ref Dictionary <int, Section> existingSections, ref Dictionary <Guid, int> sections_guid,
                                           GrasshopperAsyncComponent.WorkerInstance workerInstance = null,
                                           Action <string, double> ReportProgress = null)
        {
            int nodeidcounter = (existingNodes.Count > 0) ? existingNodes.Keys.Max() + 1 : 1;

            // Mem1ds
            if (member1ds != null)
            {
                for (int i = 0; i < member1ds.Count; i++)
                {
                    if (workerInstance != null)
                    {
                        if (workerInstance.CancellationToken.IsCancellationRequested)
                        {
                            return;
                        }
                        ReportProgress("Mem1D ", (double)i / (member1ds.Count - 1));
                    }


                    if (member1ds[i] != null)
                    {
                        GsaMember1d member1d = member1ds[i];

                        ConvertMember1D(member1d, ref existingMembers, ref memberidcounter, ref existingNodes, ref nodeidcounter, ref existingSections, ref sections_guid);
                    }
                }
            }
            if (workerInstance != null)
            {
                ReportProgress("Mem1D assembled", -2);
            }
        }
Пример #8
0
        public static void ConvertProp2d(List <GsaProp2d> prop2Ds,
                                         ref Dictionary <int, Prop2D> existingProp2Ds, ref Dictionary <Guid, int> prop2d_guid,
                                         GrasshopperAsyncComponent.WorkerInstance workerInstance = null,
                                         Action <string, double> ReportProgress = null)
        {
            // create a counter for creating new properties
            int prop2didcounter = (existingProp2Ds.Count > 0) ? existingProp2Ds.Keys.Max() + 1 : 1; //checking the existing model

            // Prop2Ds
            if (prop2Ds != null)
            {
                if (prop2Ds.Count != 0)
                {
                    // update counter if new prop2ds have set ID higher than existing max
                    int existingProp2dMaxID = prop2Ds.Max(x => x.ID); // max ID in new
                    if (existingProp2dMaxID > prop2didcounter)
                    {
                        prop2didcounter = existingProp2dMaxID + 1;
                    }

                    for (int i = 0; i < prop2Ds.Count; i++)
                    {
                        if (workerInstance != null)
                        {
                            if (workerInstance.CancellationToken.IsCancellationRequested)
                            {
                                return;
                            }
                            ReportProgress("Prop2D ", (double)i / (prop2Ds.Count - 1));
                        }

                        if (prop2Ds[i] != null)
                        {
                            GsaProp2d prop2d    = prop2Ds[i];
                            Prop2D    apiProp2d = prop2d.Prop2d;

                            if (prop2d_guid.ContainsKey(prop2d.GUID))
                            {
                                prop2d_guid.TryGetValue(prop2d.GUID, out int sID);
                                // if guid exist in our dictionary it has been added to the model
                                continue;
                            }

                            if (prop2d.ID > 0) // if the ID is larger than 0 than means the ID has been set and we sent it to the known list
                            {
                                existingProp2Ds[prop2d.ID] = apiProp2d;
                                // set guid in dictionary
                                prop2d_guid.Add(prop2d.GUID, prop2d.ID);
                            }
                            else
                            {
                                existingProp2Ds.Add(prop2didcounter, apiProp2d);
                                // set guid in dictionary
                                prop2d_guid.Add(prop2d.GUID, prop2didcounter);
                                prop2didcounter++;
                            }
                        }
                    }
                }
            }
            if (workerInstance != null)
            {
                ReportProgress("Prop2D assembled", -2);
            }
        }
Пример #9
0
        public static void ConvertSection(List <GsaSection> sections,
                                          ref Dictionary <int, Section> existingSections, ref Dictionary <Guid, int> sections_guid,
                                          GrasshopperAsyncComponent.WorkerInstance workerInstance = null,
                                          Action <string, double> ReportProgress = null)
        {
            // create a counter for creating new nodes
            int sectionidcounter = (existingSections.Count > 0) ? existingSections.Keys.Max() + 1 : 1; //checking the existing model

            // Add/Set Nodes
            if (sections != null)
            {
                if (sections.Count != 0)
                {
                    // update counter if new sections have set ID higher than existing max
                    int existingSectionsMaxID = sections.Max(x => x.ID); // max ID in new
                    if (existingSectionsMaxID > sectionidcounter)
                    {
                        sectionidcounter = existingSectionsMaxID + 1;
                    }

                    for (int i = 0; i < sections.Count; i++)
                    {
                        if (workerInstance != null)
                        {
                            if (workerInstance.CancellationToken.IsCancellationRequested)
                            {
                                return;
                            }
                            ReportProgress("Sections ", (double)i / (sections.Count - 1));
                        }


                        if (sections[i] != null)
                        {
                            GsaSection section    = sections[i];
                            Section    apiSection = section.Section;

                            if (sections_guid.ContainsKey(section.GUID))
                            {
                                sections_guid.TryGetValue(section.GUID, out int sID);
                                // if guid exist in our dictionary it has been added to the model
                                continue;
                            }

                            if (section.ID > 0) // if the ID is larger than 0 than means the ID has been set and we sent it to the known list
                            {
                                existingSections[section.ID] = apiSection;
                                // set guid in dictionary
                                sections_guid.Add(section.GUID, section.ID);
                            }
                            else
                            {
                                existingSections.Add(sectionidcounter, apiSection);
                                // set guid in dictionary
                                sections_guid.Add(section.GUID, sectionidcounter);
                                sectionidcounter++;
                            }
                        }
                    }
                }
            }
            if (workerInstance != null)
            {
                ReportProgress("Sections assembled", -2);
            }
        }
Пример #10
0
        /// <summary>
        /// Method to assemble full GSA model
        /// </summary>
        /// <param name="model">Existing models to be merged</param>
        /// <param name="nodes">List of nodes with properties like support conditions</param>
        /// <param name="elem1ds">List of 1D elements. Nodes at end-points will automatically be added to the model, using existing nodes in model within tolerance. Section will automatically be added to model</param>
        /// <param name="elem2ds">List of 2D elements. Nodes at mesh-verticies will automatically be added to the model, using existing nodes in model within tolerance. Prop2d will automatically be added to model</param>
        /// <param name="elem3ds">List of 3D elements. Nodes at mesh-verticies will automatically be added to the model, using existing nodes in model within tolerance</param>
        /// <param name="mem1ds">List of 1D members. Topology nodes will automatically be added to the model, using existing nodes in model within tolerance. Section will automatically be added to model</param>
        /// <param name="mem2ds">List of 2D members. Topology nodes will automatically be added to the model, using existing nodes in model within tolerance. Prop2d will automatically be added to model</param>
        /// <param name="mem3ds">List of 3D members. Topology nodes will automatically be added to the model, using existing nodes in model within tolerance</param>
        /// <param name="sections">List of Sections</param>
        /// <param name="prop2Ds">List of 2D Properties</param>
        /// <param name="loads">List of Loads. For Grid loads the Axis, GridPlane and GridSurface will automatically be added to the model using existing objects where possible within tolerance.</param>
        /// <param name="gridPlaneSurfaces">List of GridPlaneSurfaces</param>
        /// <param name="workerInstance">Optional input for AsyncComponents</param>
        /// <param name="ReportProgress">Optional input for AsyncComponents</param>
        /// <returns></returns>
        public static Model AssembleModel(GsaModel model, List <GsaNode> nodes,
                                          List <GsaElement1d> elem1ds, List <GsaElement2d> elem2ds, List <GsaElement3d> elem3ds,
                                          List <GsaMember1d> mem1ds, List <GsaMember2d> mem2ds, List <GsaMember3d> mem3ds,
                                          List <GsaSection> sections, List <GsaProp2d> prop2Ds,
                                          List <GsaLoad> loads, List <GsaGridPlaneSurface> gridPlaneSurfaces,
                                          GrasshopperAsyncComponent.WorkerInstance workerInstance = null,
                                          Action <string, double> ReportProgress = null
                                          )
        {
            // Set model to work on
            Model gsa = new Model();

            if (model != null)
            {
                gsa = model.Model;
            }

            #region Nodes
            // ### Nodes ###
            // We take out the existing nodes in the model and work on that dictionary

            // Get existing nodes
            IReadOnlyDictionary <int, Node> gsaNodes = gsa.Nodes();
            Dictionary <int, Node>          apinodes = gsaNodes.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

            // Get existing axes
            IReadOnlyDictionary <int, Axis> gsaAxes = gsa.Axes();
            Dictionary <int, Axis>          apiaxes = gsaAxes.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

            // Set / add nodes to dictionary
            Nodes.ConvertNode(nodes, ref apinodes, ref apiaxes, workerInstance, ReportProgress);
            #endregion

            #region Properties
            // ### Sections ###
            // list to keep track of duplicated sextions
            Dictionary <Guid, int> sections_guid = new Dictionary <Guid, int>();

            // Get existing sections
            IReadOnlyDictionary <int, Section> gsaSections = gsa.Sections();
            Dictionary <int, Section>          apisections = gsaSections.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
            // add / set sections
            Sections.ConvertSection(sections, ref apisections, ref sections_guid, workerInstance, ReportProgress);

            // ### Prop2ds ###
            // list to keep track of duplicated sextions
            Dictionary <Guid, int> prop2d_guid = new Dictionary <Guid, int>();
            // Get existing prop2ds
            IReadOnlyDictionary <int, Prop2D> gsaProp2ds = gsa.Prop2Ds();
            Dictionary <int, Prop2D>          apiprop2ds = gsaProp2ds.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
            // add / set prop2ds
            Prop2ds.ConvertProp2d(prop2Ds, ref apiprop2ds, ref prop2d_guid, workerInstance, ReportProgress);
            #endregion

            #region Elements
            // ### Elements ###
            // We take out the existing elements in the model and work on that dictionary

            // Get existing elements
            IReadOnlyDictionary <int, Element> gsaElems = gsa.Elements();
            Dictionary <int, Element>          elems    = gsaElems.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

            // create a counter for creating new elements
            int newElementID = (elems.Count > 0) ? elems.Keys.Max() + 1 : 1; //checking the existing model

            // as both elem1d and elem2d will be set in the same table, we check the highest ID that may have
            // been set in the incoming elements and start appending from there to avoid accidentially overwriting
            if (elem1ds != null)
            {
                if (elem1ds.Count > 0)
                {
                    int existingElem1dMaxID = elem1ds.Max(x => x.ID); // max ID in new Elem1ds
                    if (existingElem1dMaxID > newElementID)
                    {
                        newElementID = existingElem1dMaxID + 1;
                    }
                }
            }
            if (elem2ds != null)
            {
                if (elem2ds.Count > 0)
                {
                    int existingElem2dMaxID = elem2ds.Max(x => x.ID.Max()); // max ID in new Elem2ds
                    if (existingElem2dMaxID > newElementID)
                    {
                        newElementID = existingElem2dMaxID + 1;
                    }
                }
            }

            // Set / add 1D elements to dictionary
            Elements.ConvertElement1D(elem1ds, ref elems, ref newElementID, ref apinodes, ref apisections, ref sections_guid, workerInstance, ReportProgress);

            // Set / add 2D elements to dictionary
            Elements.ConvertElement2D(elem2ds, ref elems, ref newElementID, ref apinodes, ref apiprop2ds, ref prop2d_guid, workerInstance, ReportProgress);

            // Set / add 3D elements to dictionary
            Elements.ConvertElement3D(elem3ds, ref elems, ref newElementID, ref apinodes, workerInstance, ReportProgress);
            #endregion

            #region Members
            // ### Members ###
            // We take out the existing members in the model and work on that dictionary

            // Get existing members
            IReadOnlyDictionary <int, Member> gsaMems = gsa.Members();
            Dictionary <int, Member>          mems    = gsaMems.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

            // create a counter for creating new members
            int newMemberID = (mems.Count > 0) ? mems.Keys.Max() + 1 : 1; //checking the existing model

            // as both mem1d, mem2d and mem3dwill be set in the same table, we check the highest ID that may have
            // been set in the incoming elements and start appending from there to avoid accidentially overwriting
            if (mem1ds != null)
            {
                if (mem1ds.Count > 0)
                {
                    int existingMem1dMaxID = mem1ds.Max(x => x.ID); // max ID in new Elem1ds
                    if (existingMem1dMaxID > newMemberID)
                    {
                        newMemberID = existingMem1dMaxID + 1;
                    }
                }
            }

            if (mem2ds != null)
            {
                if (mem2ds.Count > 0)
                {
                    int existingMem2dMaxID = mem2ds.Max(x => x.ID); // max ID in new Elem2ds
                    if (existingMem2dMaxID > newMemberID)
                    {
                        newMemberID = existingMem2dMaxID + 1;
                    }
                }
            }

            if (mem3ds != null)
            {
                if (mem3ds.Count > 0)
                {
                    int existingMem3dMaxID = mem3ds.Max(x => x.ID); // max ID in new Elem2ds
                    if (existingMem3dMaxID > newMemberID)
                    {
                        newMemberID = existingMem3dMaxID + 1;
                    }
                }
            }

            // Set / add 1D members to dictionary
            Members.ConvertMember1D(mem1ds, ref mems, ref newMemberID, ref apinodes, ref apisections, ref sections_guid, workerInstance, ReportProgress);

            // Set / add 2D members to dictionary
            Members.ConvertMember2D(mem2ds, ref mems, ref newMemberID, ref apinodes, ref apiprop2ds, ref prop2d_guid, workerInstance, ReportProgress);

            // Set / add 3D members to dictionary
            Members.ConvertMember3D(mem3ds, ref mems, ref newMemberID, ref apinodes, workerInstance, ReportProgress);
            #endregion

            #region Loads
            // ### Loads ###
            // We let the existing loads (if any) survive and just add new loads

            // Get existing loads
            List <GravityLoad>   gravityLoads     = new List <GravityLoad>();
            List <NodeLoad>      nodeLoads_node   = new List <NodeLoad>();
            List <NodeLoad>      nodeLoads_displ  = new List <NodeLoad>();
            List <NodeLoad>      nodeLoads_settle = new List <NodeLoad>();
            List <BeamLoad>      beamLoads        = new List <BeamLoad>();
            List <FaceLoad>      faceLoads        = new List <FaceLoad>();
            List <GridPointLoad> gridPointLoads   = new List <GridPointLoad>();
            List <GridLineLoad>  gridLineLoads    = new List <GridLineLoad>();
            List <GridAreaLoad>  gridAreaLoads    = new List <GridAreaLoad>();

            IReadOnlyDictionary <int, GridPlane> gsaGPln       = gsa.GridPlanes();
            Dictionary <int, GridPlane>          apiGridPlanes = gsaGPln.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

            IReadOnlyDictionary <int, GridSurface> gsaGSrf         = gsa.GridSurfaces();
            Dictionary <int, GridSurface>          apiGridSurfaces = gsaGSrf.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

            // lists to keep track of duplicated grid planes and grid surfaces
            Dictionary <Guid, int> gp_guid = new Dictionary <Guid, int>();
            Dictionary <Guid, int> gs_guid = new Dictionary <Guid, int>();

            // Set / add Grid plane surfaces - do this first to set any GridPlane and GridSurfaces with IDs.
            Loads.ConvertGridPlaneSurface(gridPlaneSurfaces, ref apiaxes, ref apiGridPlanes, ref apiGridSurfaces,
                                          ref gp_guid, ref gs_guid, workerInstance, ReportProgress);

            // Set / add loads to lists
            Loads.ConvertLoad(loads, ref gravityLoads, ref nodeLoads_node, ref nodeLoads_displ, ref nodeLoads_settle,
                              ref beamLoads, ref faceLoads, ref gridPointLoads, ref gridLineLoads, ref gridAreaLoads,
                              ref apiaxes, ref apiGridPlanes, ref apiGridSurfaces, ref gp_guid, ref gs_guid,
                              workerInstance, ReportProgress);
            #endregion



            #region set stuff in model
            if (workerInstance != null)
            {
                if (workerInstance.CancellationToken.IsCancellationRequested)
                {
                    return(null);
                }
            }
            //nodes
            ReadOnlyDictionary <int, Node> setnodes = new ReadOnlyDictionary <int, Node>(apinodes);
            gsa.SetNodes(setnodes);
            //elements
            ReadOnlyDictionary <int, Element> setelem = new ReadOnlyDictionary <int, Element>(elems);
            gsa.SetElements(setelem);
            //members
            ReadOnlyDictionary <int, Member> setmem = new ReadOnlyDictionary <int, Member>(mems);
            gsa.SetMembers(setmem);
            //gravity load
            ReadOnlyCollection <GravityLoad> setgrav = new ReadOnlyCollection <GravityLoad>(gravityLoads);
            gsa.AddGravityLoads(setgrav);
            //node loads
            ReadOnlyCollection <NodeLoad> setnode_disp = new ReadOnlyCollection <NodeLoad>(nodeLoads_displ);
            gsa.AddNodeLoads(NodeLoadType.APPL_DISP, setnode_disp);
            ReadOnlyCollection <NodeLoad> setnode_node = new ReadOnlyCollection <NodeLoad>(nodeLoads_node);
            gsa.AddNodeLoads(NodeLoadType.NODE_LOAD, setnode_node);
            ReadOnlyCollection <NodeLoad> setnode_setl = new ReadOnlyCollection <NodeLoad>(nodeLoads_settle);
            gsa.AddNodeLoads(NodeLoadType.SETTLEMENT, setnode_setl);
            //beam loads
            ReadOnlyCollection <BeamLoad> setbeam = new ReadOnlyCollection <BeamLoad>(beamLoads);
            gsa.AddBeamLoads(setbeam);
            //face loads
            ReadOnlyCollection <FaceLoad> setface = new ReadOnlyCollection <FaceLoad>(faceLoads);
            gsa.AddFaceLoads(setface);
            //grid point loads
            ReadOnlyCollection <GridPointLoad> setpoint = new ReadOnlyCollection <GridPointLoad>(gridPointLoads);
            gsa.AddGridPointLoads(setpoint);
            //grid line loads
            ReadOnlyCollection <GridLineLoad> setline = new ReadOnlyCollection <GridLineLoad>(gridLineLoads);
            gsa.AddGridLineLoads(setline);
            //grid area loads
            ReadOnlyCollection <GridAreaLoad> setarea = new ReadOnlyCollection <GridAreaLoad>(gridAreaLoads);
            gsa.AddGridAreaLoads(setarea);
            //axes
            ReadOnlyDictionary <int, Axis> setax = new ReadOnlyDictionary <int, Axis>(apiaxes);
            gsa.SetAxes(setax);
            //gridplanes
            ReadOnlyDictionary <int, GridPlane> setgp = new ReadOnlyDictionary <int, GridPlane>(apiGridPlanes);
            gsa.SetGridPlanes(setgp);
            //gridsurfaces
            ReadOnlyDictionary <int, GridSurface> setgs = new ReadOnlyDictionary <int, GridSurface>(apiGridSurfaces);
            gsa.SetGridSurfaces(setgs);
            //sections
            ReadOnlyDictionary <int, Section> setsect = new ReadOnlyDictionary <int, Section>(apisections);
            gsa.SetSections(setsect);
            //prop2ds
            ReadOnlyDictionary <int, Prop2D> setpr2d = new ReadOnlyDictionary <int, Prop2D>(apiprop2ds);
            gsa.SetProp2Ds(setpr2d);


            if (workerInstance != null)
            {
                ReportProgress("Model assembled", -2);
            }
            #endregion

            return(gsa);
        }