public static List <Member> ConvertMember1D(List <GsaMember1d> member1ds, ref List <Node> nodes, ref int nodeidcounter) { // List to set members in List <Member> mems = new List <Member>(); #region member1d // member1Ds if (member1ds != null) { if (member1ds.Count > 0) { for (int i = 0; i < member1ds.Count; i++) { if (member1ds[i] != null) { GsaMember1d member1d = member1ds[i]; Member apiMember = Members.ConvertMember1D(member1d, ref nodes, ref nodeidcounter); mems.Add(apiMember); } } } } return(mems); #endregion }
public static Member ConvertMember1D(GsaMember1d member1d, ref List <Node> nodes, ref int nodeidcounter) { // ensure node id is at least 1 if (nodeidcounter < 1) { nodeidcounter = 1; } // take out api member Member apimember = member1d.Member; // create topology string to build string topo = ""; // Loop through the topology list for (int j = 0; j < member1d.Topology.Count; j++) { string topologyType = member1d.TopologyType[j]; if (j > 0) { if (topologyType == "" | topologyType == " ") { topo += " "; } else { topo += topologyType.ToLower() + " "; // add topology type (nothing or "a") in front of node id } } Point3d pt = member1d.Topology[j]; Node node = new Node(); node.Position.X = pt.X; node.Position.Y = pt.Y; node.Position.Z = pt.Z; nodes.Add(node); topo += nodeidcounter++; if (j != member1d.Topology.Count - 1) { topo += " "; } } // set topology in api member apimember.Topology = string.Copy(topo); return(apimember); }
public void TestCreateGsaMem1dFromCrv() { // create a list of control points List <Point3d> pts = new List <Point3d>(); pts.Add(new Point3d(-3, -4, 0)); pts.Add(new Point3d(5, -2, 0)); pts.Add(new Point3d(2, 2, 0)); pts.Add(new Point3d(6, 7, 0)); // create nurbscurve from pts PolylineCurve crv = new PolylineCurve(pts); //NurbsCurve crv = NurbsCurve.Create(false, 3, pts); // create 1d member from crv GsaMember1d mem = new GsaMember1d(crv); // set some members mem.Colour = System.Drawing.Color.Red; mem.ID = 3; mem.Member.Name = "gemma"; mem.Member.IsDummy = true; mem.Member.Offset.Z = -0.45; mem.Member.Property = 2; mem.Member.Type1D = ElementType.BEAM; mem.Member.Type = MemberType.BEAM; // check that end-points are similar between converted curve and topology list Assert.AreEqual(mem.PolyCurve.PointAtStart.X, mem.Topology[0].X); Assert.AreEqual(mem.PolyCurve.PointAtStart.Y, mem.Topology[0].Y); Assert.AreEqual(mem.PolyCurve.PointAtEnd.X, mem.Topology[mem.Topology.Count - 1].X); Assert.AreEqual(mem.PolyCurve.PointAtEnd.Y, mem.Topology[mem.Topology.Count - 1].Y); // loop through segments and check they are either arc or line for (int i = 0; i < mem.PolyCurve.SegmentCount; i++) { Assert.IsTrue(mem.PolyCurve.SegmentCurve(i).IsLinear() || mem.PolyCurve.SegmentCurve(i).IsArc()); } Assert.AreEqual(System.Drawing.Color.FromArgb(255, 255, 0, 0), mem.Member.Colour); Assert.AreEqual(3, mem.ID); Assert.AreEqual("gemma", mem.Member.Name); Assert.IsTrue(mem.Member.IsDummy); Assert.AreEqual(-0.45, mem.Member.Offset.Z); Assert.AreEqual(2, mem.Member.Property); Assert.AreEqual(ElementType.BEAM, mem.Member.Type1D); Assert.AreEqual(MemberType.BEAM, mem.Member.Type); }
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); } }
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; } } }
protected override void SolveInstance(IGH_DataAccess DA) { GH_Brep ghbrep = new GH_Brep(); if (DA.GetData(0, ref ghbrep)) { if (ghbrep == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Brep input is null"); } Brep brep = new Brep(); if (GH_Convert.ToBrep(ghbrep, ref brep, GH_Conversion.Both)) { // 1 Points List <GH_ObjectWrapper> gh_types = new List <GH_ObjectWrapper>(); List <Point3d> pts = new List <Point3d>(); List <GsaNode> nodes = new List <GsaNode>(); if (DA.GetDataList(1, gh_types)) { for (int i = 0; i < gh_types.Count; i++) { Point3d pt = new Point3d(); if (gh_types[i].Value is GsaNodeGoo) { GsaNode gsanode = new GsaNode(); gh_types[i].CastTo(ref gsanode); nodes.Add(gsanode); } else if (GH_Convert.ToPoint3d(gh_types[i].Value, ref pt, GH_Conversion.Both)) { pts.Add(pt); } else { string type = gh_types[i].Value.GetType().ToString(); type = type.Replace("GhSA.Parameters.", ""); type = type.Replace("Goo", ""); AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert incl. Point/Node input parameter of type " + type + " to point or node"); } } } // 2 Curves gh_types = new List <GH_ObjectWrapper>(); List <Curve> crvs = new List <Curve>(); List <GsaMember1d> mem1ds = new List <GsaMember1d>(); if (DA.GetDataList(2, gh_types)) { for (int i = 0; i < gh_types.Count; i++) { Curve crv = null; if (gh_types[i].Value is GsaMember1dGoo) { GsaMember1d gsamem1d = new GsaMember1d(); gh_types[i].CastTo(ref gsamem1d); mem1ds.Add(gsamem1d); } else if (GH_Convert.ToCurve(gh_types[i].Value, ref crv, GH_Conversion.Both)) { crvs.Add(crv); } else { string type = gh_types[i].Value.GetType().ToString(); type = type.Replace("GhSA.Parameters.", ""); type = type.Replace("Goo", ""); AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert incl. Curve/Mem1D input parameter of type " + type + " to curve or 1D Member"); } } } // 4 mesh size GH_Number ghmsz = new GH_Number(); double meshSize = 0; if (DA.GetData(4, ref ghmsz)) { GH_Convert.ToDouble(ghmsz, out double m_size, GH_Conversion.Both); meshSize = m_size; } // build new element2d with brep, crv and pts GsaElement2d elem2d = new GsaElement2d(brep, crvs, pts, meshSize, mem1ds, nodes); // 3 section GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); GsaProp2d prop2d = new GsaProp2d(); if (DA.GetData(3, ref gh_typ)) { if (gh_typ.Value is GsaProp2dGoo) { gh_typ.CastTo(ref prop2d); } else { if (GH_Convert.ToInt32(gh_typ.Value, out int idd, GH_Conversion.Both)) { prop2d.ID = idd; } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert PA input to a 2D Property of reference integer"); return; } } } else { prop2d.ID = 1; } List <GsaProp2d> prop2Ds = new List <GsaProp2d>(); for (int i = 0; i < elem2d.Elements.Count; i++) { prop2Ds.Add(prop2d); } elem2d.Properties = prop2Ds; DA.SetData(0, new GsaElement2dGoo(elem2d)); }
protected override void SolveInstance(IGH_DataAccess DA) { GH_Curve ghcrv = new GH_Curve(); if (DA.GetData(0, ref ghcrv)) { if (ghcrv == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Curve input is null"); } Curve crv = null; if (GH_Convert.ToCurve(ghcrv, ref crv, GH_Conversion.Both)) { GsaMember1d mem = new GsaMember1d(crv); GsaBool6 rel1 = new GsaBool6 { X = x1, Y = y1, Z = z1, XX = xx1, YY = yy1, ZZ = zz1 }; mem.ReleaseStart = rel1; GsaBool6 rel2 = new GsaBool6 { X = x2, Y = y2, Z = z2, XX = xx2, YY = yy2, ZZ = zz2 }; mem.ReleaseEnd = rel2; // 1 section GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); GsaSection section = new GsaSection(); if (DA.GetData(1, ref gh_typ)) { if (gh_typ.Value is GsaSectionGoo) { gh_typ.CastTo(ref section); mem.Section = section; } else { if (GH_Convert.ToInt32(gh_typ.Value, out int idd, GH_Conversion.Both)) { mem.Member.Property = idd; } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert PB input to a Section Property of reference integer"); return; } } } DA.SetData(0, new GsaMember1dGoo(mem)); }
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); }
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; } }
public static void ConvertMember1D(GsaMember1d member1d, ref Dictionary <int, Member> existingMembers, ref int memberidcounter, ref Dictionary <int, Node> existingNodes, ref int nodeidcounter, ref Dictionary <int, Section> existingSections, ref Dictionary <Guid, int> sections_guid) { Member apiMember = member1d.Member; // update topology list to fit model nodes string topo = ""; // Loop through the topology list for (int j = 0; j < member1d.Topology.Count; j++) { string topologyType = member1d.TopologyType[j]; Point3d pt = member1d.Topology[j]; if (j > 0) { if (topologyType == "" | topologyType == " ") { topo += " "; } else { topo += topologyType.ToLower() + " "; // add topology type (nothing or "a") in front of node id } } int id = Nodes.GetExistingNodeID(existingNodes, pt); if (id > 0) { topo += id; } else { existingNodes.Add(nodeidcounter, Nodes.NodeFromPoint(pt)); topo += nodeidcounter; nodeidcounter++; } if (j != member1d.Topology.Count - 1) { topo += " "; } } // set topology in api member apiMember.Topology = string.Copy(topo); // Section if (apiMember.Property == 0) { apiMember.Property = Sections.ConvertSection(member1d.Section, ref existingSections, ref sections_guid); } // set apimember in dictionary if (member1d.ID > 0) // if the ID is larger than 0 than means the ID has been set and we sent it to the known list { existingMembers[member1d.ID] = apiMember; } else { existingMembers.Add(memberidcounter, apiMember); memberidcounter++; } }
public void GetGeometryComponentTest() { Assert.IsTrue(Rhino.RhinoApp.IsLicenseValidated, "Rhino must be licensed to run this test"); // ensure model has been opened: if (TestModel == null) { OpenComponentTest(); } // create the component var comp = new GhSA.Components.GetGeometry(); comp.CreateAttributes(); // input parameter GsaModelGoo modelGoo = new GsaModelGoo(TestModel); Component.SetInput(comp, modelGoo); // Get output from component GsaNodeGoo output00 = (GsaNodeGoo)Component.GetOutput(comp, 0, 0, 0); GsaNodeGoo output01 = (GsaNodeGoo)Component.GetOutput(comp, 0, 0, 1); GsaElement1dGoo output1 = (GsaElement1dGoo)Component.GetOutput(comp, 1); GsaMember1dGoo output3 = (GsaMember1dGoo)Component.GetOutput(comp, 4); //pManager.AddGenericParameter("Nodes", "No", "Nodes from GSA Model", GH_ParamAccess.list); //pManager.AddGenericParameter("1D Elements", "E1D", "1D Elements (Analysis Layer) from GSA Model", GH_ParamAccess.list); //pManager.AddGenericParameter("2D Elements", "E2D", "2D Elements (Analysis Layer) from GSA Model", GH_ParamAccess.list); //pManager.AddGenericParameter("3D Elements", "E3D", "3D Elements (Analysis Layer) from GSA Model", GH_ParamAccess.list); //pManager.AddGenericParameter("1D Members", "M1D", "1D Members (Design Layer) from GSA Model", GH_ParamAccess.list); //pManager.AddGenericParameter("2D Members", "M2D", "2D Members (Design Layer) from GSA Model", GH_ParamAccess.list); //pManager.AddGenericParameter("3D Members", "M3D", "3D Members (Design Layer) from GSA Model", GH_ParamAccess.list); // cast from -goo to Gsa-GH data type GsaNode node1 = new GsaNode(); GsaNode node2 = new GsaNode(); output00.CastTo(ref node1); output01.CastTo(ref node2); GsaElement1d elem = new GsaElement1d(); output1.CastTo(ref elem); GsaMember1d mem = new GsaMember1d(); output3.CastTo(ref mem); // test nodes are correct Assert.AreEqual(1, node1.ID); Assert.AreEqual(0, node1.Point.X, 1E-9); Assert.AreEqual(0, node1.Point.Y, 1E-9); Assert.AreEqual(0, node1.Point.Z, 1E-9); Assert.AreEqual(2, node2.ID); Assert.AreEqual(7.5, node2.Point.X, 1E-9); Assert.AreEqual(0, node2.Point.Y, 1E-9); Assert.AreEqual(0, node2.Point.Z, 1E-9); Assert.IsTrue(node1.Node.Restraint.X); Assert.IsTrue(node1.Node.Restraint.Y); Assert.IsTrue(node1.Node.Restraint.Z); Assert.IsTrue(node1.Node.Restraint.XX); Assert.IsFalse(node1.Node.Restraint.YY); Assert.IsFalse(node1.Node.Restraint.ZZ); Assert.IsFalse(node2.Node.Restraint.X); Assert.IsTrue(node2.Node.Restraint.Y); Assert.IsTrue(node2.Node.Restraint.Z); Assert.IsFalse(node2.Node.Restraint.XX); Assert.IsFalse(node2.Node.Restraint.YY); Assert.IsFalse(node2.Node.Restraint.ZZ); // test element and member Assert.AreEqual(1, elem.ID); Assert.AreEqual(0, elem.Line.PointAtStart.X, 1E-9); Assert.AreEqual(0, elem.Line.PointAtStart.Y, 1E-9); Assert.AreEqual(0, elem.Line.PointAtStart.Z, 1E-9); Assert.AreEqual(7.5, elem.Line.PointAtEnd.X, 1E-9); Assert.AreEqual(0, elem.Line.PointAtEnd.Y, 1E-9); Assert.AreEqual(0, elem.Line.PointAtEnd.Z, 1E-9); //Assert.AreEqual("CAT UB UB457x191x89", elem.Section.Section.Profile.Substring(0, 19)); Assert.AreEqual(1, mem.ID); Assert.AreEqual(0, mem.PolyCurve.PointAtStart.X, 1E-9); Assert.AreEqual(0, mem.PolyCurve.PointAtStart.Y, 1E-9); Assert.AreEqual(0, mem.PolyCurve.PointAtStart.Z, 1E-9); Assert.AreEqual(7.5, mem.PolyCurve.PointAtEnd.X, 1E-9); Assert.AreEqual(0, mem.PolyCurve.PointAtEnd.Y, 1E-9); Assert.AreEqual(0, mem.PolyCurve.PointAtEnd.Z, 1E-9); }
protected override void SolveInstance(IGH_DataAccess DA) { GH_Curve ghcrv = new GH_Curve(); if (DA.GetData(0, ref ghcrv)) { Curve crv = null; if (GH_Convert.ToCurve(ghcrv, ref crv, GH_Conversion.Both)) { GsaMember1d mem = new GsaMember1d(crv); GsaBool6 rel1 = new GsaBool6 { X = x1, Y = y1, Z = z1, XX = xx1, YY = yy1, ZZ = zz1 }; mem.ReleaseStart = rel1; GsaBool6 rel2 = new GsaBool6 { X = x2, Y = y2, Z = z2, XX = xx2, YY = yy2, ZZ = zz2 }; mem.ReleaseEnd = rel2; // 1 section GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); GsaSection section = new GsaSection(); if (DA.GetData(1, ref gh_typ)) { 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; } } } else { section.ID = 1; } mem.Section = section; DA.SetData(0, new GsaMember1dGoo(mem)); } } }
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)); }
protected override void SolveInstance(IGH_DataAccess DA) { #region inputs // Get Member1d input GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); List <GH_ObjectWrapper> gh_types = new List <GH_ObjectWrapper>(); List <GsaNode> in_nodes = new List <GsaNode>(); if (DA.GetDataList(0, gh_types)) { for (int i = 0; i < gh_types.Count; i++) { gh_typ = gh_types[i]; if (gh_typ.Value is GsaNodeGoo) { GsaNode gsanode = new GsaNode(); gh_typ.CastTo(ref gsanode); in_nodes.Add(gsanode); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Error in Node input"); return; } } } List <GsaMember1d> in_mem1ds = new List <GsaMember1d>(); if (DA.GetDataList(1, gh_types)) { for (int i = 0; i < gh_types.Count; i++) { gh_typ = gh_types[i]; if (gh_typ.Value is GsaMember1dGoo) { GsaMember1d gsamem1 = new GsaMember1d(); gh_typ.CastTo(ref gsamem1); in_mem1ds.Add(gsamem1); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Error in Mem1D input"); return; } } } // Get Member2d input gh_types = new List <GH_ObjectWrapper>(); List <GsaMember2d> in_mem2ds = new List <GsaMember2d>(); if (DA.GetDataList(2, gh_types)) { for (int i = 0; i < gh_types.Count; i++) { gh_typ = gh_types[i]; if (gh_typ.Value is GsaMember2dGoo) { GsaMember2d gsamem2 = new GsaMember2d(); gh_typ.CastTo(ref gsamem2); in_mem2ds.Add(gsamem2); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Error in Mem2D input"); return; } } } // Get Member3d input gh_types = new List <GH_ObjectWrapper>(); List <GsaMember3d> in_mem3ds = new List <GsaMember3d>(); if (DA.GetDataList(3, gh_types)) { for (int i = 0; i < gh_types.Count; i++) { gh_typ = gh_types[i]; if (gh_typ.Value is GsaMember3dGoo) { GsaMember3d gsamem3 = new GsaMember3d(); gh_typ.CastTo(ref gsamem3); in_mem3ds.Add(gsamem3); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Error in Mem3D input"); return; } } } // manually add a warning if no input is set, as all three inputs are optional if (in_mem1ds.Count < 1 & in_mem2ds.Count < 1 & in_mem3ds.Count < 1) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Input parameters failed to collect data"); } #endregion // Assemble model Model gsa = Util.Gsa.ToGSA.Assemble.AssembleModel(null, in_nodes, null, null, null, in_mem1ds, in_mem2ds, in_mem3ds, null, null, null, null); #region meshing // Create elements from members gsa.CreateElementsFromMembers(); #endregion // extract nodes from model List <GsaNodeGoo> nodes = Util.Gsa.FromGSA.GetNodes(gsa.Nodes(), gsa); // extract elements from model Tuple <List <GsaElement1dGoo>, List <GsaElement2dGoo>, List <GsaElement3dGoo> > elementTuple = Util.Gsa.FromGSA.GetElements(gsa.Elements(), gsa.Nodes(), gsa.Sections(), gsa.Prop2Ds()); // expose internal model if anyone wants to use it GsaModel outModel = new GsaModel(); outModel.Model = gsa; DA.SetDataList(0, nodes); DA.SetDataList(1, elementTuple.Item1); DA.SetDataList(2, elementTuple.Item2); DA.SetDataList(3, elementTuple.Item3); DA.SetData(4, new GsaModelGoo(outModel)); // custom display settings for element2d mesh element2ds = elementTuple.Item2; }