protected override void SolveInstance(IGH_DataAccess DA) { GsaMember2d gsaMember2d = new GsaMember2d(); if (DA.GetData(0, ref gsaMember2d)) { GsaMember2d mem = gsaMember2d.Duplicate(); // #### inputs #### // 1 brep Brep brep = mem.Brep; //existing brep GH_Brep ghbrep = new GH_Brep(); if (DA.GetData(1, ref ghbrep)) { if (GH_Convert.ToBrep(ghbrep, ref brep, GH_Conversion.Both)) { mem.Brep = brep; } } // 2 section GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); if (DA.GetData(2, ref gh_typ)) { GsaProp2d prop2d = new GsaProp2d(); if (gh_typ.Value is GsaProp2d) { gh_typ.CastTo(ref prop2d); } else if (gh_typ.Value is GH_Number) { if (GH_Convert.ToInt32((GH_Number)gh_typ.Value, out int idd, GH_Conversion.Both)) { prop2d.ID = idd; } } mem.Property = prop2d; } // 3 offset GsaOffset offset = new GsaOffset(); if (DA.GetData(3, ref offset)) { mem.Member.Offset.Z = offset.Z; } // 4 inclusion points List <Point3d> pts = mem.InclusionPoints; List <GH_Point> ghpts = new List <GH_Point>(); if (DA.GetDataList(4, ghpts)) { for (int i = 0; i < ghpts.Count; i++) { Point3d pt = new Point3d(); if (GH_Convert.ToPoint3d(ghpts[i], ref pt, GH_Conversion.Both)) { pts.Add(pt); } } } // 5 inclusion lines CurveList crvlist = new CurveList(mem.InclusionLines); List <Curve> crvs = crvlist.ToList(); List <GH_Curve> ghcrvs = new List <GH_Curve>(); if (DA.GetDataList(5, ghcrvs)) { for (int i = 0; i < ghcrvs.Count; i++) { Curve crv = null; if (GH_Convert.ToCurve(ghcrvs[i], ref crv, GH_Conversion.Both)) { crvs.Add(crv); } } } GsaMember2d tmpmem = new GsaMember2d(brep, crvs, pts) { ID = mem.ID, Member = mem.Member, Property = mem.Property }; mem = tmpmem; // 6 mesh size GH_Number ghmsz = new GH_Number(); if (DA.GetData(6, ref ghmsz)) { if (GH_Convert.ToDouble(ghmsz, out double msz, GH_Conversion.Both)) { mem.Member.MeshSize = msz; } } // 7 mesh with others GH_Boolean ghbool = new GH_Boolean(); if (DA.GetData(7, ref ghbool)) { if (GH_Convert.ToBoolean(ghbool, out bool mbool, GH_Conversion.Both)) { //mem.member.MeshWithOthers } } // 8 type GH_Integer ghint = new GH_Integer(); if (DA.GetData(8, ref ghint)) { if (GH_Convert.ToInt32(ghint, out int type, GH_Conversion.Both)) { mem.Member.Type = Util.Gsa.GsaToModel.Member2dType(type); } } // 9 element type / analysis order GH_Integer ghinteg = new GH_Integer(); if (DA.GetData(9, ref ghinteg)) { if (GH_Convert.ToInt32(ghinteg, out int type, GH_Conversion.Both)) { mem.Member.Type2D = Util.Gsa.GsaToModel.Element2dType(type); } } // 10 ID GH_Integer ghID = new GH_Integer(); if (DA.GetData(10, ref ghID)) { if (GH_Convert.ToInt32(ghID, out int id, GH_Conversion.Both)) { mem.ID = id; } } // 11 name GH_String ghnm = new GH_String(); if (DA.GetData(11, ref ghnm)) { if (GH_Convert.ToString(ghnm, out string name, GH_Conversion.Both)) { mem.Member.Name = name; } } // 12 Group GH_Integer ghgrp = new GH_Integer(); if (DA.GetData(12, ref ghgrp)) { if (GH_Convert.ToInt32(ghgrp, out int grp, GH_Conversion.Both)) { mem.Member.Group = grp; } } // 13 Colour GH_Colour ghcol = new GH_Colour(); if (DA.GetData(13, ref ghcol)) { if (GH_Convert.ToColor(ghcol, out System.Drawing.Color col, GH_Conversion.Both)) { mem.Member.Colour = col; } } // 14 Dummy GH_Boolean ghdum = new GH_Boolean(); if (DA.GetData(14, ref ghdum)) { if (GH_Convert.ToBoolean(ghdum, out bool dum, GH_Conversion.Both)) { mem.Member.IsDummy = dum; } } // #### outputs #### DA.SetData(0, new GsaMember2dGoo(mem)); DA.SetData(1, mem.Brep); DA.SetData(2, mem.Property); GsaOffset gsaOffset = new GsaOffset { Z = mem.Member.Offset.Z }; DA.SetData(3, gsaOffset); DA.SetDataList(4, mem.InclusionPoints); DA.SetDataList(5, mem.InclusionLines); DA.SetData(6, mem.Member.MeshSize); //DA.SetData(7, mem.member.MeshWithOthers); DA.SetData(8, mem.Member.Type); DA.SetData(9, mem.Member.Type2D); DA.SetData(10, mem.ID); DA.SetData(11, mem.Member.Name); DA.SetData(12, mem.Member.Group); DA.SetData(13, mem.Member.Colour); DA.SetData(14, mem.Member.IsDummy); } }
protected override void SolveInstance(IGH_DataAccess DA) { GsaMember2d gsaMember2d = new GsaMember2d(); if (DA.GetData(0, ref gsaMember2d)) { if (gsaMember2d == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Member2D input is null"); } GsaMember2d mem = gsaMember2d.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/3/4 Brep, incl.pts and incl.lns Brep brep = mem.Brep; //existing brep GH_Brep ghbrep = new GH_Brep(); CurveList crvlist = new CurveList(mem.InclusionLines); List <Curve> crvs = crvlist.ToList(); List <GH_Curve> ghcrvs = new List <GH_Curve>(); List <GH_Point> ghpts = new List <GH_Point>(); List <Point3d> pts = mem.InclusionPoints; if ((DA.GetData(2, ref ghbrep)) || (DA.GetDataList(3, ghpts)) || (DA.GetDataList(4, ghcrvs))) { // 2 brep if (DA.GetData(2, ref ghbrep)) { if (GH_Convert.ToBrep(ghbrep, ref brep, GH_Conversion.Both)) { mem.Brep = brep; } } // 3 inclusion points if (DA.GetDataList(3, ghpts)) { for (int i = 0; i < ghpts.Count; i++) { Point3d pt = new Point3d(); if (GH_Convert.ToPoint3d(ghpts[i], ref pt, GH_Conversion.Both)) { pts.Add(pt); } } } // 4 inclusion lines if (DA.GetDataList(4, ghcrvs)) { for (int i = 0; i < ghcrvs.Count; i++) { Curve crv = null; if (GH_Convert.ToCurve(ghcrvs[i], ref crv, GH_Conversion.Both)) { crvs.Add(crv); } } } GsaMember2d tmpmem = new GsaMember2d(brep, crvs, pts); mem.PolyCurve = tmpmem.PolyCurve; mem.Topology = tmpmem.Topology; mem.TopologyType = tmpmem.TopologyType; mem.VoidTopology = tmpmem.VoidTopology; mem.VoidTopologyType = tmpmem.VoidTopologyType; mem.InclusionLines = tmpmem.InclusionLines; mem.IncLinesTopology = tmpmem.IncLinesTopology; mem.IncLinesTopologyType = tmpmem.IncLinesTopologyType; mem.InclusionPoints = tmpmem.InclusionPoints; mem = tmpmem; } // 5 section GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); if (DA.GetData(5, ref gh_typ)) { GsaProp2d prop2d = new GsaProp2d(); if (gh_typ.Value is GsaProp2dGoo) { gh_typ.CastTo(ref prop2d); mem.Property = prop2d; mem.Member.Property = 0; } else { if (GH_Convert.ToInt32(gh_typ.Value, out int idd, GH_Conversion.Both)) { mem.Member.Property = idd; mem.Property = null; } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert PA input to a 2D Property of reference integer"); return; } } }