/// <summary> /// Method to convert a list of loads into dictionaries containing GsaAPI objects /// </summary> /// <param name="loads"></param> /// <param name="gravityLoads"></param> /// <param name="nodeLoads_node"></param> /// <param name="nodeLoads_displ"></param> /// <param name="nodeLoads_settle"></param> /// <param name="beamLoads"></param> /// <param name="faceLoads"></param> /// <param name="gridPointLoads"></param> /// <param name="gridLineLoads"></param> /// <param name="gridAreaLoads"></param> /// <param name="existingAxes"></param> /// <param name="existingGridPlanes"></param> /// <param name="existingGridSurfaces"></param> /// <param name="gp_guid"></param> /// <param name="gs_guid"></param> /// <param name="workerInstance"></param> /// <param name="ReportProgress"></param> public static void ConvertLoad(List <GsaLoad> loads, ref List <GravityLoad> gravityLoads, ref List <NodeLoad> nodeLoads_node, ref List <NodeLoad> nodeLoads_displ, ref List <NodeLoad> nodeLoads_settle, ref List <BeamLoad> beamLoads, ref List <FaceLoad> faceLoads, ref List <GridPointLoad> gridPointLoads, ref List <GridLineLoad> gridLineLoads, ref List <GridAreaLoad> gridAreaLoads, ref Dictionary <int, Axis> existingAxes, ref Dictionary <int, GridPlane> existingGridPlanes, ref Dictionary <int, GridSurface> existingGridSurfaces, ref Dictionary <Guid, int> gp_guid, ref Dictionary <Guid, int> gs_guid, GrasshopperAsyncComponent.WorkerInstance workerInstance = null, Action <string, double> ReportProgress = null) { if (loads != null) { if (workerInstance != null) { ReportProgress("Initiating Loads assembly", -2); } // create a counter for creating new axes, gridplanes and gridsurfaces int axisidcounter = (existingAxes.Count > 0) ? existingAxes.Keys.Max() + 1 : 1; int gridplaneidcounter = (existingGridPlanes.Count > 0) ? existingGridPlanes.Keys.Max() + 1 : 1; int gridsurfaceidcounter = (existingGridSurfaces.Count > 0) ? existingGridSurfaces.Keys.Max() + 1 : 1; // get the highest gridplaneID+1 and gridsurfaceID+1 GetGridPlaneSurfaceCounters(loads, ref gridplaneidcounter, ref gridsurfaceidcounter); for (int i = 0; i < loads.Count; i++) { if (workerInstance != null) { if (workerInstance.CancellationToken.IsCancellationRequested) { return; } ReportProgress("Assembling Loads ", (double)i / (loads.Count - 1)); } if (loads[i] != null) { GsaLoad load = loads[i]; ConvertLoad(load, ref gravityLoads, ref nodeLoads_node, ref nodeLoads_displ, ref nodeLoads_settle, ref beamLoads, ref faceLoads, ref gridPointLoads, ref gridLineLoads, ref gridAreaLoads, ref existingAxes, ref axisidcounter, ref existingGridPlanes, ref gridplaneidcounter, ref existingGridSurfaces, ref gridsurfaceidcounter, ref gp_guid, ref gs_guid); } } } if (workerInstance != null) { ReportProgress("Loads assembled", -2); } }
protected override void SolveInstance(IGH_DataAccess DA) { GsaGravityLoad gravityLoad = new GsaGravityLoad(); //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); } gravityLoad.GravityLoad.Case = lc; //element/beam list string beamList = "all"; GH_String gh_bl = new GH_String(); if (DA.GetData(1, ref gh_bl)) { GH_Convert.ToString(gh_bl, out beamList, GH_Conversion.Both); } gravityLoad.GravityLoad.Elements = beamList; // 2 Name string name = ""; GH_String gh_name = new GH_String(); if (DA.GetData(2, ref gh_name)) { if (GH_Convert.ToString(gh_name, out name, GH_Conversion.Both)) { gravityLoad.GravityLoad.Name = name; } } //factor Vector3 factor = new Vector3(); Vector3d vect = new Vector3d(0, 0, -1); GH_Vector gh_factor = new GH_Vector(); if (DA.GetData(3, ref gh_factor)) { GH_Convert.ToVector3d(gh_factor, ref vect, GH_Conversion.Both); } factor.X = vect.X; factor.Y = vect.Y; factor.Z = vect.Z; gravityLoad.GravityLoad.Factor = factor; GsaLoad gsaLoad = new GsaLoad(gravityLoad); DA.SetData(0, new GsaLoadGoo(gsaLoad)); }
/// <summary> /// Method to loop through a list of Loads with GridPlaneSurfaces and return the highest set ID + 1 for gridplan and gridsurface /// </summary> /// <param name="loads"></param> /// <param name="gridplaneidcounter"></param> /// <param name="gridsurfaceidcounter"></param> public static void GetGridPlaneSurfaceCounters(List <GsaLoad> loads, ref int gridplaneidcounter, ref int gridsurfaceidcounter) { for (int i = 0; i < loads.Count; i++) { if (loads[i] != null) { GsaLoad load = loads[i]; if (load.LoadType == GsaLoad.LoadTypes.GridArea) { if (load.AreaLoad.GridPlaneSurface.GridPlaneID > 0) { gridplaneidcounter = Math.Max(gridplaneidcounter, load.AreaLoad.GridPlaneSurface.GridPlaneID + 1); } if (load.AreaLoad.GridPlaneSurface.GridSurfaceID > 0) { gridsurfaceidcounter = Math.Max(gridsurfaceidcounter, load.AreaLoad.GridPlaneSurface.GridSurfaceID + 1); } } if (load.LoadType == GsaLoad.LoadTypes.GridLine) { if (load.PointLoad.GridPlaneSurface.GridPlaneID > 0) { gridplaneidcounter = Math.Max(gridplaneidcounter, load.PointLoad.GridPlaneSurface.GridPlaneID + 1); } if (load.PointLoad.GridPlaneSurface.GridSurfaceID > 0) { gridsurfaceidcounter = Math.Max(gridsurfaceidcounter, load.PointLoad.GridPlaneSurface.GridSurfaceID + 1); } } if (load.LoadType == GsaLoad.LoadTypes.GridLine) { if (load.LineLoad.GridPlaneSurface.GridPlaneID > 0) { gridplaneidcounter = Math.Max(gridplaneidcounter, load.LineLoad.GridPlaneSurface.GridPlaneID + 1); } if (load.LineLoad.GridPlaneSurface.GridSurfaceID > 0) { gridsurfaceidcounter = Math.Max(gridsurfaceidcounter, load.LineLoad.GridPlaneSurface.GridSurfaceID + 1); } } } } }
public void GetLoadsComponentTest() { // ensure model has been opened: if (TestModel == null) { OpenComponentTest(); } // create the component var comp = new GhSA.Components.GetLoads(); comp.CreateAttributes(); // input parameter GsaModelGoo modelGoo = new GsaModelGoo(TestModel); Component.SetInput(comp, modelGoo); //pManager.AddGenericParameter("Gravity Loads", "Grav", "Gravity Loads from GSA Model", GH_ParamAccess.list); //pManager.AddGenericParameter("Node Loads", "Node", "Node Loads from GSA Model", GH_ParamAccess.list); //pManager.AddGenericParameter("Beam Loads", "Beam", "Beam Loads from GSA Model", GH_ParamAccess.list); //pManager.AddGenericParameter("Face Loads", "Face", "Face Loads from GSA Model", GH_ParamAccess.list); //pManager.AddGenericParameter("Grid Point Loads", "Point", "Grid Point Loads from GSA Model", GH_ParamAccess.list); //pManager.AddGenericParameter("Grid Line Loads", "Line", "Grid Line Loads from GSA Model", GH_ParamAccess.list); //pManager.AddGenericParameter("Grid Area Loads", "Area", "Grid Area Loads from GSA Model", GH_ParamAccess.list); //pManager.AddGenericParameter("Grid Plane Surfaces", "GPS", "Grid Plane Surfaces from GSA Model", GH_ParamAccess.list); // get output GsaLoadGoo output20 = (GsaLoadGoo)Component.GetOutput(comp, 2, 0, 0); GsaLoadGoo output21 = (GsaLoadGoo)Component.GetOutput(comp, 2, 0, 1); GsaLoad load1 = output20.Value; GsaLoad load2 = output21.Value; Assert.AreEqual(-10000, load1.BeamLoad.BeamLoad.Value(0)); Assert.AreEqual(BeamLoadType.UNIFORM.ToString(), load1.BeamLoad.BeamLoad.Type.ToString()); Assert.AreEqual(-30000, load2.BeamLoad.BeamLoad.Value(0)); Assert.AreEqual(BeamLoadType.POINT.ToString(), load2.BeamLoad.BeamLoad.Type.ToString()); }
protected override void SolveInstance(IGH_DataAccess DA) { GsaFaceLoad faceLoad = new GsaFaceLoad(); // 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); } faceLoad.FaceLoad.Case = lc; // 1 element/beam list string elemList = ""; GH_String gh_el = new GH_String(); if (DA.GetData(1, ref gh_el)) { GH_Convert.ToString(gh_el, out elemList, GH_Conversion.Both); } //var isNumeric = int.TryParse(elemList, out int n); //if (isNumeric) // elemList = "PA" + n; faceLoad.FaceLoad.Elements = elemList; // 2 Name string name = ""; GH_String gh_name = new GH_String(); if (DA.GetData(2, ref gh_name)) { if (GH_Convert.ToString(gh_name, out name, GH_Conversion.Both)) { faceLoad.FaceLoad.Name = name; } } // 3 axis int axis = -1; faceLoad.FaceLoad.AxisProperty = 0; //Note there is currently a bug/undocumented in GsaAPI that cannot translate an integer into axis type (Global, Local or edformed local) GH_Integer gh_ax = new GH_Integer(); if (DA.GetData(3, ref gh_ax)) { GH_Convert.ToInt32(gh_ax, out axis, GH_Conversion.Both); if (axis == 0 || axis == -1) { faceLoad.FaceLoad.AxisProperty = axis; } } // 4 direction string dir = "Z"; Direction direc = Direction.Z; GH_String gh_dir = new GH_String(); if (DA.GetData(4, ref gh_dir)) { GH_Convert.ToString(gh_dir, out dir, GH_Conversion.Both); } dir = dir.ToUpper().Trim(); if (dir == "X") { direc = Direction.X; } if (dir == "Y") { direc = Direction.Y; } faceLoad.FaceLoad.Direction = direc; switch (_mode) { case FoldMode.Uniform: if (_mode == FoldMode.Uniform) { faceLoad.FaceLoad.Type = FaceLoadType.CONSTANT; //projection bool prj = false; GH_Boolean gh_prj = new GH_Boolean(); if (DA.GetData(5, ref gh_prj)) { GH_Convert.ToBoolean(gh_prj, out prj, GH_Conversion.Both); } faceLoad.FaceLoad.IsProjected = prj; double load1 = 0; if (DA.GetData(6, ref load1)) { if (direc == Direction.Z) { load1 *= -1000; //convert to kN } else { load1 *= 1000; } } // set position and value faceLoad.FaceLoad.SetValue(0, load1); } break; case FoldMode.Variable: if (_mode == FoldMode.Variable) { faceLoad.FaceLoad.Type = FaceLoadType.GENERAL; //projection bool prj = false; GH_Boolean gh_prj = new GH_Boolean(); if (DA.GetData(5, ref gh_prj)) { GH_Convert.ToBoolean(gh_prj, out prj, GH_Conversion.Both); } faceLoad.FaceLoad.IsProjected = prj; double load1 = 0; if (DA.GetData(6, ref load1)) { if (direc == Direction.Z) { load1 *= -1000; //convert to kN } else { load1 *= 1000; } } double load2 = 0; if (DA.GetData(7, ref load2)) { if (direc == Direction.Z) { load2 *= -1000; //convert to kN } else { load2 *= 1000; } } double load3 = 0; if (DA.GetData(8, ref load3)) { if (direc == Direction.Z) { load3 *= -1000; //convert to kN } else { load3 *= 1000; } } double load4 = 0; if (DA.GetData(9, ref load4)) { if (direc == Direction.Z) { load4 *= -1000; //convert to kN } else { load4 *= 1000; } } // set value faceLoad.FaceLoad.SetValue(0, load1); faceLoad.FaceLoad.SetValue(1, load2); faceLoad.FaceLoad.SetValue(2, load3); faceLoad.FaceLoad.SetValue(3, load4); } break; case FoldMode.Point: if (_mode == FoldMode.Point) { faceLoad.FaceLoad.Type = FaceLoadType.POINT; //projection bool prj = false; GH_Boolean gh_prj = new GH_Boolean(); if (DA.GetData(5, ref gh_prj)) { GH_Convert.ToBoolean(gh_prj, out prj, GH_Conversion.Both); } faceLoad.FaceLoad.IsProjected = prj; double load1 = 0; if (DA.GetData(6, ref load1)) { if (direc == Direction.Z) { load1 *= -1000; //convert to kN } else { load1 *= 1000; } } double r = 0; DA.GetData(7, ref r); double s = 0; DA.GetData(8, ref s); // set position and value faceLoad.FaceLoad.SetValue(0, load1); //faceLoad.Position.X = r; //note Vector2 currently only get in GsaAPI //faceLoad.Position.Y = s; } break; case FoldMode.Edge: if (_mode == FoldMode.Edge) { //faceLoad.Type = BeamLoadType.EDGE; GsaAPI implementation missing // get data int edge = 1; DA.GetData(5, ref edge); double load1 = 0; if (DA.GetData(6, ref load1)) { if (direc == Direction.Z) { load1 *= -1000; //convert to kN } else { load1 *= 1000; } } double load2 = 0; if (DA.GetData(7, ref load2)) { if (direc == Direction.Z) { load2 *= -1000; //convert to kN } else { load2 *= 1000; } } // set value faceLoad.FaceLoad.SetValue(0, load1); faceLoad.FaceLoad.SetValue(1, load2); //faceLoad.Edge = edge; //note implementation of edge-load is not yet supported in GsaAPI faceLoad = null; } break; default: throw new ArgumentOutOfRangeException(); } GsaLoad gsaLoad = new GsaLoad(faceLoad); DA.SetData(0, new GsaLoadGoo(gsaLoad)); }
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 }
protected override void SolveInstance(IGH_DataAccess DA) { // Get Loads input GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); if (DA.GetData(0, ref gh_typ)) { GsaLoad gsaload = null; if (gh_typ.Value is GsaLoadGoo) { gh_typ.CastTo(ref gsaload); switch (gsaload.LoadType) { case GsaLoad.LoadTypes.Gravity: DA.SetData(0, gsaload.GravityLoad.GravityLoad.Case); DA.SetData(1, gsaload.GravityLoad.GravityLoad.Name); DA.SetData(2, gsaload.GravityLoad.GravityLoad.Elements); DA.SetData(6, gsaload.GravityLoad.GravityLoad.Factor.X); DA.SetData(7, gsaload.GravityLoad.GravityLoad.Factor.Y); DA.SetData(8, gsaload.GravityLoad.GravityLoad.Factor.Z); return; case GsaLoad.LoadTypes.Node: DA.SetData(0, gsaload.NodeLoad.NodeLoad.Case); DA.SetData(1, gsaload.NodeLoad.NodeLoad.Name); DA.SetData(2, gsaload.NodeLoad.NodeLoad.Nodes); DA.SetData(3, gsaload.NodeLoad.NodeLoad.AxisProperty); DA.SetData(4, gsaload.NodeLoad.NodeLoad.Direction); DA.SetData(6, gsaload.NodeLoad.NodeLoad.Value / 1000); return; case GsaLoad.LoadTypes.Beam: DA.SetData(0, gsaload.BeamLoad.BeamLoad.Case); DA.SetData(1, gsaload.BeamLoad.BeamLoad.Name); DA.SetData(2, gsaload.BeamLoad.BeamLoad.Elements); DA.SetData(3, gsaload.BeamLoad.BeamLoad.AxisProperty); DA.SetData(4, gsaload.BeamLoad.BeamLoad.Direction); DA.SetData(5, gsaload.BeamLoad.BeamLoad.IsProjected); DA.SetData(6, gsaload.BeamLoad.BeamLoad.Value(0) / 1000); DA.SetData(7, gsaload.BeamLoad.BeamLoad.Value(1) / 1000); return; case GsaLoad.LoadTypes.Face: DA.SetData(0, gsaload.FaceLoad.FaceLoad.Case); DA.SetData(1, gsaload.FaceLoad.FaceLoad.Name); DA.SetData(2, gsaload.FaceLoad.FaceLoad.Elements); DA.SetData(3, gsaload.FaceLoad.FaceLoad.AxisProperty); DA.SetData(4, gsaload.FaceLoad.FaceLoad.Direction); DA.SetData(5, gsaload.FaceLoad.FaceLoad.IsProjected); DA.SetData(6, gsaload.FaceLoad.FaceLoad.Value(0) / 1000); DA.SetData(7, gsaload.FaceLoad.FaceLoad.Value(1) / 1000); DA.SetData(8, gsaload.FaceLoad.FaceLoad.Value(2) / 1000); DA.SetData(9, gsaload.FaceLoad.FaceLoad.Value(3) / 1000); return; case GsaLoad.LoadTypes.GridPoint: DA.SetData(0, gsaload.PointLoad.GridPointLoad.Case); DA.SetData(1, gsaload.PointLoad.GridPointLoad.Name); DA.SetData(2, "(" + gsaload.PointLoad.GridPointLoad.X + "," + gsaload.PointLoad.GridPointLoad.Y + ")"); DA.SetData(3, gsaload.PointLoad.GridPointLoad.AxisProperty); DA.SetData(4, gsaload.PointLoad.GridPointLoad.Direction); DA.SetData(6, gsaload.PointLoad.GridPointLoad.Value / 1000); DA.SetData(10, new GsaGridPlaneSurfaceGoo(gsaload.PointLoad.GridPlaneSurface)); return; case GsaLoad.LoadTypes.GridLine: DA.SetData(0, gsaload.LineLoad.GridLineLoad.Case); DA.SetData(1, gsaload.LineLoad.GridLineLoad.Name); DA.SetData(2, gsaload.LineLoad.GridLineLoad.PolyLineDefinition); DA.SetData(3, gsaload.LineLoad.GridLineLoad.AxisProperty); DA.SetData(4, gsaload.LineLoad.GridLineLoad.Direction); DA.SetData(6, gsaload.LineLoad.GridLineLoad.ValueAtStart / 1000); DA.SetData(7, gsaload.LineLoad.GridLineLoad.ValueAtEnd / 1000); DA.SetData(10, new GsaGridPlaneSurfaceGoo(gsaload.LineLoad.GridPlaneSurface)); return; case GsaLoad.LoadTypes.GridArea: DA.SetData(0, gsaload.AreaLoad.GridAreaLoad.Case); DA.SetData(1, gsaload.AreaLoad.GridAreaLoad.Name); DA.SetData(2, gsaload.AreaLoad.GridAreaLoad.PolyLineDefinition); DA.SetData(3, gsaload.AreaLoad.GridAreaLoad.AxisProperty); DA.SetData(4, gsaload.AreaLoad.GridAreaLoad.Direction); DA.SetData(6, gsaload.AreaLoad.GridAreaLoad.Value / 1000); DA.SetData(10, new GsaGridPlaneSurfaceGoo(gsaload.AreaLoad.GridPlaneSurface)); return; } } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Error converting input to GSA Load"); return; } } }
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) { GsaBeamLoad beamLoad = new GsaBeamLoad(); // 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); } beamLoad.BeamLoad.Case = lc; // 1 element/beam list string beamList = ""; //pick an initial name that is sure not to be used... GH_String gh_bl = new GH_String(); if (DA.GetData(1, ref gh_bl)) { GH_Convert.ToString(gh_bl, out beamList, GH_Conversion.Both); } //var isNumeric = int.TryParse(beamList, out int n); //if (isNumeric) // beamList = "PB" + n; beamLoad.BeamLoad.Elements = beamList; // 2 Name string name = ""; GH_String gh_name = new GH_String(); if (DA.GetData(2, ref gh_name)) { if (GH_Convert.ToString(gh_name, out name, GH_Conversion.Both)) { beamLoad.BeamLoad.Name = name; } } // 3 axis int axis = 0; beamLoad.BeamLoad.AxisProperty = 0; //Note there is currently a bug/undocumented in GsaAPI that cannot translate an integer into axis type (Global, Local or edformed local) GH_Integer gh_ax = new GH_Integer(); if (DA.GetData(3, ref gh_ax)) { GH_Convert.ToInt32(gh_ax, out axis, GH_Conversion.Both); if (axis == 0 || axis == -1) { beamLoad.BeamLoad.AxisProperty = axis; } } // 4 direction string dir = "Z"; Direction direc = Direction.Z; GH_String gh_dir = new GH_String(); if (DA.GetData(4, ref gh_dir)) { GH_Convert.ToString(gh_dir, out dir, GH_Conversion.Both); } dir = dir.ToUpper().Trim(); if (dir == "X") { direc = Direction.X; } if (dir == "Y") { direc = Direction.Y; } if (dir == "XX") { direc = Direction.XX; } if (dir == "YY") { direc = Direction.YY; } if (dir == "ZZ") { direc = Direction.ZZ; } beamLoad.BeamLoad.Direction = direc; // 5 projection bool prj = false; GH_Boolean gh_prj = new GH_Boolean(); if (DA.GetData(5, ref gh_prj)) { GH_Convert.ToBoolean(gh_prj, out prj, GH_Conversion.Both); } beamLoad.BeamLoad.IsProjected = prj; // 6 value (1) double load1 = 0; if (DA.GetData(6, ref load1)) { if (direc == Direction.Z) { load1 *= -1000; //convert to kN } else { load1 *= 1000; } } switch (_mode) { case FoldMode.Point: if (_mode == FoldMode.Point) { beamLoad.BeamLoad.Type = BeamLoadType.POINT; // 7 pos (1) double pos = 0; if (DA.GetData(7, ref pos)) { pos *= -1; } // set position and value beamLoad.BeamLoad.SetValue(0, load1); beamLoad.BeamLoad.SetPosition(0, pos); } break; case FoldMode.Uniform: if (_mode == FoldMode.Uniform) { beamLoad.BeamLoad.Type = BeamLoadType.UNIFORM; // set value beamLoad.BeamLoad.SetValue(0, load1); } break; case FoldMode.Linear: if (_mode == FoldMode.Linear) { beamLoad.BeamLoad.Type = BeamLoadType.LINEAR; // 6 value (2) double load2 = 0; if (DA.GetData(7, ref load2)) { if (direc == Direction.Z) { load2 *= -1000; //convert to kN } else { load2 *= 1000; } } // set value beamLoad.BeamLoad.SetValue(0, load1); beamLoad.BeamLoad.SetValue(1, load2); } break; case FoldMode.Patch: if (_mode == FoldMode.Patch) { beamLoad.BeamLoad.Type = BeamLoadType.PATCH; // 7 pos (1) double pos1 = 0; if (DA.GetData(7, ref pos1)) { pos1 *= -1; } // 9 pos (2) double pos2 = 1; if (DA.GetData(9, ref pos2)) { pos2 *= -1; } // 8 value (2) double load2 = 0; if (DA.GetData(8, ref load2)) { if (direc == Direction.Z) { load2 *= -1000; //convert to kN } else { load2 *= 1000; } } // set value beamLoad.BeamLoad.SetValue(0, load1); beamLoad.BeamLoad.SetValue(1, load2); beamLoad.BeamLoad.SetPosition(0, pos1); beamLoad.BeamLoad.SetPosition(1, pos2); } break; case FoldMode.Trilinear: if (_mode == FoldMode.Trilinear) { beamLoad.BeamLoad.Type = BeamLoadType.TRILINEAR; // 7 pos (1) double pos1 = 0; if (DA.GetData(7, ref pos1)) { pos1 *= -1; } // 9 pos (2) double pos2 = 1; if (DA.GetData(9, ref pos2)) { pos2 *= -1; } // 8 value (2) double load2 = 0; if (DA.GetData(8, ref load2)) { if (direc == Direction.Z) { load2 *= -1000; //convert to kN } else { load2 *= 1000; } } // set value beamLoad.BeamLoad.SetValue(0, load1); beamLoad.BeamLoad.SetValue(1, load2); beamLoad.BeamLoad.SetPosition(0, pos1); beamLoad.BeamLoad.SetPosition(1, pos2); } break; default: throw new ArgumentOutOfRangeException(); } GsaLoad gsaLoad = new GsaLoad(beamLoad); DA.SetData(0, new GsaLoadGoo(gsaLoad)); }
/// <summary> /// Method to convert a single of loads into dictionaries containing GsaAPI objects. Maintains the referenced dictionaries and counters. /// </summary> /// <param name="load"></param> /// <param name="gravityLoads"></param> /// <param name="nodeLoads_node"></param> /// <param name="nodeLoads_displ"></param> /// <param name="nodeLoads_settle"></param> /// <param name="beamLoads"></param> /// <param name="faceLoads"></param> /// <param name="gridPointLoads"></param> /// <param name="gridLineLoads"></param> /// <param name="gridAreaLoads"></param> /// <param name="existingAxes"></param> /// <param name="axisidcounter"></param> /// <param name="existingGridPlanes"></param> /// <param name="gridplaneidcounter"></param> /// <param name="existingGridSurfaces"></param> /// <param name="gridsurfaceidcounter"></param> /// <param name="gp_guid"></param> /// <param name="gs_guid"></param> public static void ConvertLoad(GsaLoad load, ref List <GravityLoad> gravityLoads, ref List <NodeLoad> nodeLoads_node, ref List <NodeLoad> nodeLoads_displ, ref List <NodeLoad> nodeLoads_settle, ref List <BeamLoad> beamLoads, ref List <FaceLoad> faceLoads, ref List <GridPointLoad> gridPointLoads, ref List <GridLineLoad> gridLineLoads, ref List <GridAreaLoad> gridAreaLoads, ref Dictionary <int, Axis> existingAxes, ref int axisidcounter, ref Dictionary <int, GridPlane> existingGridPlanes, ref int gridplaneidcounter, ref Dictionary <int, GridSurface> existingGridSurfaces, ref int gridsurfaceidcounter, ref Dictionary <Guid, int> gp_guid, ref Dictionary <Guid, int> gs_guid) { switch (load.LoadType) { case GsaLoad.LoadTypes.Gravity: gravityLoads.Add(load.GravityLoad.GravityLoad); break; case GsaLoad.LoadTypes.Node: if (load.NodeLoad.NodeLoadType == GsaNodeLoad.NodeLoadTypes.APPLIED_DISP) { nodeLoads_displ.Add(load.NodeLoad.NodeLoad); } if (load.NodeLoad.NodeLoadType == GsaNodeLoad.NodeLoadTypes.NODE_LOAD) { nodeLoads_node.Add(load.NodeLoad.NodeLoad); } if (load.NodeLoad.NodeLoadType == GsaNodeLoad.NodeLoadTypes.SETTLEMENT) { nodeLoads_settle.Add(load.NodeLoad.NodeLoad); } break; case GsaLoad.LoadTypes.Beam: beamLoads.Add(load.BeamLoad.BeamLoad); break; case GsaLoad.LoadTypes.Face: faceLoads.Add(load.FaceLoad.FaceLoad); break; case GsaLoad.LoadTypes.GridPoint: if (load.PointLoad.GridPlaneSurface == null) // if gridsurface id has been set { // add the load to our list of loads to be set later gridPointLoads.Add(load.PointLoad.GridPointLoad); break; } // set grid point load and grid plane surface GsaGridPointLoad gridptref = load.PointLoad; GsaGridPlaneSurface gridplnsrf = gridptref.GridPlaneSurface; if (gridplnsrf.GridPlane != null) { // - grid load references a grid surface number // -- grid surface references a grid plane number // --- grid plane references an Axis number // toggle through the members in reverse order, set/add to model in each step // ### AXIS ### // set axis property in grid plane, add/set axis in model gridplnsrf.GridPlane.AxisProperty = SetAxis(ref gridplnsrf, ref existingAxes, ref axisidcounter); // ### GRID PLANE ### // set grid plane number in grid surface, add/set grid plane in model gridplnsrf.GridSurface.GridPlane = SetGridPlane(ref gridplnsrf, ref existingGridPlanes, ref gridplaneidcounter, ref gp_guid, existingAxes); // ### GRID SURFACE ### // set the surface number in the load, add/set the surface in the model gridptref.GridPointLoad.GridSurface = SetGridSurface(ref gridplnsrf, ref existingGridSurfaces, ref gridsurfaceidcounter, ref gs_guid, existingGridPlanes, existingAxes); } // add the load to our list of loads to be set later gridPointLoads.Add(gridptref.GridPointLoad); break; case GsaLoad.LoadTypes.GridLine: if (load.LineLoad.GridPlaneSurface == null) // if gridsurface id has been set { // add the load to our list of loads to be set later gridLineLoads.Add(load.LineLoad.GridLineLoad); break; } // set grid line load and grid plane surface GsaGridLineLoad gridlnref = load.LineLoad; gridplnsrf = gridlnref.GridPlaneSurface; if (gridplnsrf.GridPlane != null) { // - grid load references a grid surface number // -- grid surface references a grid plane number // --- grid plane references an Axis number // toggle through the members in reverse order, set/add to model in each step // ### AXIS ### // set axis property in grid plane, add/set axis in model gridplnsrf.GridPlane.AxisProperty = SetAxis(ref gridplnsrf, ref existingAxes, ref axisidcounter); // ### GRID PLANE ### // set grid plane number in grid surface, add/set grid plane in model gridplnsrf.GridSurface.GridPlane = SetGridPlane(ref gridplnsrf, ref existingGridPlanes, ref gridplaneidcounter, ref gp_guid, existingAxes); // ### GRID SURFACE ### // set the surface number in the load, add/set the surface in the model gridlnref.GridLineLoad.GridSurface = SetGridSurface(ref gridplnsrf, ref existingGridSurfaces, ref gridsurfaceidcounter, ref gs_guid, existingGridPlanes, existingAxes); } // add the load to our list of loads to be set later gridLineLoads.Add(gridlnref.GridLineLoad); break; case GsaLoad.LoadTypes.GridArea: if (load.AreaLoad.GridPlaneSurface == null) // if gridsurface id has been set { // add the load to our list of loads to be set later gridAreaLoads.Add(load.AreaLoad.GridAreaLoad); break; } // set grid line load and grid plane surface GsaGridAreaLoad gridarref = load.AreaLoad; gridplnsrf = gridarref.GridPlaneSurface; if (gridplnsrf.GridPlane != null) { // - grid load references a grid surface number // -- grid surface references a grid plane number // --- grid plane references an Axis number // toggle through the members in reverse order, set/add to model in each step // ### AXIS ### // set axis property in grid plane, add/set axis in model gridplnsrf.GridPlane.AxisProperty = SetAxis(ref gridplnsrf, ref existingAxes, ref axisidcounter); // ### GRID PLANE ### // set grid plane number in grid surface, add/set grid plane in model gridplnsrf.GridSurface.GridPlane = SetGridPlane(ref gridplnsrf, ref existingGridPlanes, ref gridplaneidcounter, ref gp_guid, existingAxes); // ### GRID SURFACE ### // set the surface number in the load, add/set the surface in the model gridarref.GridAreaLoad.GridSurface = SetGridSurface(ref gridplnsrf, ref existingGridSurfaces, ref gridsurfaceidcounter, ref gs_guid, existingGridPlanes, existingAxes); } // add the load to our list of loads to be set later gridAreaLoads.Add(gridarref.GridAreaLoad); break; } }
protected override void SolveInstance(IGH_DataAccess DA) { GsaNodeLoad nodeLoad = new GsaNodeLoad(); // Node load type switch (_mode) { case FoldMode.Node: nodeLoad.NodeLoadType = GsaNodeLoad.NodeLoadTypes.NODE_LOAD; break; case FoldMode.Applied_Displ: nodeLoad.NodeLoadType = GsaNodeLoad.NodeLoadTypes.APPLIED_DISP; break; case FoldMode.Settlements: nodeLoad.NodeLoadType = GsaNodeLoad.NodeLoadTypes.SETTLEMENT; break; } // 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); } nodeLoad.NodeLoad.Case = lc; // 1 element/beam list string nodeList = "all"; GH_String gh_nl = new GH_String(); if (DA.GetData(1, ref gh_nl)) { GH_Convert.ToString(gh_nl, out nodeList, GH_Conversion.Both); } nodeLoad.NodeLoad.Nodes = nodeList; // 3 Name string name = ""; GH_String gh_name = new GH_String(); if (DA.GetData(3, ref gh_name)) { if (GH_Convert.ToString(gh_name, out name, GH_Conversion.Both)) { nodeLoad.NodeLoad.Name = name; } } // 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().Trim(); if (dir == "X") { direc = Direction.X; } if (dir == "Y") { direc = Direction.Y; } if (dir == "XX") { direc = Direction.XX; } if (dir == "YY") { direc = Direction.YY; } if (dir == "ZZ") { direc = Direction.ZZ; } nodeLoad.NodeLoad.Direction = direc; double load = 0; if (DA.GetData(4, ref load)) { if (direc == Direction.Z) { load *= -1000; //convert to kN } else { load *= 1000; } } nodeLoad.NodeLoad.Value = load; GsaLoad gsaLoad = new GsaLoad(nodeLoad); DA.SetData(0, new GsaLoadGoo(gsaLoad)); }
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)); }