示例#1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaMember1d gsaMember1d = new GsaMember1d();

            if (DA.GetData(0, ref gsaMember1d))
            {
                if (gsaMember1d == null)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Member1D input is null");
                }
                GsaMember1d mem = gsaMember1d.Duplicate();

                // #### inputs ####
                // 1 ID
                GH_Integer ghID = new GH_Integer();
                if (DA.GetData(1, ref ghID))
                {
                    if (GH_Convert.ToInt32(ghID, out int id, GH_Conversion.Both))
                    {
                        mem.ID = id;
                    }
                }

                // 2 curve
                GH_Curve ghcrv = new GH_Curve();
                if (DA.GetData(2, ref ghcrv))
                {
                    Curve crv = null;
                    if (GH_Convert.ToCurve(ghcrv, ref crv, GH_Conversion.Both))
                    {
                        GsaMember1d tempmem = new GsaMember1d(crv);
                        mem.PolyCurve    = tempmem.PolyCurve;
                        mem.Topology     = tempmem.Topology;
                        mem.TopologyType = tempmem.TopologyType;
                    }
                }

                // 3 section
                GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();
                if (DA.GetData(3, ref gh_typ))
                {
                    GsaSection section = new GsaSection();
                    if (gh_typ.Value is GsaSectionGoo)
                    {
                        gh_typ.CastTo(ref section);
                        mem.Section         = section;
                        mem.Member.Property = 0;
                    }
                    else
                    {
                        if (GH_Convert.ToInt32(gh_typ.Value, out int idd, GH_Conversion.Both))
                        {
                            mem.Member.Property = idd;
                            mem.Section         = null;
                        }
                        else
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert PB input to a Section Property of reference integer");
                            return;
                        }
                    }
                }
        public void TestDuplicateMem1d()
        {
            // create a list of control points
            List <Point3d> pts = new List <Point3d>();

            pts.Add(new Point3d(0, 0, 0));
            pts.Add(new Point3d(0, 10, 0));

            // create nurbscurve from pts
            NurbsCurve crv = NurbsCurve.Create(false, 1, pts);

            // create 1d member from crv
            GsaMember1d orig = new GsaMember1d(crv);

            // set some members
            orig.Colour           = System.Drawing.Color.Green;
            orig.ID               = 2;
            orig.Member.Name      = "Sally";
            orig.Member.IsDummy   = false;
            orig.Member.Offset.X2 = 0.1;
            orig.Member.Property  = 3;
            orig.Section          = new GsaSection();
            orig.Section.ID       = 4;
            orig.Member.Group     = 99;
            orig.Member.Type1D    = ElementType.BAR;
            orig.Member.Type      = MemberType.COLUMN;

            // duplicate member
            GsaMember1d dup = orig.Duplicate();

            // check that member is duplicated
            Assert.AreEqual(System.Drawing.Color.FromArgb(255, 0, 128, 0), dup.Member.Colour);
            Assert.AreEqual(2, dup.ID);
            Assert.AreEqual("Sally", dup.Member.Name);
            Assert.IsFalse(dup.Member.IsDummy);
            Assert.AreEqual(0.1, dup.Member.Offset.X2);
            Assert.AreEqual(3, dup.Member.Property);
            Assert.AreEqual(4, dup.Section.ID);
            Assert.AreEqual(99, dup.Member.Group);
            Assert.AreEqual(ElementType.BAR, dup.Member.Type1D);
            Assert.AreEqual(MemberType.COLUMN, dup.Member.Type);

            // make changes to original
            orig.Colour           = System.Drawing.Color.White;
            orig.ID               = 1;
            orig.Member.Name      = "Peter Peterson";
            orig.Member.IsDummy   = true;
            orig.Member.Offset.X2 = 0.4;
            orig.Member.Property  = 2;
            orig.Section.ID       = 1;
            orig.Member.Group     = 4;
            orig.Member.Type1D    = ElementType.BEAM;
            orig.Member.Type      = MemberType.BEAM;

            // check that duplicate keeps its values
            Assert.AreEqual(System.Drawing.Color.FromArgb(255, 0, 128, 0), dup.Member.Colour);
            Assert.AreEqual(2, dup.ID);
            Assert.AreEqual("Sally", dup.Member.Name);
            Assert.IsFalse(dup.Member.IsDummy);
            Assert.AreEqual(0.1, dup.Member.Offset.X2);
            Assert.AreEqual(3, dup.Member.Property);
            Assert.AreEqual(4, dup.Section.ID);
            Assert.AreEqual(99, dup.Member.Group);
            Assert.AreEqual(ElementType.BAR, dup.Member.Type1D);
            Assert.AreEqual(MemberType.COLUMN, dup.Member.Type);

            // check that original is changed
            Assert.AreEqual(System.Drawing.Color.FromArgb(255, 255, 255, 255), orig.Member.Colour);
            Assert.AreEqual(1, orig.ID);
            Assert.AreEqual("Peter Peterson", orig.Member.Name);
            Assert.IsTrue(orig.Member.IsDummy);
            Assert.AreEqual(0.4, orig.Member.Offset.X2);
            Assert.AreEqual(2, orig.Member.Property);
            Assert.AreEqual(1, orig.Section.ID);
            Assert.AreEqual(4, orig.Member.Group);
            Assert.AreEqual(ElementType.BEAM, orig.Member.Type1D);
            Assert.AreEqual(MemberType.BEAM, orig.Member.Type);
        }
示例#3
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            #region GetData
            Models            = null;
            Nodes             = null;
            Elem1ds           = null;
            Elem2ds           = null;
            Elem3ds           = null;
            Mem1ds            = null;
            Mem2ds            = null;
            Mem3ds            = null;
            Loads             = null;
            Sections          = null;
            Prop2Ds           = null;
            GridPlaneSurfaces = null;

            // Get Model input
            List <GH_ObjectWrapper> gh_types = new List <GH_ObjectWrapper>();
            if (DA.GetDataList(0, gh_types))
            {
                List <GsaModel> in_models = new List <GsaModel>();
                for (int i = 0; i < gh_types.Count; i++)
                {
                    GH_ObjectWrapper gh_typ = gh_types[i];
                    if (gh_typ == null)
                    {
                        Params.Owner.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Input is null"); return;
                    }
                    if (gh_typ.Value is GsaModelGoo)
                    {
                        GsaModel in_model = new GsaModel();
                        gh_typ.CastTo(ref in_model);
                        in_models.Add(in_model);
                    }
                    else
                    {
                        string type = gh_typ.Value.GetType().ToString();
                        type = type.Replace("GhSA.Parameters.", "");
                        type = type.Replace("Goo", "");
                        Params.Owner.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert GSA input parameter of type " +
                                                       type + " to GsaModel");
                        return;
                    }
                }
                Models = in_models;
            }

            // Get Section Property input
            gh_types = new List <GH_ObjectWrapper>();
            if (DA.GetDataList(1, gh_types))
            {
                List <GsaSection> in_sect = new List <GsaSection>();
                List <GsaProp2d>  in_prop = new List <GsaProp2d>();
                for (int i = 0; i < gh_types.Count; i++)
                {
                    GH_ObjectWrapper gh_typ = gh_types[i];
                    if (gh_typ.Value is GsaSectionGoo)
                    {
                        GsaSection gsasection = new GsaSection();
                        gh_typ.CastTo(ref gsasection);
                        in_sect.Add(gsasection.Duplicate());
                    }
                    else if (gh_typ.Value is GsaProp2dGoo)
                    {
                        GsaProp2d gsaprop = new GsaProp2d();
                        gh_typ.CastTo(ref gsaprop);
                        in_prop.Add(gsaprop.Duplicate());
                    }
                    else
                    {
                        string type = gh_typ.Value.GetType().ToString();
                        type = type.Replace("GhSA.Parameters.", "");
                        type = type.Replace("Goo", "");
                        Params.Owner.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert Prop input parameter of type " +
                                                       type + " to GsaSection or GsaProp2d");
                        return;
                    }
                }
                if (in_sect.Count > 0)
                {
                    Sections = in_sect;
                }
                if (in_prop.Count > 0)
                {
                    Prop2Ds = in_prop;
                }
            }

            // Get Geometry input
            gh_types = new List <GH_ObjectWrapper>();
            List <GsaNode>      in_nodes   = new List <GsaNode>();
            List <GsaElement1d> in_elem1ds = new List <GsaElement1d>();
            List <GsaElement2d> in_elem2ds = new List <GsaElement2d>();
            List <GsaElement3d> in_elem3ds = new List <GsaElement3d>();
            List <GsaMember1d>  in_mem1ds  = new List <GsaMember1d>();
            List <GsaMember2d>  in_mem2ds  = new List <GsaMember2d>();
            List <GsaMember3d>  in_mem3ds  = new List <GsaMember3d>();
            if (DA.GetDataList(2, gh_types))
            {
                for (int i = 0; i < gh_types.Count; i++)
                {
                    GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();
                    gh_typ = gh_types[i];
                    if (gh_typ.Value is GsaNodeGoo)
                    {
                        GsaNode gsanode = new GsaNode();
                        gh_typ.CastTo(ref gsanode);
                        in_nodes.Add(gsanode.Duplicate());
                    }
                    else if (gh_typ.Value is GsaElement1dGoo)
                    {
                        GsaElement1d gsaelem1 = new GsaElement1d();
                        gh_typ.CastTo(ref gsaelem1);
                        in_elem1ds.Add(gsaelem1.Duplicate());
                    }
                    else if (gh_typ.Value is GsaElement2dGoo)
                    {
                        GsaElement2d gsaelem2 = new GsaElement2d();
                        gh_typ.CastTo(ref gsaelem2);
                        in_elem2ds.Add(gsaelem2.Duplicate());
                    }
                    else if (gh_typ.Value is GsaElement3dGoo)
                    {
                        GsaElement3d gsaelem3 = new GsaElement3d();
                        gh_typ.CastTo(ref gsaelem3);
                        in_elem3ds.Add(gsaelem3.Duplicate());
                    }
                    else if (gh_typ.Value is GsaMember1dGoo)
                    {
                        GsaMember1d gsamem1 = new GsaMember1d();
                        gh_typ.CastTo(ref gsamem1);
                        in_mem1ds.Add(gsamem1.Duplicate());
                    }
                    else if (gh_typ.Value is GsaMember2dGoo)
                    {
                        GsaMember2d gsamem2 = new GsaMember2d();
                        gh_typ.CastTo(ref gsamem2);
                        in_mem2ds.Add(gsamem2.Duplicate());
                    }
                    else if (gh_typ.Value is GsaMember3dGoo)
                    {
                        GsaMember3d gsamem3 = new GsaMember3d();
                        gh_typ.CastTo(ref gsamem3);
                        in_mem3ds.Add(gsamem3.Duplicate());
                    }
                    else
                    {
                        string type = gh_typ.Value.GetType().ToString();
                        type = type.Replace("GhSA.Parameters.", "");
                        type = type.Replace("Goo", "");
                        Params.Owner.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert Geometry input parameter of type " +
                                                       type + System.Environment.NewLine + " to Node, Element1D, Element2D, Element3D, Member1D, Member2D or Member3D");
                        return;
                    }
                }
                if (in_nodes.Count > 0)
                {
                    Nodes = in_nodes;
                }
                if (in_elem1ds.Count > 0)
                {
                    Elem1ds = in_elem1ds;
                }
                if (in_elem2ds.Count > 0)
                {
                    Elem2ds = in_elem2ds;
                }
                if (in_elem3ds.Count > 0)
                {
                    Elem3ds = in_elem3ds;
                }
                if (in_mem1ds.Count > 0)
                {
                    Mem1ds = in_mem1ds;
                }
                if (in_mem2ds.Count > 0)
                {
                    Mem2ds = in_mem2ds;
                }
                if (in_mem3ds.Count > 0)
                {
                    Mem3ds = in_mem3ds;
                }
            }


            // Get Loads input
            gh_types = new List <GH_ObjectWrapper>();
            if (DA.GetDataList(3, gh_types))
            {
                List <GsaLoad>             in_loads = new List <GsaLoad>();
                List <GsaGridPlaneSurface> in_gps   = new List <GsaGridPlaneSurface>();
                for (int i = 0; i < gh_types.Count; i++)
                {
                    GH_ObjectWrapper gh_typ = gh_types[i];
                    if (gh_typ.Value is GsaLoadGoo)
                    {
                        GsaLoad gsaload = null;
                        gh_typ.CastTo(ref gsaload);
                        in_loads.Add(gsaload.Duplicate());
                    }
                    else if (gh_typ.Value is GsaGridPlaneSurfaceGoo)
                    {
                        GsaGridPlaneSurface gsaGPS = new GsaGridPlaneSurface();
                        gh_typ.CastTo(ref gsaGPS);
                        in_gps.Add(gsaGPS.Duplicate());
                    }
                    else
                    {
                        string type = gh_typ.Value.GetType().ToString();
                        type = type.Replace("GhSA.Parameters.", "");
                        type = type.Replace("Goo", "");
                        Params.Owner.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert Load input parameter of type " +
                                                       type + " to Load or GridPlaneSurface");
                        return;
                    }
                }
                if (in_loads.Count > 0)
                {
                    Loads = in_loads;
                }
                if (in_gps.Count > 0)
                {
                    GridPlaneSurfaces = in_gps;
                }
            }
            // manually add a warning if no input is set, as all inputs are optional
            if (Models == null & Nodes == null & Elem1ds == null & Elem2ds == null &
                Mem1ds == null & Mem2ds == null & Mem3ds == null & Sections == null
                & Prop2Ds == null & Loads == null & GridPlaneSurfaces == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Input parameters failed to collect data");
                return;
            }

            #endregion

            #region DoWork
            GsaModel analysisModel = null;
            if (Models != null)
            {
                if (Models.Count > 0)
                {
                    if (Models.Count > 1)
                    {
                        analysisModel = Util.Gsa.ToGSA.Models.MergeModel(Models);
                    }
                    else
                    {
                        analysisModel = Models[0].Clone();
                    }
                }
            }
            if (analysisModel != null)
            {
                OutModel = analysisModel;
            }
            else
            {
                OutModel = new GsaModel();
            }

            // Assemble model
            Model gsa = Util.Gsa.ToGSA.Assemble.AssembleModel(analysisModel, Nodes, Elem1ds, Elem2ds, Elem3ds, Mem1ds, Mem2ds, Mem3ds, Sections, Prop2Ds, Loads, GridPlaneSurfaces);
            //gsa.SaveAs(@"C:\Users\Kristjan.Nielsen\Desktop\test3.gwb");
            #region meshing
            // Create elements from members
            gsa.CreateElementsFromMembers();
            #endregion

            #region analysis

            //analysis
            IReadOnlyDictionary <int, AnalysisTask> gsaTasks = gsa.AnalysisTasks();
            if (gsaTasks.Count < 1)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Model contains no Analysis Tasks");
            }

            foreach (KeyValuePair <int, AnalysisTask> task in gsaTasks)
            {
                if (!(gsa.Analyse(task.Key)))
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Warning Analysis Case " + task.Key + " could not be analysed");
                }
            }

            #endregion
            OutModel.Model = gsa;

            //gsa.SaveAs("C:\\Users\\Kristjan.Nielsen\\Desktop\\GsaGH_test.gwb");
            #endregion

            #region SetData
            DA.SetData(0, new GsaModelGoo(OutModel));
            #endregion
        }
            public override void GetData(IGH_DataAccess DA, GH_ComponentParamServer Params)
            {
                #region GetData
                Models            = null;
                Nodes             = null;
                Elem1ds           = null;
                Elem2ds           = null;
                Elem3ds           = null;
                Mem1ds            = null;
                Mem2ds            = null;
                Mem3ds            = null;
                Loads             = null;
                Sections          = null;
                Prop2Ds           = null;
                GridPlaneSurfaces = null;
                OutModel          = null;
                component         = Params.Owner;

                // Get Model input
                List <GH_ObjectWrapper> gh_types = new List <GH_ObjectWrapper>();
                if (DA.GetDataList(0, gh_types))
                {
                    List <GsaModel> in_models = new List <GsaModel>();
                    for (int i = 0; i < gh_types.Count; i++)
                    {
                        if (gh_types[i] == null)
                        {
                            return;
                        }
                        GH_ObjectWrapper gh_typ = gh_types[i];
                        if (gh_typ.Value is GsaModelGoo)
                        {
                            GsaModel in_model = new GsaModel();
                            gh_typ.CastTo(ref in_model);
                            in_models.Add(in_model);
                        }
                        else
                        {
                            string type = gh_typ.Value.GetType().ToString();
                            type = type.Replace("GhSA.Parameters.", "");
                            type = type.Replace("Goo", "");
                            Params.Owner.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert GSA input parameter of type " +
                                                           type + " to GsaModel");
                            return;
                        }
                    }
                    Models = in_models;
                }

                // Get Section Property input
                gh_types = new List <GH_ObjectWrapper>();
                if (DA.GetDataList(1, gh_types))
                {
                    List <GsaSection> in_sect = new List <GsaSection>();
                    List <GsaProp2d>  in_prop = new List <GsaProp2d>();
                    for (int i = 0; i < gh_types.Count; i++)
                    {
                        if (gh_types[i] == null)
                        {
                            return;
                        }
                        GH_ObjectWrapper gh_typ = gh_types[i];
                        if (gh_typ.Value is GsaSectionGoo)
                        {
                            GsaSection gsasection = new GsaSection();
                            gh_typ.CastTo(ref gsasection);
                            in_sect.Add(gsasection.Duplicate());
                        }
                        else if (gh_typ.Value is GsaProp2dGoo)
                        {
                            GsaProp2d gsaprop = new GsaProp2d();
                            gh_typ.CastTo(ref gsaprop);
                            in_prop.Add(gsaprop.Duplicate());
                        }
                        else
                        {
                            string type = gh_typ.Value.GetType().ToString();
                            type = type.Replace("GhSA.Parameters.", "");
                            type = type.Replace("Goo", "");
                            Params.Owner.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert Prop input parameter of type " +
                                                           type + " to GsaSection or GsaProp2d");
                            return;
                        }
                    }
                    if (in_sect.Count > 0)
                    {
                        Sections = in_sect;
                    }
                    if (in_prop.Count > 0)
                    {
                        Prop2Ds = in_prop;
                    }
                }

                // Get Geometry input
                gh_types = new List <GH_ObjectWrapper>();
                List <GsaNode>      in_nodes   = new List <GsaNode>();
                List <GsaElement1d> in_elem1ds = new List <GsaElement1d>();
                List <GsaElement2d> in_elem2ds = new List <GsaElement2d>();
                List <GsaElement3d> in_elem3ds = new List <GsaElement3d>();
                List <GsaMember1d>  in_mem1ds  = new List <GsaMember1d>();
                List <GsaMember2d>  in_mem2ds  = new List <GsaMember2d>();
                List <GsaMember3d>  in_mem3ds  = new List <GsaMember3d>();
                if (DA.GetDataList(2, gh_types))
                {
                    for (int i = 0; i < gh_types.Count; i++)
                    {
                        if (gh_types[i] == null)
                        {
                            return;
                        }
                        GH_ObjectWrapper gh_typ = gh_types[i];
                        if (gh_typ.Value is GsaNodeGoo)
                        {
                            GsaNode gsanode = new GsaNode();
                            gh_typ.CastTo(ref gsanode);
                            in_nodes.Add(gsanode.Duplicate());
                        }
                        else if (gh_typ.Value is GsaElement1dGoo)
                        {
                            GsaElement1d gsaelem1 = new GsaElement1d();
                            gh_typ.CastTo(ref gsaelem1);
                            in_elem1ds.Add(gsaelem1.Duplicate());
                        }
                        else if (gh_typ.Value is GsaElement2dGoo)
                        {
                            GsaElement2d gsaelem2 = new GsaElement2d();
                            gh_typ.CastTo(ref gsaelem2);
                            in_elem2ds.Add(gsaelem2.Duplicate());
                        }
                        else if (gh_typ.Value is GsaElement3dGoo)
                        {
                            GsaElement3d gsaelem3 = new GsaElement3d();
                            gh_typ.CastTo(ref gsaelem3);
                            in_elem3ds.Add(gsaelem3.Duplicate());
                        }
                        else if (gh_typ.Value is GsaMember1dGoo)
                        {
                            GsaMember1d gsamem1 = new GsaMember1d();
                            gh_typ.CastTo(ref gsamem1);
                            in_mem1ds.Add(gsamem1.Duplicate());
                        }
                        else if (gh_typ.Value is GsaMember2dGoo)
                        {
                            GsaMember2d gsamem2 = new GsaMember2d();
                            gh_typ.CastTo(ref gsamem2);
                            in_mem2ds.Add(gsamem2.Duplicate());
                        }
                        else if (gh_typ.Value is GsaMember3dGoo)
                        {
                            GsaMember3d gsamem3 = new GsaMember3d();
                            gh_typ.CastTo(ref gsamem3);
                            in_mem3ds.Add(gsamem3.Duplicate());
                        }
                        else
                        {
                            string type = gh_typ.Value.GetType().ToString();
                            type = type.Replace("GhSA.Parameters.", "");
                            type = type.Replace("Goo", "");
                            Params.Owner.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert Geometry input parameter of type " +
                                                           type + System.Environment.NewLine + " to Node, Element1D, Element2D, Element3D, Member1D, Member2D or Member3D");
                            return;
                        }
                    }
                    if (in_nodes.Count > 0)
                    {
                        Nodes = in_nodes;
                    }
                    if (in_elem1ds.Count > 0)
                    {
                        Elem1ds = in_elem1ds;
                    }
                    if (in_elem2ds.Count > 0)
                    {
                        Elem2ds = in_elem2ds;
                    }
                    if (in_elem3ds.Count > 0)
                    {
                        Elem3ds = in_elem3ds;
                    }
                    if (in_mem1ds.Count > 0)
                    {
                        Mem1ds = in_mem1ds;
                    }
                    if (in_mem2ds.Count > 0)
                    {
                        Mem2ds = in_mem2ds;
                    }
                    if (in_mem3ds.Count > 0)
                    {
                        Mem3ds = in_mem3ds;
                    }
                }


                // Get Loads input
                gh_types = new List <GH_ObjectWrapper>();
                if (DA.GetDataList(3, gh_types))
                {
                    List <GsaLoad>             in_loads = new List <GsaLoad>();
                    List <GsaGridPlaneSurface> in_gps   = new List <GsaGridPlaneSurface>();
                    for (int i = 0; i < gh_types.Count; i++)
                    {
                        if (gh_types[i] == null)
                        {
                            return;
                        }
                        GH_ObjectWrapper gh_typ = gh_types[i];
                        if (gh_typ.Value is GsaLoadGoo)
                        {
                            GsaLoad gsaload = null;
                            gh_typ.CastTo(ref gsaload);
                            in_loads.Add(gsaload.Duplicate());
                        }
                        else if (gh_typ.Value is GsaGridPlaneSurfaceGoo)
                        {
                            GsaGridPlaneSurface gsaGPS = new GsaGridPlaneSurface();
                            gh_typ.CastTo(ref gsaGPS);
                            in_gps.Add(gsaGPS.Duplicate());
                        }
                        else
                        {
                            string type = gh_typ.Value.GetType().ToString();
                            type = type.Replace("GhSA.Parameters.", "");
                            type = type.Replace("Goo", "");
                            Params.Owner.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert Load input parameter of type " +
                                                           type + " to Load or GridPlaneSurface");
                            return;
                        }
                    }
                    if (in_loads.Count > 0)
                    {
                        Loads = in_loads;
                    }
                    if (in_gps.Count > 0)
                    {
                        GridPlaneSurfaces = in_gps;
                    }
                }

                #endregion

                // manually add a warning if no input is set, as all inputs are optional
                if (Models == null & Nodes == null & Elem1ds == null & Elem2ds == null &
                    Mem1ds == null & Mem2ds == null & Mem3ds == null & Sections == null
                    & Prop2Ds == null & Loads == null & GridPlaneSurfaces == null)
                {
                    hasInput = false;
                    Params.Owner.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Input parameters failed to collect data");
                    return;
                }
                else
                {
                    hasInput = true;
                }
            }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaMember1d gsaMember1d = new GsaMember1d();

            if (DA.GetData(0, ref gsaMember1d))
            {
                GsaMember1d mem = gsaMember1d.Duplicate();

                // #### inputs ####

                // 1 curve
                GH_Curve ghcrv = new GH_Curve();
                if (DA.GetData(1, ref ghcrv))
                {
                    Curve crv = null;
                    if (GH_Convert.ToCurve(ghcrv, ref crv, GH_Conversion.Both))
                    {
                        GsaMember1d tmpmem = new GsaMember1d(crv)
                        {
                            ID           = mem.ID,
                            Member       = mem.Member,
                            ReleaseEnd   = mem.ReleaseEnd,
                            ReleaseStart = mem.ReleaseStart
                        };
                        mem = tmpmem;
                    }
                }

                // 2 section
                GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();
                if (DA.GetData(2, ref gh_typ))
                {
                    GsaSection section = new GsaSection();
                    if (gh_typ.Value is GsaSection)
                    {
                        gh_typ.CastTo(ref section);
                    }
                    else if (gh_typ.Value is GH_Number)
                    {
                        if (GH_Convert.ToInt32((GH_Number)gh_typ.Value, out int idd, GH_Conversion.Both))
                        {
                            section.ID = idd;
                        }
                    }
                    mem.Section = section;
                }


                // 3 type
                GH_Integer ghint = new GH_Integer();
                if (DA.GetData(4, ref ghint))
                {
                    if (GH_Convert.ToInt32(ghint, out int type, GH_Conversion.Both))
                    {
                        mem.Member.Type = Util.Gsa.GsaToModel.Member1dType(type);
                    }
                }

                // 4 element type
                GH_Integer ghinteg = new GH_Integer();
                if (DA.GetData(4, ref ghinteg))
                {
                    if (GH_Convert.ToInt32(ghinteg, out int type, GH_Conversion.Both))
                    {
                        mem.Member.Type1D = Util.Gsa.GsaToModel.Element1dType(type);
                    }
                }

                // 5 offset
                GsaOffset offset = new GsaOffset();
                if (DA.GetData(5, ref offset))
                {
                    mem.Member.Offset.X1 = offset.X1;
                    mem.Member.Offset.X2 = offset.X2;
                    mem.Member.Offset.Y  = offset.Y;
                    mem.Member.Offset.Z  = offset.Z;
                }

                // 6 start release
                GsaBool6 start = new GsaBool6();
                if (DA.GetData(6, ref start))
                {
                    mem.ReleaseStart = start;
                }

                // 7 end release
                GsaBool6 end = new GsaBool6();
                if (DA.GetData(7, ref end))
                {
                    mem.ReleaseEnd = end;
                }

                // 8 orientation angle
                GH_Number ghangle = new GH_Number();
                if (DA.GetData(8, ref ghangle))
                {
                    if (GH_Convert.ToDouble(ghangle, out double angle, GH_Conversion.Both))
                    {
                        mem.Member.OrientationAngle = angle;
                    }
                }

                // 9 orientation node
                GH_Integer ghori = new GH_Integer();
                if (DA.GetData(9, ref ghori))
                {
                    if (GH_Convert.ToInt32(ghori, out int orient, GH_Conversion.Both))
                    {
                        mem.Member.OrientationNode = orient;
                    }
                }

                // 10 mesh size
                GH_Number ghmsz = new GH_Number();
                if (DA.GetData(10, ref ghmsz))
                {
                    if (GH_Convert.ToDouble(ghmsz, out double msz, GH_Conversion.Both))
                    {
                        mem.Member.MeshSize = msz;
                    }
                }

                // 11 mesh with others
                GH_Boolean ghbool = new GH_Boolean();
                if (DA.GetData(11, ref ghbool))
                {
                    if (GH_Convert.ToBoolean(ghbool, out bool mbool, GH_Conversion.Both))
                    {
                        //mem.member.MeshWithOthers
                    }
                }

                // 12 ID
                GH_Integer ghID = new GH_Integer();
                if (DA.GetData(12, ref ghID))
                {
                    if (GH_Convert.ToInt32(ghID, out int id, GH_Conversion.Both))
                    {
                        mem.ID = id;
                    }
                }

                // 13 name
                GH_String ghnm = new GH_String();
                if (DA.GetData(13, ref ghnm))
                {
                    if (GH_Convert.ToString(ghnm, out string name, GH_Conversion.Both))
                    {
                        mem.Member.Name = name;
                    }
                }

                // 14 Group
                GH_Integer ghgrp = new GH_Integer();
                if (DA.GetData(14, ref ghgrp))
                {
                    if (GH_Convert.ToInt32(ghgrp, out int grp, GH_Conversion.Both))
                    {
                        mem.Member.Group = grp;
                    }
                }

                // 15 Colour
                GH_Colour ghcol = new GH_Colour();
                if (DA.GetData(15, ref ghcol))
                {
                    if (GH_Convert.ToColor(ghcol, out System.Drawing.Color col, GH_Conversion.Both))
                    {
                        mem.Member.Colour = col;
                    }
                }

                // 16 Dummy
                GH_Boolean ghdum = new GH_Boolean();
                if (DA.GetData(16, ref ghdum))
                {
                    if (GH_Convert.ToBoolean(ghdum, out bool dum, GH_Conversion.Both))
                    {
                        mem.Member.IsDummy = dum;
                    }
                }

                // #### outputs ####
                DA.SetData(0, new GsaMember1dGoo(mem));
                DA.SetData(1, mem.PolyCurve);
                DA.SetData(2, mem.Section);

                DA.SetData(3, mem.Member.Type);

                DA.SetData(4, mem.Member.Type1D);

                GsaOffset gsaOffset = new GsaOffset
                {
                    X1 = mem.Member.Offset.X1,
                    X2 = mem.Member.Offset.X2,
                    Y  = mem.Member.Offset.Y,
                    Z  = mem.Member.Offset.Z
                };
                DA.SetData(5, gsaOffset);

                DA.SetData(6, mem.ReleaseStart);
                DA.SetData(7, mem.ReleaseEnd);

                DA.SetData(8, mem.Member.OrientationAngle);
                DA.SetData(9, mem.Member.OrientationNode);

                DA.SetData(10, mem.Member.MeshSize);
                //DA.SetData(11, mem.member.MeshSize); //mesh with others bool

                DA.SetData(12, mem.ID);
                DA.SetData(13, mem.Member.Name);
                DA.SetData(14, mem.Member.Group);
                DA.SetData(15, mem.Member.Colour);

                DA.SetData(16, mem.Member.IsDummy);
            }
        }
        /// <summary>
        /// Method to import 1D and 2D Members from a GSA model.
        /// Will output a tuple of GhSA GsaMember1d and GsaMember2d.
        /// Filter members to import using memList input;
        /// "all" or empty string ("") will import all elements. Default is "all"
        /// "propGraft" bool = true; will put members in Grasshopper branch corrosponding to its property
        /// </summary>
        /// <param name="model"></param>
        /// <param name="memList"></param>
        /// <param name="propGraft"></param>
        /// <returns></returns>
        public static Tuple <DataTree <GsaMember1dGoo>, DataTree <GsaMember2dGoo> > GsaGetMemb(Model model, string memList = "all", bool propGraft = true)
        {
            // Create dictionaries to read list of elements and nodes:
            IReadOnlyDictionary <int, Member> mDict;

            mDict = model.Members(memList);
            IReadOnlyDictionary <int, Node> nDict;

            nDict = model.Nodes("all");
            IReadOnlyDictionary <int, Section> sDict;

            sDict = model.Sections();
            IReadOnlyDictionary <int, Prop2D> pDict;

            pDict = model.Prop2Ds();

            // Create lists for Rhino lines and meshes
            DataTree <GsaMember1dGoo> mem1ds = new DataTree <GsaMember1dGoo>();
            DataTree <GsaMember2dGoo> mem2ds = new DataTree <GsaMember2dGoo>();

            if (!propGraft)
            {
                mem1ds.EnsurePath(0);
                mem2ds.EnsurePath(0);
                int max = mDict.Count;
                if (max > 0)
                {
                    for (int i = 0; i < mDict.Keys.ElementAt(max - 1); i++)
                    {
                        mem1ds.Branches[0].Add(null);
                        mem2ds.Branches[0].Add(null);
                    }
                }
            }

            // Loop through all members in Member dictionary
            foreach (var key in mDict.Keys)
            {
                if (mDict.TryGetValue(key, out Member mem))
                {
                    int prop = 0;
                    if (propGraft)
                    {
                        prop = mem.Property - 1;
                    }

                    // Build topology lists
                    string toporg = mem.Topology; //original topology list

                    Tuple <Tuple <List <int>, List <string> >, Tuple <List <List <int> >, List <List <string> > >,
                           Tuple <List <List <int> >, List <List <string> > >, List <int> > topologyTuple = Topology_detangler(toporg);
                    Tuple <List <int>, List <string> > topoTuple = topologyTuple.Item1;
                    Tuple <List <List <int> >, List <List <string> > > voidTuple = topologyTuple.Item2;
                    Tuple <List <List <int> >, List <List <string> > > lineTuple = topologyTuple.Item3;

                    List <int>    topo_int = topoTuple.Item1;
                    List <string> topoType = topoTuple.Item2; //list of polyline curve type (arch or line) for member1d/2d

                    List <List <int> >    void_topo_int = voidTuple.Item1;
                    List <List <string> > void_topoType = voidTuple.Item2; //list of polyline curve type (arch or line) for void /member2d

                    List <List <int> >    incLines_topo_int  = lineTuple.Item1;
                    List <List <string> > inclLines_topoType = lineTuple.Item2; //list of polyline curve type (arch or line) for inclusion /member2d

                    List <int> inclpts = topologyTuple.Item4;

                    // replace topology integers with actual points
                    List <Point3d> topopts = new List <Point3d>(); // list of topology points for visualisation /member1d/member2d
                    for (int i = 0; i < topo_int.Count; i++)
                    {
                        if (nDict.TryGetValue(topo_int[i], out Node node))
                        {
                            var p = node.Position;
                            topopts.Add(new Point3d(p.X, p.Y, p.Z));
                        }
                        node.Dispose();
                    }

                    //list of lists of void points /member2d
                    List <List <Point3d> > void_topo = new List <List <Point3d> >();
                    for (int i = 0; i < void_topo_int.Count; i++)
                    {
                        void_topo.Add(new List <Point3d>());
                        for (int j = 0; j < void_topo_int[i].Count; j++)
                        {
                            if (nDict.TryGetValue(void_topo_int[i][j], out Node node))
                            {
                                var p = node.Position;
                                void_topo[i].Add(new Point3d(p.X, p.Y, p.Z));
                            }
                            node.Dispose();
                        }
                    }

                    //list of lists of line inclusion topology points /member2d
                    List <List <Point3d> > incLines_topo = new List <List <Point3d> >();
                    for (int i = 0; i < incLines_topo_int.Count; i++)
                    {
                        incLines_topo.Add(new List <Point3d>());
                        for (int j = 0; j < incLines_topo_int[i].Count; j++)
                        {
                            if (nDict.TryGetValue(incLines_topo_int[i][j], out Node node))
                            {
                                var p = node.Position;
                                incLines_topo[i].Add(new Point3d(p.X, p.Y, p.Z));
                            }
                            node.Dispose();
                        }
                    }

                    //list of points for inclusion /member2d
                    List <Point3d> incl_pts = new List <Point3d>();
                    for (int i = 0; i < inclpts.Count; i++)
                    {
                        if (nDict.TryGetValue(inclpts[i], out Node node))
                        {
                            var p = node.Position;
                            incl_pts.Add(new Point3d(p.X, p.Y, p.Z));
                        }
                        node.Dispose();
                    }

                    if (mem.Type == MemberType.GENERIC_1D | mem.Type == MemberType.BEAM | mem.Type == MemberType.CANTILEVER |
                        mem.Type == MemberType.COLUMN | mem.Type == MemberType.COMPOS | mem.Type == MemberType.PILE)
                    {
                        GsaMember1d mem1d = new GsaMember1d(topopts, topoType)
                        {
                            ID     = key,
                            Member = mem
                        };
                        GsaSection section = new GsaSection
                        {
                            ID = mem.Property
                        };
                        if (sDict.TryGetValue(section.ID, out Section tempSection))
                        {
                            section.Section = tempSection;
                        }
                        mem1d.Section = section;
                        mem1ds.EnsurePath(prop);
                        GH_Path path = new GH_Path(prop);
                        if (propGraft)
                        {
                            mem1ds.Add(new GsaMember1dGoo(mem1d.Duplicate()), path);
                        }
                        else
                        {
                            mem1ds[path, key - 1] = new GsaMember1dGoo(mem1d.Duplicate());
                        }
                    }
                    else
                    {
                        GsaMember2d mem2d = new GsaMember2d(topopts, topoType, void_topo, void_topoType, incLines_topo, inclLines_topoType, incl_pts)
                        {
                            Member = mem,
                            ID     = key
                        };
                        GsaProp2d prop2d = new GsaProp2d
                        {
                            ID = mem.Property
                        };
                        if (pDict.TryGetValue(prop2d.ID, out Prop2D tempProp))
                        {
                            prop2d.Prop2d = tempProp;
                        }
                        mem2d.Property = prop2d;
                        mem2ds.EnsurePath(prop);
                        GH_Path path = new GH_Path(prop);
                        if (propGraft)
                        {
                            mem2ds.Add(new GsaMember2dGoo(mem2d.Duplicate()), path);
                        }
                        else
                        {
                            mem2ds[path, key - 1] = new GsaMember2dGoo(mem2d.Duplicate());
                        }
                    }

                    topopts.Clear();
                    topoType.Clear();
                    void_topo.Clear();
                    void_topoType.Clear();
                    incLines_topo.Clear();
                    inclLines_topoType.Clear();
                    incl_pts.Clear();
                }
            }

            return(new Tuple <DataTree <GsaMember1dGoo>, DataTree <GsaMember2dGoo> >(mem1ds, mem2ds));
        }