Skip to content

Commit

Permalink
Merge pull request #215 from arup-group/feature/GSAGH-150-node-damp-m…
Browse files Browse the repository at this point in the history
…ass-spring-prop

gsagh-150 node damp mass spring prop
  • Loading branch information
kpne authored Nov 24, 2022
2 parents 66f6eef + df91b44 commit 07a8cde
Show file tree
Hide file tree
Showing 8 changed files with 596 additions and 42 deletions.
Binary file modified ExampleFiles/Parameters/2_Geometry/GetGeometry_TrGen_10.gh
Binary file not shown.
8 changes: 6 additions & 2 deletions GsaGH/Components/2_Geometry/EditElement1d.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Parameters;
using Grasshopper.Kernel.Types;
using GsaAPI;
Expand Down Expand Up @@ -95,7 +97,7 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager)
pManager.AddColourParameter("Colour", "Co", "Get Element Colour", GH_ParamAccess.item);
pManager.AddBooleanParameter("Dummy Element", "Dm", "Get if Element is Dummy", GH_ParamAccess.item);
pManager.AddIntegerParameter("Parent Members", "pM", "Get Parent Member IDs in Model that Element was created from", GH_ParamAccess.list);
pManager.AddIntegerParameter("Topology", "Tp", "Get the Element's original topology list referencing node IDs in Model that Element was created from", GH_ParamAccess.list);
pManager.AddIntegerParameter("Topology", "Tp", "Get the Element's original topology list referencing node IDs in Model that Element was created from", GH_ParamAccess.tree);
}
#endregion

Expand Down Expand Up @@ -279,7 +281,9 @@ protected override void SolveInstance(IGH_DataAccess DA)
DA.SetData(13, elem.IsDummy);

try { DA.SetData(14, elem.ParentMember); } catch (Exception) { }
DA.SetDataList(15, new Collection<int>(elem.API_Element.Topology));
DataTree<int> topo = new DataTree<int>();
topo.AddRange(elem.API_Element.Topology, new GH_Path(elem.Id));
DA.SetDataTree(15, topo);
}
}
}
Expand Down
97 changes: 57 additions & 40 deletions GsaGH/Components/2_Geometry/EditNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace GsaGH.Components
public class EditNode : GH_OasysComponent, IGH_PreviewObject, IGH_VariableParameterComponent
{
#region Name and Ribbon Layout
public override Guid ComponentGuid => new Guid("de176ec0-0516-4634-8f04-82017e502e1e");
public override Guid ComponentGuid => new Guid("418e222d-16b8-4a8e-bb3d-98ad72b913d8");
public override GH_Exposure Exposure => GH_Exposure.secondary | GH_Exposure.obscure;
public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance;
protected override System.Drawing.Bitmap Icon => GsaGH.Properties.Resources.EditNode;
Expand All @@ -38,6 +38,9 @@ protected override void RegisterInputParams(GH_InputParamManager pManager)
pManager.AddPointParameter("Node Position", "Pt", "Set new Position (x, y, z) of Node", GH_ParamAccess.item);
pManager.AddPlaneParameter("Node local axis", "Pl", "Set Local axis (Plane) of Node", GH_ParamAccess.item);
pManager.AddParameter(new GsaBool6Parameter(), "Node Restraints", "B6", "Set Restraints (Bool6) of Node", GH_ParamAccess.item);
pManager.AddIntegerParameter("Damper Property", "DP", "Set Damper Property by reference", GH_ParamAccess.item);
pManager.AddIntegerParameter("Mass Property", "MP", "Set Mass Property by reference", GH_ParamAccess.item);
pManager.AddIntegerParameter("Spring Property", "SP", "Set Spring Property by reference", GH_ParamAccess.item);
pManager.AddTextParameter("Node Name", "Na", "Set Name of Node", GH_ParamAccess.item);
pManager.AddColourParameter("Node Colour", "Co", "Set colour of node", GH_ParamAccess.item);

Expand All @@ -58,6 +61,9 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager)
pManager.AddPlaneParameter("Node local axis", "Pl", "Local axis (Plane) of Node", GH_ParamAccess.item);
pManager.HideParameter(3);
pManager.AddParameter(new GsaBool6Parameter(), "Node Restraints", "B6", "Restraints (Bool6) of Node", GH_ParamAccess.item);
pManager.AddIntegerParameter("Damper Property", "DP", "Get Damper Property reference", GH_ParamAccess.item);
pManager.AddIntegerParameter("Mass Property", "MP", "Get Mass Property reference", GH_ParamAccess.item);
pManager.AddIntegerParameter("Spring Property", "SP", "Get Spring Property reference", GH_ParamAccess.item);
pManager.AddTextParameter("Node Name", "Na", "Name of Node", GH_ParamAccess.item);
pManager.AddColourParameter("Node Colour", "Co", "Get colour of node", GH_ParamAccess.item);
if (_mode == FoldMode.GetConnected)
Expand Down Expand Up @@ -127,7 +133,6 @@ protected override void SolveInstance(IGH_DataAccess DA)
Plane pln = new Plane();
if (GH_Convert.ToPlane(ghPln, ref pln, GH_Conversion.Both))
{
pln.Origin = node.Point;
node.LocalAxis = pln;
}
}
Expand All @@ -139,17 +144,41 @@ protected override void SolveInstance(IGH_DataAccess DA)
node.Restraint = restraint;
}

// 5 Name
// 5 Damper Property
ghInt = new GH_Integer();
if (DA.GetData(5, ref ghInt))
{
if (GH_Convert.ToInt32(ghInt, out int prop, GH_Conversion.Both))
node.DamperProperty = prop;
}

// 6 Mass Property
ghInt = new GH_Integer();
if (DA.GetData(6, ref ghInt))
{
if (GH_Convert.ToInt32(ghInt, out int prop, GH_Conversion.Both))
node.MassProperty = prop;
}

// 7 Spring Property
ghInt = new GH_Integer();
if (DA.GetData(7, ref ghInt))
{
if (GH_Convert.ToInt32(ghInt, out int prop, GH_Conversion.Both))
node.SpringProperty = prop;
}

// 8 Name
GH_String ghStr = new GH_String();
if (DA.GetData(5, ref ghStr))
if (DA.GetData(8, ref ghStr))
{
if (GH_Convert.ToString(ghStr, out string name, GH_Conversion.Both))
node.Name = name;
}

// 6 Colour
// 9 Colour
GH_Colour ghcol = new GH_Colour();
if (DA.GetData(6, ref ghcol))
if (DA.GetData(9, ref ghcol))
{
if (GH_Convert.ToColor(ghcol, out System.Drawing.Color col, GH_Conversion.Both))
node.Colour = col;
Expand All @@ -161,21 +190,24 @@ protected override void SolveInstance(IGH_DataAccess DA)
DA.SetData(2, node.Point);
DA.SetData(3, new GH_Plane(node.LocalAxis));
DA.SetData(4, new GsaBool6Goo(node.Restraint));
DA.SetData(5, node.ApiNode.Name.ToString());
DA.SetData(6, node.Colour);
DA.SetData(5, node.DamperProperty);
DA.SetData(6, node.MassProperty);
DA.SetData(7, node.SpringProperty);
DA.SetData(8, node.ApiNode.Name.ToString());
DA.SetData(9, node.Colour);

// only get connected elements/members if enabled (computationally expensive)
if (_mode == FoldMode.GetConnected)
{
try
{
DA.SetDataList(7, node.ApiNode.ConnectedElements);
DA.SetDataList(10, node.ApiNode.ConnectedElements);
}
catch (Exception) { }

try
{
DA.SetDataList(8, node.ApiNode.ConnectedMembers);
DA.SetDataList(11, node.ApiNode.ConnectedMembers);
}
catch (Exception) { }
}
Expand Down Expand Up @@ -205,8 +237,8 @@ private void FlipMode(object sender, EventArgs e)
_mode = FoldMode.DoNotGetConnected;

//remove input parameters
while (Params.Output.Count > 8)
Params.UnregisterOutputParameter(Params.Output[8], true);
while (Params.Output.Count > 10)
Params.UnregisterOutputParameter(Params.Output[10], true);
}
else
{
Expand Down Expand Up @@ -242,38 +274,23 @@ public void VariableParameterMaintenance()
{
if (_mode == FoldMode.GetConnected)
{
Params.Output[8].NickName = "El";
Params.Output[8].Name = "Connected Elements";
Params.Output[8].Description = "Connected Element IDs in Model that Node once belonged to";
Params.Output[8].Access = GH_ParamAccess.list;

Params.Output[9].NickName = "Me";
Params.Output[9].Name = "Connected Members";
Params.Output[9].Description = "Connected Member IDs in Model that Node once belonged to";
Params.Output[9].Access = GH_ParamAccess.list;
Params.Output[10].NickName = "El";
Params.Output[10].Name = "Connected Elements";
Params.Output[10].Description = "Connected Element IDs in Model that Node once belonged to";
Params.Output[10].Access = GH_ParamAccess.list;

Params.Output[11].NickName = "Me";
Params.Output[11].Name = "Connected Members";
Params.Output[11].Description = "Connected Member IDs in Model that Node once belonged to";
Params.Output[11].Access = GH_ParamAccess.list;
}
}

#region IGH_variable parameter null implementation
public bool CanInsertParameter(GH_ParameterSide side, int index)
{
return false;
}

public bool CanRemoveParameter(GH_ParameterSide side, int index)
{
return false;
}

public IGH_Param CreateParameter(GH_ParameterSide side, int index)
{
return null;
}

public bool DestroyParameter(GH_ParameterSide side, int index)
{
return false;
}
public bool CanInsertParameter(GH_ParameterSide side, int index) => false;
public bool CanRemoveParameter(GH_ParameterSide side, int index) => false;
public IGH_Param CreateParameter(GH_ParameterSide side, int index) => null;
public bool DestroyParameter(GH_ParameterSide side, int index) => false;
#endregion
}
}
Expand Down
Loading

0 comments on commit 07a8cde

Please sign in to comment.