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) { // 0 Plane Plane pln = Plane.Unset; GsaGridPlaneSurface gps; bool idSet = false; GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); if (DA.GetData(0, ref gh_typ)) { if (gh_typ.Value is GsaGridPlaneSurfaceGoo) { GsaGridPlaneSurface temppln = new GsaGridPlaneSurface(); gh_typ.CastTo(ref temppln); gps = temppln.Duplicate(); } else { if (gh_typ.CastTo(ref pln)) { gps = new GsaGridPlaneSurface(pln); } else { int id = 0; if (GH_Convert.ToInt32(gh_typ.Value, out id, GH_Conversion.Both)) { gps = new GsaGridPlaneSurface(); gps.GridSurface.GridPlane = id; gps.GridPlane = null; idSet = true; } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Cannot convert your input to GridPlaneSurface or Plane"); return; } } } } else { pln = Plane.WorldXY; gps = new GsaGridPlaneSurface(pln); } // record if changes has been made from default type bool changeGS = false; GridSurface gs = new GridSurface(); // new GridSurface to make changes to, set it back to GPS in the end if (idSet) { gs.GridPlane = gps.GridSurface.GridPlane; } // 1 ID GH_Integer ghint = new GH_Integer(); if (DA.GetData(1, ref ghint)) { int id = 0; GH_Convert.ToInt32(ghint, out id, GH_Conversion.Both); gps.GridSurfaceID = id; } // 2 Elements GH_String ghelem = new GH_String(); if (DA.GetData(2, ref ghelem)) { string elem = ""; if (GH_Convert.ToString(ghelem, out elem, GH_Conversion.Both)) { gs.Elements = elem; changeGS = true; } } // 3 Name GH_String ghtxt = new GH_String(); if (DA.GetData(3, ref ghtxt)) { string name = ""; if (GH_Convert.ToString(ghtxt, out name, GH_Conversion.Both)) { gs.Name = name; changeGS = true; } } // 4 Tolerance GH_Number ghtol = new GH_Number(); if (DA.GetData(4, ref ghtol)) { double tol = 10; if (GH_Convert.ToDouble(ghtol, out tol, GH_Conversion.Both)) { gs.Tolerance = tol; changeGS = true; } } switch (_mode) { case FoldMode.One_Dimensional_One_Way: gs.ElementType = GridSurface.Element_Type.ONE_DIMENSIONAL; gs.SpanType = GridSurface.Span_Type.ONE_WAY; // 5 span direction GH_Number ghdir = new GH_Number(); if (DA.GetData(5, ref ghdir)) { double dir = 0; if (GH_Convert.ToDouble(ghdir, out dir, GH_Conversion.Both)) { if (dir > 180 || dir < -180) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Angle value must be between -180 and 180 degrees"); // to be updated when GsaAPI support units } gs.Direction = dir; if (dir != 0) { changeGS = true; } } } break; case FoldMode.One_Dimensional_Two_Way: changeGS = true; gs.ElementType = GridSurface.Element_Type.ONE_DIMENSIONAL; // 5 expansion method int exp = 0; GH_Integer ghexp = new GH_Integer(); if (DA.GetData(5, ref ghexp)) { GH_Convert.ToInt32_Primary(ghexp, ref exp); } gs.ExpansionType = GridSurfaceExpansionType.PLANE_CORNER; if (exp == 1) { gs.ExpansionType = GridSurfaceExpansionType.PLANE_SMOOTH; } if (exp == 2) { gs.ExpansionType = GridSurfaceExpansionType.PLANE_ASPECT; } if (exp == 3) { gs.ExpansionType = GridSurfaceExpansionType.LEGACY; } // 6 simplify tributary area bool simple = true; GH_Boolean ghsim = new GH_Boolean(); if (DA.GetData(6, ref ghsim)) { GH_Convert.ToBoolean(ghsim, out simple, GH_Conversion.Both); } if (simple) { gs.SpanType = GridSurface.Span_Type.TWO_WAY_SIMPLIFIED_TRIBUTARY_AREAS; } else { gs.SpanType = GridSurface.Span_Type.TWO_WAY; } break; case FoldMode.Two_Dimensional: changeGS = true; gs.ElementType = GridSurface.Element_Type.TWO_DIMENSIONAL; break; } if (changeGS) { gps.GridSurface = gs; } DA.SetData(0, new GsaGridPlaneSurfaceGoo(gps)); }
protected override void SolveInstance(IGH_DataAccess DA) { GsaGridLineLoad gridlineload = new GsaGridLineLoad(); // 0 Load case int lc = 1; GH_Integer gh_lc = new GH_Integer(); if (DA.GetData(0, ref gh_lc)) { GH_Convert.ToInt32(gh_lc, out lc, GH_Conversion.Both); } gridlineload.GridLineLoad.Case = lc; // Do plane input first as to see if we need to project polyline onto grid plane // 2 Plane Plane pln = Plane.WorldXY; bool planeSet = false; GsaGridPlaneSurface grdplnsrf = new GsaGridPlaneSurface(); GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); if (DA.GetData(2, ref gh_typ)) { if (gh_typ.Value is GsaGridPlaneSurfaceGoo) { GsaGridPlaneSurface temppln = new GsaGridPlaneSurface(); gh_typ.CastTo(ref temppln); grdplnsrf = temppln.Duplicate(); pln = grdplnsrf.Plane; planeSet = true; } else if (gh_typ.Value is Plane) { gh_typ.CastTo(ref pln); grdplnsrf = new GsaGridPlaneSurface(pln); planeSet = true; } else { int id = 0; if (GH_Convert.ToInt32(gh_typ.Value, out id, GH_Conversion.Both)) { gridlineload.GridLineLoad.GridSurface = id; gridlineload.GridPlaneSurface = null; } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Error in GPS input. Accepted inputs are Grid Plane Surface or Plane. " + System.Environment.NewLine + "If no input here then the line's best-fit plane will be used"); return; } } } // we wait setting the gridplanesurface until we have run the polyline input // 1 Polyline Polyline ln = new Polyline(); GH_Curve gh_crv = new GH_Curve(); if (DA.GetData(1, ref gh_crv)) { Curve crv = null; GH_Convert.ToCurve(gh_crv, ref crv, GH_Conversion.Both); //convert to polyline if (crv.TryGetPolyline(out ln)) { // get control points List <Point3d> ctrl_pts = ln.ToList(); // plane if (!planeSet) { // create best-fit plane from pts pln = Util.GH.Convert.CreateBestFitUnitisedPlaneFromPts(ctrl_pts); // create grid plane surface from best fit plane grdplnsrf = new GsaGridPlaneSurface(pln, true); } else { // project original curve onto grid plane crv = Curve.ProjectToPlane(crv, pln); // convert to polyline again crv.TryGetPolyline(out ln); //get control points again ctrl_pts = ln.ToList(); } // string to write polyline description to string desc = ""; // loop through all points for (int i = 0; i < ctrl_pts.Count; i++) { if (i > 0) { desc += " "; } // get control points in local plane coordinates Point3d temppt = new Point3d(); pln.RemapToPlaneSpace(ctrl_pts[i], out temppt); // write point to string // format accepted by GSA: (0,0) (0,1) (1,2) (3,4) (4,0)(m) desc += "(" + temppt.X + "," + temppt.Y + ")"; } // add units to the end desc += "(" + Units.LengthLarge + ")"; // set polyline in grid line load gridlineload.GridLineLoad.Type = GridLineLoad.PolyLineType.EXPLICIT_POLYLINE; gridlineload.GridLineLoad.PolyLineDefinition = desc; } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Could not convert Curve to Polyline"); } } // now we can set the gridplanesurface: if (gridlineload.GridPlaneSurface != null) { if (gridlineload.GridPlaneSurface.GridSurfaceID == 0) { gridlineload.GridPlaneSurface = grdplnsrf; } } // 3 direction string dir = "Z"; Direction direc = Direction.Z; GH_String gh_dir = new GH_String(); if (DA.GetData(3, ref gh_dir)) { GH_Convert.ToString(gh_dir, out dir, GH_Conversion.Both); } dir = dir.ToUpper(); if (dir == "X") { direc = Direction.X; } if (dir == "Y") { direc = Direction.Y; } gridlineload.GridLineLoad.Direction = direc; // 4 Axis int axis = 0; gridlineload.GridLineLoad.AxisProperty = 0; GH_Integer gh_ax = new GH_Integer(); if (DA.GetData(4, ref gh_ax)) { GH_Convert.ToInt32(gh_ax, out axis, GH_Conversion.Both); if (axis == 0 || axis == -1) { gridlineload.GridLineLoad.AxisProperty = axis; } } // 5 Projected bool proj = false; GH_Boolean gh_proj = new GH_Boolean(); if (DA.GetData(5, ref gh_proj)) { if (GH_Convert.ToBoolean(gh_proj, out proj, GH_Conversion.Both)) { gridlineload.GridLineLoad.IsProjected = proj; } } // 6 Name string name = ""; GH_String gh_name = new GH_String(); if (DA.GetData(6, ref gh_name)) { if (GH_Convert.ToString(gh_name, out name, GH_Conversion.Both)) { gridlineload.GridLineLoad.Name = name; } } // 7 load value double load1 = 0; if (DA.GetData(7, ref load1)) { load1 *= -1000; //convert to kN } gridlineload.GridLineLoad.ValueAtStart = load1; // 8 load value double load2 = load1; if (DA.GetData(8, ref load2)) { load2 *= -1000; //convert to kN } gridlineload.GridLineLoad.ValueAtEnd = load2; // convert to goo GsaLoad gsaLoad = new GsaLoad(gridlineload); DA.SetData(0, new GsaLoadGoo(gsaLoad)); }
protected override void SolveInstance(IGH_DataAccess DA) { GsaGridPointLoad gridpointload = new GsaGridPointLoad(); // 0 Load case int lc = 1; GH_Integer gh_lc = new GH_Integer(); if (DA.GetData(0, ref gh_lc)) { GH_Convert.ToInt32(gh_lc, out lc, GH_Conversion.Both); } gridpointload.GridPointLoad.Case = lc; // 1 Point Point3d pt = new Point3d(); GH_Point gh_pt = new GH_Point(); if (DA.GetData(1, ref gh_pt)) { GH_Convert.ToPoint3d(gh_pt, ref pt, GH_Conversion.Both); } gridpointload.GridPointLoad.X = pt.X; gridpointload.GridPointLoad.Y = pt.Y; // 2 Plane GsaGridPlaneSurface grdplnsrf; Plane pln = Plane.WorldXY; GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); if (DA.GetData(2, ref gh_typ)) { if (gh_typ.Value is GsaGridPlaneSurfaceGoo) { GsaGridPlaneSurface temppln = new GsaGridPlaneSurface(); gh_typ.CastTo(ref temppln); grdplnsrf = temppln.Duplicate(); gridpointload.GridPlaneSurface = grdplnsrf; } else if (gh_typ.Value is Plane) { gh_typ.CastTo(ref pln); grdplnsrf = new GsaGridPlaneSurface(pln); gridpointload.GridPlaneSurface = grdplnsrf; } else { int id = 0; if (GH_Convert.ToInt32(gh_typ.Value, out id, GH_Conversion.Both)) { gridpointload.GridPointLoad.GridSurface = id; gridpointload.GridPlaneSurface = null; } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Error in GPS input. Accepted inputs are Grid Plane Surface or Plane. " + System.Environment.NewLine + "If no input here then the point's z-coordinate will be used for an xy-plane at that elevation"); return; } } } else { pln = Plane.WorldXY; pln.Origin = pt; grdplnsrf = new GsaGridPlaneSurface(pln); gridpointload.GridPlaneSurface = grdplnsrf; } // 3 direction string dir = "Z"; Direction direc = Direction.Z; GH_String gh_dir = new GH_String(); if (DA.GetData(3, ref gh_dir)) { GH_Convert.ToString(gh_dir, out dir, GH_Conversion.Both); } dir = dir.ToUpper(); if (dir == "X") { direc = Direction.X; } if (dir == "Y") { direc = Direction.Y; } gridpointload.GridPointLoad.Direction = direc; // 4 Axis int axis = 0; gridpointload.GridPointLoad.AxisProperty = 0; GH_Integer gh_ax = new GH_Integer(); if (DA.GetData(4, ref gh_ax)) { GH_Convert.ToInt32(gh_ax, out axis, GH_Conversion.Both); if (axis == 0 || axis == -1) { gridpointload.GridPointLoad.AxisProperty = axis; } } // 5 Name string name = ""; GH_String gh_name = new GH_String(); if (DA.GetData(5, ref gh_name)) { if (GH_Convert.ToString(gh_name, out name, GH_Conversion.Both)) { gridpointload.GridPointLoad.Name = name; } } // 6 load value double load = 0; if (DA.GetData(6, ref load)) { load *= -1000; //convert to kN } gridpointload.GridPointLoad.Value = load; // convert to goo GsaLoad gsaLoad = new GsaLoad(gridpointload); DA.SetData(0, new GsaLoadGoo(gsaLoad)); }