diff --git a/DocsGeneration/MarkDowns/Components.cs b/DocsGeneration/MarkDowns/Components.cs index c1560e67a..567309e0f 100644 --- a/DocsGeneration/MarkDowns/Components.cs +++ b/DocsGeneration/MarkDowns/Components.cs @@ -8,15 +8,6 @@ namespace DocsGeneration.MarkDowns { public class Components { - public static readonly string ComponentsOverview = - "# Components\n" + - "\n" + - ":::caution" + - "\nGSA-Grasshopper plugin is pre-release and under active development, including further testing to be undertaken. It is provided \\\"as-is\\\" and you bear the risk of using it. Future versions may contain breaking changes. Any files, results, or other types of output information created using the plugin should not be relied upon without thorough and independent checking.\n:::\n" + - "\n" + - "![GsaGH-Ribbon](./images/RibbonLayout.gif)\n" + - "\n"; - public static void CreateOverview( Dictionary> components, List parameters) { CreateComponentOverview(components.Keys.ToList()); @@ -165,7 +156,13 @@ private static void CreateComponentOverview(List categories) { string filePath = $@"Output\gsagh-components.md"; Console.WriteLine($"Writing {filePath}"); - string text = ComponentsOverview; + string text = "# Components\n\n"; + if (GsaGH.GsaGhInfo.isBeta) { + text += StringHelper.AddBetaWarning(); + text += "\n"; + } + + text += "![GsaGH-Ribbon](./images/RibbonLayout.gif)\n\n"; foreach (string category in categories) { text += $"[{category} components](gsagh-{category.ToLower()}-components-overview.md)\n\n"; diff --git a/ExampleFiles/Components/Annotate.gh b/ExampleFiles/Components/Annotate.gh index 8c4592771..6c43aa476 100644 Binary files a/ExampleFiles/Components/Annotate.gh and b/ExampleFiles/Components/Annotate.gh differ diff --git a/ExampleFiles/Components/AssembleWithIDsTestIdSequence.gh b/ExampleFiles/Components/AssembleWithIDsTestIdSequence.gh index ff467d6ca..67fc5393f 100644 Binary files a/ExampleFiles/Components/AssembleWithIDsTestIdSequence.gh and b/ExampleFiles/Components/AssembleWithIDsTestIdSequence.gh differ diff --git a/ExampleFiles/Components/CreateEdit3dPropElemAndMem.gh b/ExampleFiles/Components/CreateEdit3dPropElemAndMem.gh index 9eff9174c..7fb26af1e 100644 Binary files a/ExampleFiles/Components/CreateEdit3dPropElemAndMem.gh and b/ExampleFiles/Components/CreateEdit3dPropElemAndMem.gh differ diff --git a/ExampleFiles/Components/Elem2dResults.gh b/ExampleFiles/Components/Elem2dResults.gh index 85b59f617..e35ad2e54 100644 Binary files a/ExampleFiles/Components/Elem2dResults.gh and b/ExampleFiles/Components/Elem2dResults.gh differ diff --git a/ExampleFiles/Components/GridLoadPolyline.gh b/ExampleFiles/Components/GridLoadPolyline.gh index 416477aee..186e7d3b8 100644 Binary files a/ExampleFiles/Components/GridLoadPolyline.gh and b/ExampleFiles/Components/GridLoadPolyline.gh differ diff --git a/ExampleFiles/Components/LoadsFromReferenceObjects.gh b/ExampleFiles/Components/LoadsFromReferenceObjects.gh index 4df1b865f..c8c456c5b 100644 Binary files a/ExampleFiles/Components/LoadsFromReferenceObjects.gh and b/ExampleFiles/Components/LoadsFromReferenceObjects.gh differ diff --git a/ExampleFiles/Components/NodeLocalAxisReactionForceDiagram.gh b/ExampleFiles/Components/NodeLocalAxisReactionForceDiagram.gh index 93e92fa6c..ea15448cb 100644 Binary files a/ExampleFiles/Components/NodeLocalAxisReactionForceDiagram.gh and b/ExampleFiles/Components/NodeLocalAxisReactionForceDiagram.gh differ diff --git a/ExampleFiles/Components/NodeReactionForceResult.gh b/ExampleFiles/Components/NodeReactionForceResult.gh index 27c96635c..ddff1edf3 100644 Binary files a/ExampleFiles/Components/NodeReactionForceResult.gh and b/ExampleFiles/Components/NodeReactionForceResult.gh differ diff --git a/ExampleFiles/Components/NodeResults.gh b/ExampleFiles/Components/NodeResults.gh index 46b7c185a..232c7f9b5 100644 Binary files a/ExampleFiles/Components/NodeResults.gh and b/ExampleFiles/Components/NodeResults.gh differ diff --git a/ExampleFiles/Components/Prop2dAxis.gh b/ExampleFiles/Components/Prop2dAxis.gh index 5539052ed..2515e8751 100644 Binary files a/ExampleFiles/Components/Prop2dAxis.gh and b/ExampleFiles/Components/Prop2dAxis.gh differ diff --git a/ExampleFiles/Components/ReactionForceDiagrams.gh b/ExampleFiles/Components/ReactionForceDiagrams.gh index 96675d1ac..89bfaf34e 100644 Binary files a/ExampleFiles/Components/ReactionForceDiagrams.gh and b/ExampleFiles/Components/ReactionForceDiagrams.gh differ diff --git a/ExampleFiles/Components/SectionAlignment.gh b/ExampleFiles/Components/SectionAlignment.gh index d5e4517b7..6fe2b30ea 100644 Binary files a/ExampleFiles/Components/SectionAlignment.gh and b/ExampleFiles/Components/SectionAlignment.gh differ diff --git a/ExampleFiles/GsaGH_Example1_GerberMember.gh b/ExampleFiles/GsaGH_Example1_GerberMember.gh index e65ace4d1..8e19c1656 100644 Binary files a/ExampleFiles/GsaGH_Example1_GerberMember.gh and b/ExampleFiles/GsaGH_Example1_GerberMember.gh differ diff --git a/ExampleFiles/GsaGH_Example2_Reciprocal.gh b/ExampleFiles/GsaGH_Example2_Reciprocal.gh index 0492bf9d2..08578d8dd 100644 Binary files a/ExampleFiles/GsaGH_Example2_Reciprocal.gh and b/ExampleFiles/GsaGH_Example2_Reciprocal.gh differ diff --git a/ExampleFiles/GsaGH_Example3_Truss.gh b/ExampleFiles/GsaGH_Example3_Truss.gh index 67fad707f..c9d57c042 100644 Binary files a/ExampleFiles/GsaGH_Example3_Truss.gh and b/ExampleFiles/GsaGH_Example3_Truss.gh differ diff --git a/ExampleFiles/GsaGH_Example4_ReMeshing.gh b/ExampleFiles/GsaGH_Example4_ReMeshing.gh index 3ae5c8c97..6f2911711 100644 Binary files a/ExampleFiles/GsaGH_Example4_ReMeshing.gh and b/ExampleFiles/GsaGH_Example4_ReMeshing.gh differ diff --git a/ExampleFiles/GsaGH_Example5_4PointSrfMidSupport.gh b/ExampleFiles/GsaGH_Example5_4PointSrfMidSupport.gh index 76c89bef4..5759ba9fa 100644 Binary files a/ExampleFiles/GsaGH_Example5_4PointSrfMidSupport.gh and b/ExampleFiles/GsaGH_Example5_4PointSrfMidSupport.gh differ diff --git a/ExampleFiles/GsaGH_Example6_3dBoxes.gh b/ExampleFiles/GsaGH_Example6_3dBoxes.gh index 15c6323f3..14dbbcff7 100644 Binary files a/ExampleFiles/GsaGH_Example6_3dBoxes.gh and b/ExampleFiles/GsaGH_Example6_3dBoxes.gh differ diff --git a/ExampleFiles/Parameters/0_Model/GsaList_Nodes.gh b/ExampleFiles/Parameters/0_Model/GsaList_Nodes.gh index c74d23192..7ef06b1bb 100644 Binary files a/ExampleFiles/Parameters/0_Model/GsaList_Nodes.gh and b/ExampleFiles/Parameters/0_Model/GsaList_Nodes.gh differ diff --git a/ExampleFiles/Parameters/0_Model/GsaList_Properties.gh b/ExampleFiles/Parameters/0_Model/GsaList_Properties.gh index 1a8d3bba4..9711cafe4 100644 Binary files a/ExampleFiles/Parameters/0_Model/GsaList_Properties.gh and b/ExampleFiles/Parameters/0_Model/GsaList_Properties.gh differ diff --git a/ExampleFiles/Parameters/1_Properties/CreateProfile.gh b/ExampleFiles/Parameters/1_Properties/CreateProfile.gh index 45075d507..269b706ae 100644 Binary files a/ExampleFiles/Parameters/1_Properties/CreateProfile.gh and b/ExampleFiles/Parameters/1_Properties/CreateProfile.gh differ diff --git a/ExampleFiles/Parameters/1_Properties/GetProperties_TrGen_10.gh b/ExampleFiles/Parameters/1_Properties/GetProperties_TrGen_10.gh index b2a5da358..f781c3701 100644 Binary files a/ExampleFiles/Parameters/1_Properties/GetProperties_TrGen_10.gh and b/ExampleFiles/Parameters/1_Properties/GetProperties_TrGen_10.gh differ diff --git a/ExampleFiles/Parameters/1_Properties/Materials.gh b/ExampleFiles/Parameters/1_Properties/Materials.gh index eddbb04fc..ee5293ee7 100644 Binary files a/ExampleFiles/Parameters/1_Properties/Materials.gh and b/ExampleFiles/Parameters/1_Properties/Materials.gh differ diff --git a/ExampleFiles/Parameters/3_Loads/GridPlaneSurface.gh b/ExampleFiles/Parameters/3_Loads/GridPlaneSurface.gh index 303ee5458..daf0668d9 100644 Binary files a/ExampleFiles/Parameters/3_Loads/GridPlaneSurface.gh and b/ExampleFiles/Parameters/3_Loads/GridPlaneSurface.gh differ diff --git a/ExampleFiles/Parameters/4_Analysis/GetCreateAnalysisTaskAndCase.gh b/ExampleFiles/Parameters/4_Analysis/GetCreateAnalysisTaskAndCase.gh index 0a1aa33f4..4a346ae19 100644 Binary files a/ExampleFiles/Parameters/4_Analysis/GetCreateAnalysisTaskAndCase.gh and b/ExampleFiles/Parameters/4_Analysis/GetCreateAnalysisTaskAndCase.gh differ diff --git a/GsaGH/Components/0_Model/CreateModel.cs b/GsaGH/Components/0_Model/CreateModel.cs index 59e6bb28e..f6f6ac282 100644 --- a/GsaGH/Components/0_Model/CreateModel.cs +++ b/GsaGH/Components/0_Model/CreateModel.cs @@ -4,7 +4,6 @@ using System.Windows.Forms; using GH_IO.Serialization; using Grasshopper.Kernel; -using GsaGH.Components.GraveyardComp; using GsaGH.Helpers; using GsaGH.Helpers.Assembly; using GsaGH.Helpers.GH; diff --git a/GsaGH/Components/1_Properties/Create2dProperty.cs b/GsaGH/Components/1_Properties/Create2dProperty.cs index 90bcc4f5d..c0df28d21 100644 --- a/GsaGH/Components/1_Properties/Create2dProperty.cs +++ b/GsaGH/Components/1_Properties/Create2dProperty.cs @@ -14,6 +14,7 @@ using OasysGH; using OasysGH.Components; using OasysGH.Helpers; +using OasysGH.Parameters; using OasysGH.Units; using OasysGH.Units.Helpers; using OasysUnits; @@ -51,7 +52,7 @@ private readonly IReadOnlyDictionary _supportDropDown private Prop2dType _mode = Prop2dType.Shell; private int _supportTypeIndex; - public Create2dProperty() : base("Create 2D Property", "Prop2d", "Create a GSA Property 2D", + public Create2dProperty() : base("Create 2D Property", "Prop2d", "Create a GSA 2D Property", CategoryName.Name(), SubCategoryName.Cat1()) { Hidden = true; } diff --git a/GsaGH/Components/1_Properties/Create3dProperty.cs b/GsaGH/Components/1_Properties/Create3dProperty.cs index 78bef792e..04ec829c8 100644 --- a/GsaGH/Components/1_Properties/Create3dProperty.cs +++ b/GsaGH/Components/1_Properties/Create3dProperty.cs @@ -17,7 +17,7 @@ public class Create3dProperty : GH_OasysComponent { public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; protected override Bitmap Icon => Resources.Create3dProperty; - public Create3dProperty() : base("Create 3D Property", "Prop3d", "Create GSA Property 3D", + public Create3dProperty() : base("Create 3D Property", "Prop3d", "Create GSA 3D Property", CategoryName.Name(), SubCategoryName.Cat1()) { Hidden = true; } diff --git a/GsaGH/Components/1_Properties/Edit3dProperty.cs b/GsaGH/Components/1_Properties/Edit3dProperty.cs index d7d32aeca..d31d762c6 100644 --- a/GsaGH/Components/1_Properties/Edit3dProperty.cs +++ b/GsaGH/Components/1_Properties/Edit3dProperty.cs @@ -17,7 +17,7 @@ public class Edit3dProperty : GH_OasysComponent { public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; protected override Bitmap Icon => Resources.Edit3dProperty; - public Edit3dProperty() : base("Edit 3D Property", "EditPV", "Modify a GSA Property 3D", + public Edit3dProperty() : base("Edit 3D Property", "EditPV", "Modify a GSA 3D Property", CategoryName.Name(), SubCategoryName.Cat1()) { Hidden = true; } diff --git a/GsaGH/Components/2_Geometry/Create2dElementsFromBrep.cs b/GsaGH/Components/2_Geometry/Create2dElementsFromBrep.cs index 3e2b7e73a..41b26af46 100644 --- a/GsaGH/Components/2_Geometry/Create2dElementsFromBrep.cs +++ b/GsaGH/Components/2_Geometry/Create2dElementsFromBrep.cs @@ -7,7 +7,6 @@ using Grasshopper.Kernel; using Grasshopper.Kernel.Types; using GsaAPI; -using GsaGH.Components.GraveyardComp; using GsaGH.Helpers.GH; using GsaGH.Parameters; using GsaGH.Properties; @@ -27,12 +26,12 @@ namespace GsaGH.Components { /// public class Create2dElementsFromBrep : GH_OasysDropDownComponent { public override Guid ComponentGuid => new Guid("18c5913e-cbce-42e8-8563-18e28b079d34"); - public override GH_Exposure Exposure => GH_Exposure.quarternary; + public override GH_Exposure Exposure => GH_Exposure.quarternary | GH_Exposure.obscure; public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; protected override Bitmap Icon => Resources.Create2dElementsFromBrep; private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; internal ToleranceContextMenu ToleranceMenu { get; set; } = new ToleranceContextMenu(); - private List _meshMode = new List() { + private readonly List _meshMode = new List() { "Tri-6 only", "Planar Quads", "Quad-8 only" diff --git a/GsaGH/Components/GraveyardComp/BeamDisplacement_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/BeamDisplacement_OBSOLETE.cs deleted file mode 100644 index 78930b216..000000000 --- a/GsaGH/Components/GraveyardComp/BeamDisplacement_OBSOLETE.cs +++ /dev/null @@ -1,238 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Threading.Tasks; -using Grasshopper; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Data; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; - -namespace GsaGH.Components { - /// - /// Component to get GSA beam displacement values - /// - public class BeamDisplacement_OBSOLETE : GH_OasysDropDownComponent { - public override Guid ComponentGuid => new Guid("21ec9005-1b2f-4eb8-8171-b2c0190a4a54"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.BeamDisplacements; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitResult; - - public BeamDisplacement_OBSOLETE() : base("Beam Displacements", "BeamDisp", - "Element1D Translation and Rotation result values", CategoryName.Name(), - SubCategoryName.Cat5()) { - Hidden = true; - } - - public override void SetSelected(int i, int j) { - _selectedItems[i] = _dropDownItems[i][j]; - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[i]); - base.UpdateUI(); - } - - public override void VariableParameterMaintenance() { - string unitAbbreviation = Length.GetAbbreviation(_lengthUnit); - int i = 0; - Params.Output[i++].Name = "Translations X [" + unitAbbreviation + "]"; - Params.Output[i++].Name = "Translations Y [" + unitAbbreviation + "]"; - Params.Output[i++].Name = "Translations Z [" + unitAbbreviation + "]"; - Params.Output[i].Name = "Translations |XYZ| [" + unitAbbreviation + "]"; - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Unit", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaResultParameter(), "Result", "Res", "GSA Result", - GH_ParamAccess.list); - pManager.AddGenericParameter("Element filter list", "El", - "Filter results by list (by default 'all')" + Environment.NewLine - + "Input a GSA List or a text string taking the form:" + Environment.NewLine - + " 1 11 to 20 step 2 P1 not (G1 to G6 step 3) P11 not (PA PB1 PS2 PM3 PA4 M1)" - + Environment.NewLine - + "Refer to GSA help file for definition of lists and full vocabulary.", - GH_ParamAccess.item); - pManager[1].Optional = true; - pManager.AddIntegerParameter("Intermediate Points", "nP", - "Number of intermediate equidistant points (default 3)", GH_ParamAccess.item, 3); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - string unitAbbreviation = Length.GetAbbreviation(_lengthUnit); - - string note = Environment.NewLine - + "DataTree organised as { CaseID ; Permutation ; ElementID } " + Environment.NewLine - + "fx. {1;2;3} is Case 1, Permutation 2, Element 3, where each " + Environment.NewLine - + "branch contains a list of results per element position."; - - pManager.AddGenericParameter("Translations X [" + unitAbbreviation + "]", "Ux", - "Translations in Local Element X-direction." + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Translations Y [" + unitAbbreviation + "]", "Uy", - "Translations in Local Element Y-direction." + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Translations Z [" + unitAbbreviation + "]", "Uz", - "Translations in Local Element Z-direction." + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Translations |XYZ| [" + unitAbbreviation + "]", "|U|", - "Combined |XYZ| Translations in Local Axis." + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Rotations XX [rad]", "Rxx", - "Rotations around Local Element X-axis." + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Rotations YY [rad]", "Ryy", - "Rotations around Local Element Y-axis." + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Rotations ZZ [rad]", "Rzz", - "Rotations around Local Element Z-axis." + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Rotations |XYZ| [rad]", "|R|", - "Combined |XXYYZZ| Rotations in Local Axis." + note, GH_ParamAccess.tree); - } - - protected override void SolveInternal(IGH_DataAccess da) { - this.AddRuntimeError("Beam Displacements are now in local axis - please update your script accordingly!"); - var result = new GsaResult(); - - string elementlist = string.Empty; - - var ghDivisions = new GH_Integer(); - da.GetData(2, ref ghDivisions); - GH_Convert.ToInt32(ghDivisions, out int positionsCount, GH_Conversion.Both); - positionsCount = Math.Abs(positionsCount) + 2; // taken absolute value and add 2 end points. - - var outTransX = new DataTree(); - var outTransY = new DataTree(); - var outTransZ = new DataTree(); - var outTransXyz = new DataTree(); - var outRotX = new DataTree(); - var outRotY = new DataTree(); - var outRotZ = new DataTree(); - var outRotXyz = new DataTree(); - - var ghTypes = new List(); - if (!da.GetDataList(0, ghTypes)) { - return; - } - - foreach (GH_ObjectWrapper ghTyp in ghTypes) { - if (ghTyp?.Value == null) { - this.AddRuntimeWarning("Input is null"); - return; - } - - if (ghTyp.Value is GsaResultGoo goo) { - result = goo.Value; - elementlist = Inputs.GetElementListDefinition(this, da, 1, result.Model); - } else { - this.AddRuntimeError("Error converting input to GSA Result"); - return; - } - - List vals - = result.Element1DDisplacementValues(elementlist, positionsCount, 0, _lengthUnit); - - List permutations = result.SelectedPermutationIds is null ? new List() { - 1, - } : result.SelectedPermutationIds; - if (permutations.Count == 1 && permutations[0] == -1) { - permutations = Enumerable.Range(1, vals.Count).ToList(); - } - - // loop through all permutations (analysis case will just have one) - foreach (int perm in permutations) { - if (vals[perm - 1].XyzResults.Count == 0 & vals[perm - 1].XxyyzzResults.Count == 0) { - string acase = result.ToString().Replace('}', ' ').Replace('{', ' '); - this.AddRuntimeWarning("Case " + acase + " contains no Element1D results."); - continue; - } - - Parallel.For(0, 2, thread => // split computation in two for xyz and xxyyzz - { - switch (thread) { - case 0: { - foreach (KeyValuePair> kvp in - vals[perm - 1].XyzResults) { - int elementId = kvp.Key; - ConcurrentDictionary res = kvp.Value; - if (res.Count == 0) { - continue; - } - - var path = new GH_Path(result.CaseId, - result.SelectedPermutationIds == null ? 0 : perm, elementId); - - outTransX.AddRange( - res.Select(x => new GH_UnitNumber(x.Value.X.ToUnit(_lengthUnit))), - path); // use ToUnit to capture changes in dropdown - outTransY.AddRange( - res.Select(x => new GH_UnitNumber(x.Value.Y.ToUnit(_lengthUnit))), path); - outTransZ.AddRange( - res.Select(x => new GH_UnitNumber(x.Value.Z.ToUnit(_lengthUnit))), path); - outTransXyz.AddRange( - res.Select(x => new GH_UnitNumber(x.Value.Xyz.ToUnit(_lengthUnit))), path); - } - - break; - } - case 1: { - foreach (KeyValuePair> kvp in - vals[perm - 1].XxyyzzResults) { - int elementId = kvp.Key; - ConcurrentDictionary res = kvp.Value; - if (res.Count == 0) { - continue; - } - - var path = new GH_Path(result.CaseId, - result.SelectedPermutationIds == null ? 0 : perm, elementId); - - outRotX.AddRange(res.Select(x => new GH_UnitNumber(x.Value.X)), - path); // always use [rad] units - outRotY.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Y)), path); - outRotZ.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Z)), path); - outRotXyz.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Xyz)), path); - } - - break; - } - } - }); - } - } - - da.SetDataTree(0, outTransX); - da.SetDataTree(1, outTransY); - da.SetDataTree(2, outTransZ); - da.SetDataTree(3, outTransXyz); - da.SetDataTree(4, outRotX); - da.SetDataTree(5, outRotY); - da.SetDataTree(6, outRotZ); - da.SetDataTree(7, outRotXyz); - - PostHog.Result(result.Type, 1, GsaResultsValues.ResultType.Displacement); - } - - protected override void UpdateUIFromSelectedItems() { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[0]); - base.UpdateUIFromSelectedItems(); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/CreateBool6_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateBool6_OBSOLETE.cs deleted file mode 100644 index f1c6e0f12..000000000 --- a/GsaGH/Components/GraveyardComp/CreateBool6_OBSOLETE.cs +++ /dev/null @@ -1,159 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.UI; - -namespace GsaGH.Components { - /// - /// Component to create a new Bool6 - /// - // ReSharper disable once InconsistentNaming - public class CreateBool6_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("f5909576-6796-4d6e-90d8-31a9b7ee6fb6"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.CreateBool6; - private bool _x; - private bool _xx; - private bool _y; - private bool _yy; - private bool _z; - private bool _zz; - - public CreateBool6_OBSOLETE() : base("Create " + GsaBool6Goo.Name.Replace(" ", string.Empty), - GsaBool6Goo.NickName.Replace(" ", string.Empty), "Create a " + GsaBool6Goo.Description, - CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - public override void CreateAttributes() { - var bool6 = new List>() { - new List() { - _x, - _y, - _z, - _xx, - _yy, - _zz, - }, - }; - m_attributes = new CheckBoxComponentAttributes(this, SetReleases, - new List() { - "Set 6 DOF", - }, bool6, new List>() { - new List() { - "x", - "y", - "z", - "xx", - "yy", - "zz", - }, - }); - } - - public override bool Read(GH_IReader reader) { - _x = reader.GetBoolean("x"); - _y = reader.GetBoolean("y"); - _z = reader.GetBoolean("z"); - _xx = reader.GetBoolean("xx"); - _yy = reader.GetBoolean("yy"); - _zz = reader.GetBoolean("zz"); - CreateAttributes(); - ExpireSolution(true); - Params.OnParametersChanged(); - OnDisplayExpired(true); - return base.Read(reader); - } - - public void SetReleases(List> bool6) { - _x = bool6[0][0]; - _y = bool6[0][1]; - _z = bool6[0][2]; - _xx = bool6[0][3]; - _yy = bool6[0][4]; - _zz = bool6[0][5]; - } - - public override bool Write(GH_IWriter writer) { - writer.SetBoolean("x", _x); - writer.SetBoolean("y", _y); - writer.SetBoolean("z", _z); - writer.SetBoolean("xx", _xx); - writer.SetBoolean("yy", _yy); - writer.SetBoolean("zz", _zz); - return base.Write(writer); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddBooleanParameter("X", "X", "X", GH_ParamAccess.item); - pManager.AddBooleanParameter("Y", "Y", "Y", GH_ParamAccess.item); - pManager.AddBooleanParameter("Z", "Z", "Z", GH_ParamAccess.item); - pManager.AddBooleanParameter("XX", "XX", "XX", GH_ParamAccess.item); - pManager.AddBooleanParameter("YY", "YY", "YY", GH_ParamAccess.item); - pManager.AddBooleanParameter("ZZ", "ZZ", "ZZ", GH_ParamAccess.item); - - pManager[0].Optional = true; - pManager[1].Optional = true; - pManager[2].Optional = true; - pManager[3].Optional = true; - pManager[4].Optional = true; - pManager[5].Optional = true; - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddGenericParameter("Bool6", "B6", "GSA Bool6 to set releases or restraints", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var ghBolX = new GH_Boolean(); - if (da.GetData(0, ref ghBolX)) { - GH_Convert.ToBoolean(ghBolX, out _x, GH_Conversion.Both); - } - - var ghBolY = new GH_Boolean(); - if (da.GetData(1, ref ghBolY)) { - GH_Convert.ToBoolean(ghBolY, out _y, GH_Conversion.Both); - } - - var ghBolZ = new GH_Boolean(); - if (da.GetData(2, ref ghBolZ)) { - GH_Convert.ToBoolean(ghBolZ, out _z, GH_Conversion.Both); - } - - var ghBolXx = new GH_Boolean(); - if (da.GetData(3, ref ghBolXx)) { - GH_Convert.ToBoolean(ghBolXx, out _xx, GH_Conversion.Both); - } - - var ghBolYy = new GH_Boolean(); - if (da.GetData(4, ref ghBolYy)) { - GH_Convert.ToBoolean(ghBolYy, out _yy, GH_Conversion.Both); - } - - var ghBolZz = new GH_Boolean(); - if (da.GetData(5, ref ghBolZz)) { - GH_Convert.ToBoolean(ghBolZz, out _zz, GH_Conversion.Both); - } - - var bool6 = new GsaBool6 { - X = _x, - Y = _y, - Z = _z, - Xx = _xx, - Yy = _yy, - Zz = _zz, - }; - da.SetData(0, new GsaBool6Goo(bool6)); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/CreateCombinationCase_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateCombinationCase_OBSOLETE.cs deleted file mode 100644 index fcc68cdf7..000000000 --- a/GsaGH/Components/GraveyardComp/CreateCombinationCase_OBSOLETE.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Drawing; -using Grasshopper.Kernel; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; - -namespace GsaGH.Components { - /// - /// Component to create GSA Combination Case - /// - public class CreateCombinationCase_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("d8df767a-ef59-4e08-b592-2a39149efde1"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.CreateCombinationCase; - - public CreateCombinationCase_OBSOLETE() : base("Create Combination Case", "CreateCombination", - "Create a new GSA Combination Case", CategoryName.Name(), SubCategoryName.Cat4()) { - Hidden = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddTextParameter("Name", "Na", "Case Name", GH_ParamAccess.item); - pManager.AddTextParameter("Description", "De", - "The description should take the form: 1.5A1 + 0.4A3." + Environment.NewLine - + "Use 'or' for enveloping cases eg (1 or -1.4)A1," + Environment.NewLine - + "'to' for enveloping a range of cases eg (C1 to C3)", GH_ParamAccess.item); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaCombinationCaseParameter()); - } - - protected override void SolveInstance(IGH_DataAccess da) { - string name = string.Empty; - da.GetData(0, ref name); - string desc = string.Empty; - da.GetData(1, ref desc); - da.SetData(0, new GsaCombinationCaseGoo(new GsaCombinationCase(name, desc))); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/CreateCustomMaterial_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateCustomMaterial_OBSOLETE.cs deleted file mode 100644 index 11a66290a..000000000 --- a/GsaGH/Components/GraveyardComp/CreateCustomMaterial_OBSOLETE.cs +++ /dev/null @@ -1,212 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using Grasshopper.Kernel; -using GsaAPI.Materials; -using GsaGH.Helpers; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; - -namespace GsaGH.Components { - /// - /// Component to create a new Material - /// - public class CreateCustomMaterial_OBSOLETE : GH_OasysDropDownComponent { - private enum FoldMode { - Generic, - Steel, - Concrete, - Timber, - Aluminium, - Frp, - Glass, - Fabric, - } - - public override Guid ComponentGuid => new Guid("83bfce91-9204-4fe4-b81d-0036babf0c6d"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.CreateCustomMaterial; - private DensityUnit _densityUnit = DefaultUnits.DensityUnit; - private FoldMode _mode = FoldMode.Timber; - private PressureUnit _stressUnit = DefaultUnits.StressUnitResult; - private TemperatureUnit _temperatureUnit = DefaultUnits.TemperatureUnit; - - public CreateCustomMaterial_OBSOLETE() : base("Custom Material", "Material", - "Create a Custom GSA Analysis Material", CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - public override void SetSelected(int i, int j) { - _selectedItems[i] = _dropDownItems[i][j]; - - if (i == 0) { - _mode = (FoldMode)Enum.Parse(typeof(FoldMode), _selectedItems[0].ToPascalCase()); - } else { - switch (i) { - case 1: - _stressUnit = (PressureUnit)UnitsHelper.Parse(typeof(PressureUnit), _selectedItems[1]); - break; - - case 2: - _densityUnit = (DensityUnit)UnitsHelper.Parse(typeof(DensityUnit), _selectedItems[2]); - break; - - case 3: - _temperatureUnit - = (TemperatureUnit)UnitsHelper.Parse(typeof(TemperatureUnit), _selectedItems[3]); - break; - } - } - - base.UpdateUI(); - } - - public override void VariableParameterMaintenance() { - string stressUnitAbbreviation = Pressure.GetAbbreviation(_stressUnit); - string densityUnitAbbreviation = Density.GetAbbreviation(_densityUnit); - string temperatureUnitAbbreviation = Temperature.GetAbbreviation(_temperatureUnit); - - int i = 1; - Params.Input[i].Name = "Elastic Modulus [" + stressUnitAbbreviation + "]"; - i++; - i++; - Params.Input[i].Name = "Density [" + densityUnitAbbreviation + "]"; - i++; - Params.Input[i].Name = "Thermal Expansion [/" + temperatureUnitAbbreviation + "]"; - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Material Type", - "Stress Unit", - "Density Unit", - "Temperature Unit", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(CreateCustomMaterial.MaterialTypes); - _selectedItems.Add(_mode.ToString()); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Stress)); - _selectedItems.Add(Pressure.GetAbbreviation(_stressUnit)); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Density)); - _selectedItems.Add(Density.GetAbbreviation(_densityUnit)); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Temperature)); - _selectedItems.Add(Temperature.GetAbbreviation(_temperatureUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - string stressUnitAbbreviation = Pressure.GetAbbreviation(_stressUnit); - string densityUnitAbbreviation = Density.GetAbbreviation(_densityUnit); - string temperatureUnitAbbreviation = Temperature.GetAbbreviation(_temperatureUnit); - - pManager.AddIntegerParameter("Analysis Property Number", "ID", - "Analysis Property Number (do not use 0 -> 'from Grade')", GH_ParamAccess.item); - pManager.AddGenericParameter("Elastic Modulus [" + stressUnitAbbreviation + "]", "E", - "Elastic Modulus of the elastic isotropic material", GH_ParamAccess.item); - pManager.AddNumberParameter("Poisson's Ratio", "ν", - "Poisson's Ratio of the elastic isotropic material", GH_ParamAccess.item); - pManager.AddGenericParameter("Density [" + densityUnitAbbreviation + "]", "ρ", - "Density of the elastic isotropic material", GH_ParamAccess.item); - pManager.AddGenericParameter("Thermal Expansion [/" + temperatureUnitAbbreviation + "]", "α", - "Thermal Expansion Coefficient of the elastic isotropic material", GH_ParamAccess.item); - pManager[0].Optional = true; - pManager[4].Optional = true; - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaMaterialParameter(), "Material", "Mat", "GSA Custom Material", - GH_ParamAccess.item); - } - - protected override void SolveInternal(IGH_DataAccess da) { - int id = 0; - da.GetData(0, ref id); - - double poisson = 0.3; - da.GetData(2, ref poisson); - - CoefficientOfThermalExpansionUnit thermalExpansionUnit - = CoefficientOfThermalExpansionUnit.InverseDegreeCelsius; - switch (_temperatureUnit) { - case TemperatureUnit.DegreeFahrenheit: - thermalExpansionUnit = CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit; - break; - - case TemperatureUnit.Kelvin: - thermalExpansionUnit = CoefficientOfThermalExpansionUnit.InverseKelvin; - break; - } - - var analysisMaterial = new AnalysisMaterial() { - ElasticModulus = Input.UnitNumber(this, da, 1, _stressUnit).As(PressureUnit.Pascal), - PoissonsRatio = poisson, - Density = Input.UnitNumber(this, da, 3, _densityUnit).As(DensityUnit.KilogramPerCubicMeter), - CoefficientOfThermalExpansion = Input.UnitNumber(this, da, 4, thermalExpansionUnit, true) - .As(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius), - }; - - GsaMaterial material = null; - - switch (_mode) { - case FoldMode.Generic: - material = new GsaCustomMaterial(analysisMaterial, id, MatType.Custom); - break; - - case FoldMode.Steel: - material = new GsaCustomMaterial(analysisMaterial, id, MatType.Steel); - break; - - case FoldMode.Concrete: - material = new GsaCustomMaterial(analysisMaterial, id, MatType.Concrete); - break; - - case FoldMode.Timber: - material = new GsaCustomMaterial(analysisMaterial, id, MatType.Timber); - break; - - case FoldMode.Aluminium: - material = new GsaCustomMaterial(analysisMaterial, id, MatType.Aluminium); - break; - - case FoldMode.Frp: - material = new GsaCustomMaterial(analysisMaterial, id, MatType.Frp); - break; - - case FoldMode.Glass: - material = new GsaCustomMaterial(analysisMaterial, id, MatType.Glass); - break; - - case FoldMode.Fabric: - material = new GsaCustomMaterial(analysisMaterial, id, MatType.Fabric); - break; - } - - da.SetData(0, new GsaMaterialGoo(material)); - } - - protected override void UpdateUIFromSelectedItems() { - _mode = (FoldMode)Enum.Parse(typeof(FoldMode), _selectedItems[0].ToPascalCase()); - _stressUnit = (PressureUnit)UnitsHelper.Parse(typeof(PressureUnit), _selectedItems[1]); - _densityUnit = (DensityUnit)UnitsHelper.Parse(typeof(DensityUnit), _selectedItems[2]); - _temperatureUnit - = (TemperatureUnit)UnitsHelper.Parse(typeof(TemperatureUnit), _selectedItems[3]); - base.UpdateUIFromSelectedItems(); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/CreateGridPlane_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateGridPlane_OBSOLETE.cs deleted file mode 100644 index 4d9262228..000000000 --- a/GsaGH/Components/GraveyardComp/CreateGridPlane_OBSOLETE.cs +++ /dev/null @@ -1,233 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Parameters; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; -using Rhino.Geometry; - -namespace GsaGH.Components { - // ReSharper disable once InconsistentNaming - public class CreateGridPlane_OBSOLETE : GH_OasysDropDownComponent { - private enum FoldMode { - General, - Storey, - } - - public override Guid ComponentGuid => new Guid("675fd47a-890d-45b8-bdde-fb2e8c1d9cca"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.CreateGridPlane; - private readonly List _type = new List(new string[] { - "General", - "Storey", - }); - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - private FoldMode _mode = FoldMode.General; - - public CreateGridPlane_OBSOLETE() : base("Create Grid Plane", "GridPlane", - "Create GSA Grid Plane", CategoryName.Name(), SubCategoryName.Cat3()) { } - - public override bool Read(GH_IReader reader) { - if (reader.ItemExists("Mode")) { - _mode = (FoldMode)reader.GetInt32("Mode"); - InitialiseDropdowns(); - } - - if (_mode != FoldMode.Storey || Params.Input.Count >= 5) { - return base.Read(reader); - } - - Params.RegisterInputParam(new Param_GenericObject()); - Params.RegisterInputParam(new Param_GenericObject()); - - return base.Read(reader); - } - - public override void SetSelected(int i, int j) { - _selectedItems[i] = _dropDownItems[i][j]; - if (i == 0) { - switch (_selectedItems[0]) { - case "General": - Mode1Clicked(); - break; - - case "Storey": - Mode2Clicked(); - break; - } - } else { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[i]); - } - - base.UpdateUI(); - } - - public override void VariableParameterMaintenance() { - Params.Input[2].Name = "Grid Elevation [" + Length.GetAbbreviation(_lengthUnit) + "]"; - - if (_mode != FoldMode.Storey) { - return; - } - - if (Params.Input.Count < 5) { - Params.RegisterInputParam(new Param_GenericObject()); - Params.RegisterInputParam(new Param_GenericObject()); - } - - Params.Input[4].NickName = "tA"; - Params.Input[4].Name = "Tolerance Above [" + Length.GetAbbreviation(_lengthUnit) + "]"; - Params.Input[4].Description = "Tolerance Above Grid Plane"; - Params.Input[4].Access = GH_ParamAccess.item; - Params.Input[4].Optional = true; - - Params.Input[5].NickName = "tB"; - Params.Input[5].Name = "Tolerance Below [" + Length.GetAbbreviation(_lengthUnit) + "]"; - Params.Input[5].Description = "Tolerance Below Grid Plane"; - Params.Input[5].Access = GH_ParamAccess.item; - Params.Input[5].Optional = true; - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new string[] { - "Type", - "Unit", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(_type); - _selectedItems.Add(_mode.ToString()); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddGenericParameter("Plane", "P", - "Plane for Axis and Grid Plane definition. Note that an XY-plane will be created with an axis origin Z = 0 " - + "and the height location will be controlled by Grid Plane elevation. For all none-XY plane inputs, the Grid Plane elevation will be 0", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Grid Plane ID", "ID", - "GSA Grid Plane ID. Setting this will replace any existing Grid Planes in GSA model", - GH_ParamAccess.item, 0); - pManager.AddGenericParameter("Grid Elevation [" + Length.GetAbbreviation(_lengthUnit) + "]", - "Ev", - "Grid Elevation (Optional). Note that this value will be added to Plane origin location in the plane's normal axis direction.", - GH_ParamAccess.item); - pManager.AddTextParameter("Name", "Na", "Grid Plane Name", GH_ParamAccess.item); - - pManager[0].Optional = true; - pManager[1].Optional = true; - pManager[2].Optional = true; - pManager[3].Optional = true; - - _mode = FoldMode.General; - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaGridPlaneSurfaceParameter(), "Grid Plane", "GP", "GSA Grid Plane", - GH_ParamAccess.item); - } - - protected override void SolveInternal(IGH_DataAccess da) { - Plane plane = Plane.WorldXY; - var ghPlane = new GH_Plane(); - if (da.GetData(0, ref ghPlane)) { - GH_Convert.ToPlane(ghPlane, ref plane, GH_Conversion.Both); - } - - var gsaGridPlaneSurface = new GsaGridPlaneSurface(plane); - - var ghint = new GH_Integer(); - if (da.GetData(1, ref ghint)) { - GH_Convert.ToInt32(ghint, out int id, GH_Conversion.Both); - gsaGridPlaneSurface.GridPlaneId = id; - } - - if (Params.Input[2].SourceCount > 0) { - double elev = Input.UnitNumber(this, da, 2, _lengthUnit, true).As(LengthUnit.Meter); - gsaGridPlaneSurface.GridPlane.Elevation = elev; - - Vector3d vec = plane.Normal; - vec.Unitize(); - vec.X *= elev; - vec.Y *= elev; - vec.Z *= elev; - var xform = Transform.Translation(vec); - plane.Transform(xform); - gsaGridPlaneSurface.Plane = plane; - } - - var ghtxt = new GH_String(); - if (da.GetData(3, ref ghtxt)) { - if (GH_Convert.ToString(ghtxt, out string name, GH_Conversion.Both)) { - gsaGridPlaneSurface.GridPlane.Name = name; - } - } - - if (_mode == FoldMode.General) { - gsaGridPlaneSurface.GridPlane.IsStoreyType = false; - } else { - gsaGridPlaneSurface.GridPlane.IsStoreyType = true; - - if (Params.Input[4].SourceCount > 0) { - gsaGridPlaneSurface.GridPlane.ToleranceAbove = Input - .UnitNumber(this, da, 4, _lengthUnit, true).As(LengthUnit.Meter); - } - - if (Params.Input[5].SourceCount > 0) { - gsaGridPlaneSurface.GridPlane.ToleranceBelow = Input - .UnitNumber(this, da, 5, _lengthUnit, true).As(LengthUnit.Meter); - } - } - - da.SetData(0, new GsaGridPlaneSurfaceGoo(gsaGridPlaneSurface)); - } - - protected override void UpdateUIFromSelectedItems() { - _mode = (FoldMode)Enum.Parse(typeof(FoldMode), _selectedItems[0]); - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[1]); - base.UpdateUIFromSelectedItems(); - } - - private void Mode1Clicked() { - if (_mode == FoldMode.General) { - return; - } - - RecordUndoEvent("General Parameters"); - _mode = FoldMode.General; - - while (Params.Input.Count > 4) { - Params.UnregisterInputParameter(Params.Input[4], true); - } - } - - private void Mode2Clicked() { - if (_mode == FoldMode.Storey) { - return; - } - - RecordUndoEvent("Storey Parameters"); - _mode = FoldMode.Storey; - - Params.RegisterInputParam(new Param_GenericObject()); - Params.RegisterInputParam(new Param_GenericObject()); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/CreateGridSurface_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateGridSurface_OBSOLETE.cs deleted file mode 100644 index b9826db1b..000000000 --- a/GsaGH/Components/GraveyardComp/CreateGridSurface_OBSOLETE.cs +++ /dev/null @@ -1,404 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Parameters; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using Rhino.Geometry; -using AngleUnit = OasysUnits.Units.AngleUnit; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - // ReSharper disable once InconsistentNaming - public class CreateGridSurface_OBSOLETE : GH_OasysDropDownComponent { - private enum FoldMode { - OneDimensionalOneWay, - OneDimensionalTwoWay, - TwoDimensional, - } - - public override Guid ComponentGuid => new Guid("1052955c-cf97-4378-81d3-8491e0defad0"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.CreateGridSurface; - private readonly List _type = new List(new[] { - "1D, One-way span", - "1D, Two-way span", - "2D", - }); - private IGH_Param _angleInputParam; - private AngleUnit _angleUnit = AngleUnit.Radian; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - private FoldMode _mode = FoldMode.OneDimensionalOneWay; - - public CreateGridSurface_OBSOLETE() : base("Create Grid Surface", "GridSurface", - "Create GSA Grid Surface", CategoryName.Name(), SubCategoryName.Cat3()) { } - - public override bool Read(GH_IReader reader) { - if (!reader.ItemExists("Mode")) { - return base.Read(reader); - } - - _mode = (FoldMode)reader.GetInt32("Mode"); - - InitialiseDropdowns(); - - _selectedItems = new List(); - switch (_mode) { - case FoldMode.OneDimensionalOneWay: - _selectedItems.Add("1D, One-way span"); - break; - - case FoldMode.OneDimensionalTwoWay: - _selectedItems.Add("1D, Two-way span"); - break; - - case FoldMode.TwoDimensional: - _selectedItems.Add("2D"); - break; - } - - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - - return base.Read(reader); - } - - public override void SetSelected(int i, int j) { - _selectedItems[i] = _dropDownItems[i][j]; - if (i == 0) { - switch (_selectedItems[i]) { - case "1D, One-way span": - Mode1Clicked(); - break; - - case "1D, Two-way span": - Mode2Clicked(); - break; - - case "2D": - Mode3Clicked(); - break; - } - } else { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[i]); - } - - base.UpdateUI(); - } - - public override void VariableParameterMaintenance() { - switch (_mode) { - case FoldMode.OneDimensionalOneWay: - Params.Input[5].NickName = "Dir"; - Params.Input[5].Name = "Span Direction"; - Params.Input[5].Description = "Span Direction between -180 and 180 degrees"; - Params.Input[5].Access = GH_ParamAccess.item; - Params.Input[5].Optional = true; - break; - - case FoldMode.OneDimensionalTwoWay: - Params.Input[5].NickName = "Exp"; - Params.Input[5].Name = "Load Expansion"; - Params.Input[5].Description = "Load Expansion: " + Environment.NewLine - + "Accepted inputs are:" + Environment.NewLine + "0 : Corner (plane)" - + Environment.NewLine + "1 : Smooth (plane)" + Environment.NewLine + "2 : Plane" - + Environment.NewLine + "3 : Legacy"; - Params.Input[5].Access = GH_ParamAccess.item; - Params.Input[5].Optional = true; - - Params.Input[6].NickName = "Sim"; - Params.Input[6].Name = "Simplify"; - Params.Input[6].Description = "Simplify Tributary Area (default: True)"; - Params.Input[6].Access = GH_ParamAccess.item; - Params.Input[6].Optional = true; - break; - } - } - - protected override void BeforeSolveInstance() { - base.BeforeSolveInstance(); - if (_mode != FoldMode.OneDimensionalOneWay) { - return; - } - - if (Params.Input[5] is Param_Number angleParameter) { - _angleUnit = angleParameter.UseDegrees ? AngleUnit.Degree : AngleUnit.Radian; - } - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Type", - "Unit", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(_type); - _selectedItems.Add(_type[0]); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - IQuantity length = new Length(0, DefaultUnits.LengthUnitGeometry); - string unitAbbreviation = string.Concat(length.ToString().Where(char.IsLetter)); - - pManager.AddGenericParameter("Grid Plane", "GP", - "Grid Plane. If no input, Global XY-plane will be used", GH_ParamAccess.item); - pManager.AddIntegerParameter("Grid Surface ID", "ID", - "GSA Grid Surface ID. Setting this will replace any existing Grid Surfaces in GSA model", - GH_ParamAccess.item, 0); - pManager.AddTextParameter("Element list", "El", - "List of Elements for which load should be expanded to (by default 'all')." - + Environment.NewLine + "Element list should take the form:" + Environment.NewLine - + " 1 11 to 20 step 2 P1 not (G1 to G6 step 3) P11 not (PA PB1 PS2 PM3 PA4 M1)" - + Environment.NewLine - + "Refer to GSA help file for definition of lists and full vocabulary.", - GH_ParamAccess.item, "All"); - pManager.AddTextParameter("Name", "Na", "Grid Surface Name", GH_ParamAccess.item); - pManager.AddGenericParameter("Tolerance [" + unitAbbreviation + "]", "To", - "Tolerance for Load Expansion (default 10mm)", GH_ParamAccess.item); - pManager.AddAngleParameter("Span Direction", "Di", - "Span Direction between -180 and 180 degrees", GH_ParamAccess.item, 0); - pManager[5].Optional = true; - _angleInputParam = Params.Input[5]; - - pManager[0].Optional = true; - pManager[1].Optional = true; - pManager[2].Optional = true; - pManager[3].Optional = true; - pManager[4].Optional = true; - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaGridPlaneSurfaceParameter(), "Grid Surface", "GPS", "GSA Grid Surface", - GH_ParamAccess.item); - } - - protected override void SolveInternal(IGH_DataAccess da) { - GsaGridPlaneSurface gsaGridPlaneSurface; - Plane plane = Plane.Unset; - bool idSet = false; - - GsaGridPlaneSurfaceGoo gridPlaneSurfaceGoo = null; - if (da.GetData(0, ref gridPlaneSurfaceGoo)) { - gsaGridPlaneSurface = gridPlaneSurfaceGoo.Value; - if (gsaGridPlaneSurface.GridPlane == null - && gsaGridPlaneSurface.GridSurface.GridPlane != 0) { - idSet = true; - } - } else { - plane = Plane.WorldXY; - gsaGridPlaneSurface = new GsaGridPlaneSurface(plane); - } - - - var ghtxt = new GH_String(); - string name = ""; - bool changeGs = false; - if (da.GetData(3, ref ghtxt)) { - if (GH_Convert.ToString(ghtxt, out name, GH_Conversion.Both)) { - changeGs = true; - } - } - - var gs = new GridSurface(name); - if (idSet) { - gs.GridPlane = gsaGridPlaneSurface.GridSurface.GridPlane; - } - - var ghint = new GH_Integer(); - if (da.GetData(1, ref ghint)) { - GH_Convert.ToInt32(ghint, out int id, GH_Conversion.Both); - gsaGridPlaneSurface.GridSurfaceId = id; - } - - var ghTyp = new GH_ObjectWrapper(); - if (da.GetData(2, ref ghTyp)) { - string type = ghTyp.Value.ToString().ToUpper(); - if (type.StartsWith("GSA ")) { - Params.Owner.AddRuntimeError( - "You cannot input a Node/Element/Member in ElementList input!" + Environment.NewLine - + "Element list should take the form:" + Environment.NewLine - + "'1 11 to 20 step 2 P1 not (G1 to G6 step 3) P11 not (PA PB1 PS2 PM3 PA4 M1)'" - + Environment.NewLine - + "Refer to GSA help file for definition of lists and full vocabulary."); - return; - } - } - - var ghString = new GH_String(); - if (da.GetData(2, ref ghString)) { - if (GH_Convert.ToString(ghString, out string elem, GH_Conversion.Both)) { - gs.Elements = elem; - changeGs = true; - } - } - - if (Params.Input[4].SourceCount != 0) { - gs.Tolerance = ((Length)Input.UnitNumber(this, da, 4, _lengthUnit, true)).Millimeters; - changeGs = true; - } - - switch (_mode) { - case FoldMode.OneDimensionalOneWay: - gs.ElementType = GridSurface.Element_Type.ONE_DIMENSIONAL; - gs.SpanType = GridSurface.Span_Type.ONE_WAY; - - double dir = 0.0; - if (da.GetData(5, ref dir)) { - var direction = new Angle(dir, _angleUnit); - - if (direction.Degrees > 180 || direction.Degrees < -180) { - this.AddRuntimeWarning( - "Angle value must be between -180 and 180 degrees"); // to be updated when GsaAPI support units - } - - gs.Direction = direction.Degrees; - if (dir != 0.0) { - changeGs = true; - } - } - - break; - - case FoldMode.OneDimensionalTwoWay: - changeGs = true; - gs.ElementType = GridSurface.Element_Type.ONE_DIMENSIONAL; - - int exp = 0; - var ghexp = new GH_Integer(); - if (da.GetData(5, ref ghexp)) { - GH_Convert.ToInt32_Primary(ghexp, ref exp); - } - - gs.ExpansionType = GridSurfaceExpansionType.PLANE_CORNER; - switch (exp) { - case 1: - gs.ExpansionType = GridSurfaceExpansionType.PLANE_SMOOTH; - break; - - case 2: - gs.ExpansionType = GridSurfaceExpansionType.PLANE_ASPECT; - break; - - case 3: - gs.ExpansionType = GridSurfaceExpansionType.LEGACY; - break; - } - - bool simple = true; - var ghsim = new GH_Boolean(); - if (da.GetData(6, ref ghsim)) { - GH_Convert.ToBoolean(ghsim, out simple, GH_Conversion.Both); - } - - gs.SpanType = simple ? GridSurface.Span_Type.TWO_WAY_SIMPLIFIED_TRIBUTARY_AREAS : - GridSurface.Span_Type.TWO_WAY; - break; - - case FoldMode.TwoDimensional: - changeGs = true; - gs.ElementType = GridSurface.Element_Type.TWO_DIMENSIONAL; - break; - } - - if (changeGs) { - gsaGridPlaneSurface.GridSurface = gs; - } - - da.SetData(0, new GsaGridPlaneSurfaceGoo(gsaGridPlaneSurface)); - } - - protected override void UpdateUIFromSelectedItems() { - switch (_selectedItems[0]) { - case "1D, One-way span": - _mode = FoldMode.OneDimensionalOneWay; - break; - - case "1D, Two-way span": - _mode = FoldMode.OneDimensionalTwoWay; - break; - - case "2D": - _mode = FoldMode.TwoDimensional; - break; - } - - if (_selectedItems.Count > 1) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[1]); - } - - base.UpdateUIFromSelectedItems(); - } - - private void Mode1Clicked() { - if (_mode == FoldMode.OneDimensionalOneWay) { - return; - } - - RecordUndoEvent("1D, one-way Parameters"); - _mode = FoldMode.OneDimensionalOneWay; - - while (Params.Input.Count > 5) { - Params.UnregisterInputParameter(Params.Input[5], true); - } - - Params.RegisterInputParam(_angleInputParam); - } - - private void Mode2Clicked() { - switch (_mode) { - case FoldMode.OneDimensionalTwoWay: return; - - case FoldMode.OneDimensionalOneWay: - _angleInputParam = Params.Input[5]; - break; - } - - RecordUndoEvent("1D, two-way Parameters"); - _mode = FoldMode.OneDimensionalTwoWay; - - while (Params.Input.Count > 5) { - Params.UnregisterInputParameter(Params.Input[5], true); - } - - Params.RegisterInputParam(new Param_Integer()); - Params.RegisterInputParam(new Param_Boolean()); - } - - private void Mode3Clicked() { - switch (_mode) { - case FoldMode.TwoDimensional: return; - - case FoldMode.OneDimensionalOneWay: - _angleInputParam = Params.Input[5]; - break; - } - - RecordUndoEvent("2D Parameters"); - _mode = FoldMode.TwoDimensional; - - while (Params.Input.Count > 5) { - Params.UnregisterInputParameter(Params.Input[5], true); - } - } - } -} diff --git a/GsaGH/Components/GraveyardComp/CreateMaterial2_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateMaterial2_OBSOLETE.cs deleted file mode 100644 index 240982100..000000000 --- a/GsaGH/Components/GraveyardComp/CreateMaterial2_OBSOLETE.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using Grasshopper.Kernel; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; - -namespace GsaGH.Components.GraveyardComp { - /// - /// Component to create a new Material - /// - public class CreateMaterial2_OBSOLETE : GH_OasysDropDownComponent { - public override Guid ComponentGuid => new Guid("40641747-cfb1-4dab-b060-b9dd344d3ac3"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - public static List MaterialTypes = new List() { - "Generic", - "Steel", - "Concrete", - "Timber", - "Aluminium", - "FRP", - "Glass", - "Fabric", - }; - - protected override Bitmap Icon => Resources.CreateMaterial; - - public CreateMaterial2_OBSOLETE() : base("Create" + GsaMaterialGoo.Name.Replace(" ", string.Empty), - GsaMaterialGoo.Name.Replace(" ", string.Empty), - "Create a " + GsaMaterialGoo.Description + " for a " + GsaSectionGoo.Description, - CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - public override void SetSelected(int i, int j) { - _selectedItems[i] = _dropDownItems[i][j]; - base.UpdateUI(); - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Material type", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(new List(MaterialTypes)); - _selectedItems.Add(MaterialTypes[3]); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddIntegerParameter("Grade", "Grd", "Material Grade (default = 1)", - GH_ParamAccess.item, 1); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaMaterialParameter(), "Material", "Mat", - "GSA Standard Material (reference)", GH_ParamAccess.item); - } - - protected override void SolveInternal(IGH_DataAccess da) { - this.AddRuntimeError( - $"This component is obsolete and no longer works with the plugin. {Environment.NewLine}" + - $"Please use the new CreateMaterial component that now supports standard materials." + - $"{Environment.NewLine}Simply drag a new Create Material component onto the canvas."); - - da.SetData(0, new GsaMaterialGoo(null)); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/CreateMaterial_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateMaterial_OBSOLETE.cs deleted file mode 100644 index 081995d2f..000000000 --- a/GsaGH/Components/GraveyardComp/CreateMaterial_OBSOLETE.cs +++ /dev/null @@ -1,268 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.UI; - -namespace GsaGH.Components { - /// - /// Component to create a new Material - /// - // ReSharper disable once InconsistentNaming - public class CreateMaterial_OBSOLETE : GH_OasysComponent, IGH_VariableParameterComponent { - private enum FoldMode { - Generic, - Steel, - Concrete, - Timber, - Aluminium, - Frp, - Glass, - Fabric, - } - - public override Guid ComponentGuid => new Guid("72bfce91-9204-4fe4-b81d-0036babf0c6d"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.CreateMaterial; - private readonly List _dropDownItems = new List(new[] { - "Generic", - "Steel", - "Concrete", - "Timber", - "Aluminium", - "Frp", - "Glass", - "Fabric", - }); - private readonly bool _first = true; - private FoldMode _mode = FoldMode.Timber; - private string _selecteditem; - - public CreateMaterial_OBSOLETE() : base("Create Material", "Material", - "Create GSA Material by reference to existing type and grade", CategoryName.Name(), - SubCategoryName.Cat1()) { - Hidden = true; - } - - bool IGH_VariableParameterComponent.CanInsertParameter(GH_ParameterSide side, int index) { - return false; - } - - bool IGH_VariableParameterComponent.CanRemoveParameter(GH_ParameterSide side, int index) { - return false; - } - - public override void CreateAttributes() { - if (_first) { - _selecteditem = _mode.ToString(); - } - - m_attributes = new DropDownComponentAttributes(this, SetSelected, new List>() { - _dropDownItems, - }, new List() { - _selecteditem, - }, new List() { - "Material Type", - }); - } - - IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index) { - return null; - } - - bool IGH_VariableParameterComponent.DestroyParameter(GH_ParameterSide side, int index) { - return false; - } - - public override bool Read(GH_IReader reader) { - _mode = (FoldMode)reader.GetInt32("Mode"); - _selecteditem = reader.GetString("select"); - CreateAttributes(); - return base.Read(reader); - } - - public void SetSelected(int i, int j) { - _selecteditem = _dropDownItems[i]; - switch (_selecteditem) { - case "Generic": - Mode1Clicked(); - break; - - case "Steel": - Mode2Clicked(); - break; - - case "Concrete": - Mode3Clicked(); - break; - - case "Timber": - Mode4Clicked(); - break; - - case "Aluminium": - Mode5Clicked(); - break; - - case "Frp": - Mode6Clicked(); - break; - - case "Glass": - Mode7Clicked(); - break; - - case "Fabric": - Mode8Clicked(); - break; - } - } - - void IGH_VariableParameterComponent.VariableParameterMaintenance() { } - - public override bool Write(GH_IWriter writer) { - writer.SetInt32("Mode", (int)_mode); - writer.SetString("select", _selecteditem); - return base.Write(writer); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddIntegerParameter("Analysis Property Number", "ID", - "Analysis Property Number (default = 0 -> 'from Grade')", GH_ParamAccess.item, 0); - pManager.AddIntegerParameter("Grade", "Gr", "Material Grade (default = 1)", - GH_ParamAccess.item, 1); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddGenericParameter("Material", "Ma", "GSA Material", GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - this.AddRuntimeError( - $"This component is obsolete and no longer works with the plugin. {Environment.NewLine}" + - $"Please use the new CreateMaterial component that now supports standard materials." + - $"{Environment.NewLine}Simply drag a new Create Material component onto the canvas."); - - da.SetData(0, new GsaMaterialGoo(null)); - } - - private void Mode1Clicked() { - if (_mode == FoldMode.Generic) { - return; - } - - RecordUndoEvent(_mode + "Parameters"); - - _mode = FoldMode.Generic; - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - - private void Mode2Clicked() { - if (_mode == FoldMode.Steel) { - return; - } - - RecordUndoEvent(_mode + "Parameters"); - - _mode = FoldMode.Steel; - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - - private void Mode3Clicked() { - if (_mode == FoldMode.Concrete) { - return; - } - - RecordUndoEvent(_mode + "Parameters"); - - _mode = FoldMode.Concrete; - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - - private void Mode4Clicked() { - if (_mode == FoldMode.Timber) { - return; - } - - RecordUndoEvent(_mode + "Parameters"); - - _mode = FoldMode.Timber; - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - - private void Mode5Clicked() { - if (_mode == FoldMode.Aluminium) { - return; - } - - RecordUndoEvent(_mode + "Parameters"); - - _mode = FoldMode.Aluminium; - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - - private void Mode6Clicked() { - if (_mode == FoldMode.Frp) { - return; - } - - RecordUndoEvent(_mode + "Parameters"); - - _mode = FoldMode.Frp; - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - - private void Mode7Clicked() { - if (_mode == FoldMode.Glass) { - return; - } - - RecordUndoEvent(_mode + "Parameters"); - - _mode = FoldMode.Glass; - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - - private void Mode8Clicked() { - if (_mode == FoldMode.Fabric) { - return; - } - - RecordUndoEvent(_mode + "Parameters"); - - _mode = FoldMode.Fabric; - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/CreateMember1d_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateMember1d_OBSOLETE.cs deleted file mode 100644 index dc7c3bf59..000000000 --- a/GsaGH/Components/GraveyardComp/CreateMember1d_OBSOLETE.cs +++ /dev/null @@ -1,217 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Components.GraveyardComp; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.UI; -using OasysGH.Units; -using Rhino.Geometry; - -namespace GsaGH.Components { - /// - /// Component to create new 1D Member - /// - // ReSharper disable once InconsistentNaming - public class CreateMember1d_OBSOLETE : GH_OasysDropDownComponent { - public override Guid ComponentGuid => new Guid("5c5b9efa-cdae-4be5-af40-ff2b590801dd"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Create1dMember; - private bool _x1; - private bool _x2; - private bool _xx1; - private bool _xx2; - private bool _y1; - private bool _y2; - private bool _yy1; - private bool _yy2; - private bool _z1; - private bool _z2; - private bool _zz1; - private bool _zz2; - - public CreateMember1d_OBSOLETE() : base("Create 1D Member", "Mem1D", "Create GSA 1D Member", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - public override void CreateAttributes() { - var restraints = new List>() { - new List() { - _x1, - _y1, - _z1, - _xx1, - _yy1, - _zz1, - }, - new List() { - _x2, - _y2, - _z2, - _xx2, - _yy2, - _zz2, - }, - }; - m_attributes = new CheckBoxComponentAttributes(this, SetReleases, - new List() { - "Start Release", - "End Release", - }, restraints, new List>() { - new List() { - "x", - "y", - "z", - "xx", - "yy", - "zz", - }, - new List() { - "x", - "y", - "z", - "xx", - "yy", - "zz", - }, - }); - } - - public override bool Read(GH_IReader reader) { - _x1 = reader.GetBoolean("x1"); - _y1 = reader.GetBoolean("y1"); - _z1 = reader.GetBoolean("z1"); - _xx1 = reader.GetBoolean("xx1"); - _yy1 = reader.GetBoolean("yy1"); - _zz1 = reader.GetBoolean("zz1"); - _x2 = reader.GetBoolean("x2"); - _y2 = reader.GetBoolean("y2"); - _z2 = reader.GetBoolean("z2"); - _xx2 = reader.GetBoolean("xx2"); - _yy2 = reader.GetBoolean("yy2"); - _zz2 = reader.GetBoolean("zz2"); - - if (reader.ChunkExists("ParameterData")) { - base.Read(reader); - } else { - BaseReader.Read(reader, this); - _isInitialised = true; - UpdateUIFromSelectedItems(); - } - - GH_IReader attributes = reader.FindChunk("Attributes"); - Attributes.Bounds = (RectangleF)attributes.Items[0].InternalData; - Attributes.Pivot = (PointF)attributes.Items[1].InternalData; - return true; - } - - public void SetReleases(List> restraints) { - _x1 = restraints[0][0]; - _y1 = restraints[0][1]; - _z1 = restraints[0][2]; - _xx1 = restraints[0][3]; - _yy1 = restraints[0][4]; - _zz1 = restraints[0][5]; - _x2 = restraints[1][0]; - _y2 = restraints[1][1]; - _z2 = restraints[1][2]; - _xx2 = restraints[1][3]; - _yy2 = restraints[1][4]; - _zz2 = restraints[1][5]; - - base.UpdateUI(); - } - - public override void SetSelected(int i, int j) { } - - public override bool Write(GH_IWriter writer) { - writer.SetBoolean("x1", _x1); - writer.SetBoolean("y1", _y1); - writer.SetBoolean("z1", _z1); - writer.SetBoolean("xx1", _xx1); - writer.SetBoolean("yy1", _yy1); - writer.SetBoolean("zz1", _zz1); - writer.SetBoolean("x2", _x2); - writer.SetBoolean("y2", _y2); - writer.SetBoolean("z2", _z2); - writer.SetBoolean("xx2", _xx2); - writer.SetBoolean("yy2", _yy2); - writer.SetBoolean("zz2", _zz2); - return base.Write(writer); - } - - protected override void InitialiseDropdowns() { } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddCurveParameter("Curve", "C", - "Curve (a NURBS curve will automatically be converted in to a Polyline of Arc and Line segments)", - GH_ParamAccess.item); - pManager.AddParameter(new GsaSectionParameter()); - pManager[1].Optional = true; - pManager.HideParameter(0); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaMember1dParameter()); - } - - protected override void SolveInternal(IGH_DataAccess da) { - var ghcrv = new GH_Curve(); - if (!da.GetData(0, ref ghcrv)) { - return; - } - - if (ghcrv == null) { - this.AddRuntimeWarning("Curve input is null"); - } - - Curve crv = null; - if (!GH_Convert.ToCurve(ghcrv, ref crv, GH_Conversion.Both)) { - return; - } - - var mem = new GsaMember1d(crv); - if (mem.PolyCurve.GetLength() < DefaultUnits.Tolerance.As(DefaultUnits.LengthUnitGeometry)) { - this.AddRuntimeRemark( - "Service message from you favourite Oasys dev team: Based on your Default Unit Settings (changed in the Oasys Menu), one or more input curves have relatively short length less than the set tolerance (" - + DefaultUnits.Tolerance.ToString().Replace(" ", string.Empty) - + ". This may convert into a zero-length line when assembling the GSA Model, thus creating invalid topology that cannot be analysed. You can ignore this message if you are creating your model in another unit (set on 'Analyse' or 'CreateModel' components) than " - + DefaultUnits.LengthUnitGeometry.ToString() + "."); - } - - var rel1 = new GsaBool6 { - X = _x1, - Y = _y1, - Z = _z1, - Xx = _xx1, - Yy = _yy1, - Zz = _zz1, - }; - - mem.ReleaseStart = rel1; - - var rel2 = new GsaBool6 { - X = _x2, - Y = _y2, - Z = _z2, - Xx = _xx2, - Yy = _yy2, - Zz = _zz2, - }; - mem.ReleaseEnd = rel2; - - GsaSectionGoo sectionGoo = null; - if (da.GetData(1, ref sectionGoo)) { - mem.Section = sectionGoo.Value; - } - - da.SetData(0, new GsaMember1dGoo(mem)); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/CreateMember2d2_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateMember2d2_OBSOLETE.cs deleted file mode 100644 index 26207be48..000000000 --- a/GsaGH/Components/GraveyardComp/CreateMember2d2_OBSOLETE.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using Rhino.Collections; -using Rhino.Geometry; - -namespace GsaGH.Components { - /// - /// Component to create new 2D Member - /// - public class CreateMember2d2_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("01450bfc-7ac1-4c51-97a2-42d81d6476b6"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Create2dMember; - - public CreateMember2d2_OBSOLETE() : base("Create 2D Member", "Mem2D", "Create GSA Member 2D", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddBrepParameter("Brep", "B", - "Planar Brep (non-planar geometry will be automatically converted to an average plane of exterior boundary control points))", - GH_ParamAccess.item); - pManager.AddPointParameter("Incl. Points", "(P)", - "Inclusion points (will automatically be projected onto Brep)", GH_ParamAccess.list); - pManager.AddCurveParameter("Incl. Curves", "(C)", - "Inclusion curves (will automatically be made planar and projected onto brep, and converted to Arcs and Lines)", - GH_ParamAccess.list); - pManager.AddParameter(new GsaProperty2dParameter()); - pManager.AddNumberParameter("Mesh Size in model units", "Ms", "Target mesh size", - GH_ParamAccess.item); - - pManager.HideParameter(0); - pManager.HideParameter(1); - pManager.HideParameter(2); - - pManager[1].Optional = true; - pManager[2].Optional = true; - pManager[3].Optional = true; - pManager[4].Optional = true; - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaMember2dParameter()); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var ghbrep = new GH_Brep(); - if (!da.GetData(0, ref ghbrep)) { - return; - } - - if (ghbrep == null) { - this.AddRuntimeWarning("Brep input is null"); - } - - var brep = new Brep(); - if (!GH_Convert.ToBrep(ghbrep, ref brep, GH_Conversion.Both)) { - return; - } - - var points = new Point3dList(); - var ghpts = new List(); - if (da.GetDataList(1, ghpts)) { - foreach (GH_Point point in ghpts) { - var pt = new Point3d(); - if (GH_Convert.ToPoint3d(point, ref pt, GH_Conversion.Both)) { - points.Add(pt); - } - } - } - - var crvs = new List(); - var ghcrvs = new List(); - if (da.GetDataList(2, ghcrvs)) { - foreach (GH_Curve curve in ghcrvs) { - Curve crv = null; - if (GH_Convert.ToCurve(curve, ref crv, GH_Conversion.Both)) { - crvs.Add(crv); - } - } - } - - var mem = new GsaMember2d(); - try { - mem = new GsaMember2d(brep, crvs, points); - } catch (Exception e) { - this.AddRuntimeWarning(e.Message); - } - - GsaProperty2dGoo prop2dGoo = null; - if (da.GetData(3, ref prop2dGoo)) { - mem.Prop2d = prop2dGoo.Value; - } - - double meshSize = 0; - if (da.GetData(4, ref meshSize)) { - mem.ApiMember.MeshSize = meshSize; - } - - da.SetData(0, new GsaMember2dGoo(mem)); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/CreateMember2d3_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateMember2d3_OBSOLETE.cs deleted file mode 100644 index 7869e6f71..000000000 --- a/GsaGH/Components/GraveyardComp/CreateMember2d3_OBSOLETE.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using Rhino.Collections; -using Rhino.Geometry; - -namespace GsaGH.Components { - /// - /// Component to create new 2D Member - /// - public class CreateMember2d3_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("d996b426-9655-4abf-af0d-3e206d252b00"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Create2dMember; - - public CreateMember2d3_OBSOLETE() : base("Create 2D Member", "Mem2D", "Create GSA Member 2D", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddBrepParameter("Brep", "B", - "Planar Brep (non-planar geometry will be automatically converted to an average plane of exterior boundary control points))", - GH_ParamAccess.item); - pManager.AddPointParameter("Incl. Points", "(P)", - "Inclusion points (will automatically be projected onto Brep)", GH_ParamAccess.list); - pManager.AddCurveParameter("Incl. Curves", "(C)", - "Inclusion curves (will automatically be made planar and projected onto brep, and converted to Arcs and Lines)", - GH_ParamAccess.list); - pManager.AddParameter(new GsaProperty2dParameter()); - pManager.AddNumberParameter("Mesh Size in model units", "Ms", "Target mesh size", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Internal Offset", "IO", - "Set Automatic Internal Offset of Member", GH_ParamAccess.item, false); - - pManager.HideParameter(0); - pManager.HideParameter(1); - pManager.HideParameter(2); - - pManager[1].Optional = true; - pManager[2].Optional = true; - pManager[3].Optional = true; - pManager[4].Optional = true; - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaMember2dParameter()); - } - - protected override void SolveInstance(IGH_DataAccess da) { - GH_Brep ghbrep = null; - da.GetData(0, ref ghbrep); - - var points = new Point3dList(); - var ghpts = new List(); - if (da.GetDataList(1, ghpts)) { - points = new Point3dList(ghpts.ConvertAll(pt => pt.Value)); - } - - var crvs = new List(); - var ghcrvs = new List(); - if (da.GetDataList(2, ghcrvs)) { - crvs = ghcrvs.Select(crv => crv.Value).ToList(); - } - - var mem = new GsaMember2d(); - mem = new GsaMember2d(ghbrep.Value, crvs, points); - - GsaProperty2dGoo prop2dGoo = null; - if (da.GetData(3, ref prop2dGoo)) { - mem.Prop2d = prop2dGoo.Value; - } - - double meshSize = 0; - if (da.GetData(4, ref meshSize)) { - mem.ApiMember.MeshSize = meshSize; - } - - bool internalOffset = false; - if (da.GetData(5, ref internalOffset)) { - mem.ApiMember.AutomaticOffset.Internal = internalOffset; - } - - da.SetData(0, new GsaMember2dGoo(mem)); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/CreateMember2d_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateMember2d_OBSOLETE.cs deleted file mode 100644 index 79820cb8c..000000000 --- a/GsaGH/Components/GraveyardComp/CreateMember2d_OBSOLETE.cs +++ /dev/null @@ -1,160 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Components.GraveyardComp; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; -using Rhino.Collections; -using Rhino.Geometry; - -namespace GsaGH.Components { - /// - /// Component to create new 2D Member - /// - // ReSharper disable once InconsistentNaming - public class CreateMember2d_OBSOLETE : GH_OasysDropDownComponent { - public override Guid ComponentGuid => new Guid("df0c2786-9e46-4500-ab63-0c4162a580d4"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Create2dMember; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - - public CreateMember2d_OBSOLETE() : base("Create 2D Member", "Mem2D", "Create GSA Member 2D", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - public override bool Read(GH_IReader reader) { - if (reader.ItemExists("dropdown") || reader.ChunkExists("ParameterData")) { - base.Read(reader); - } else { - BaseReader.Read(reader, this); - _isInitialised = true; - UpdateUIFromSelectedItems(); - } - - GH_IReader attributes = reader.FindChunk("Attributes"); - Attributes.Bounds = (RectangleF)attributes.Items[0].InternalData; - Attributes.Pivot = (PointF)attributes.Items[1].InternalData; - return true; - } - - public override void SetSelected(int i, int j) { - _selectedItems[i] = _dropDownItems[i][j]; - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[i]); - base.UpdateUI(); - } - - public override void VariableParameterMaintenance() { - Params.Input[4].Name = "Mesh Size [" + Length.GetAbbreviation(_lengthUnit) + "]"; - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Unit", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - string unitAbbreviation = Length.GetAbbreviation(_lengthUnit); - - pManager.AddBrepParameter("Brep", "B", - "Planar Brep (non-planar geometry will be automatically converted to an average plane of exterior boundary control points))", - GH_ParamAccess.item); - pManager.AddPointParameter("Incl. Points", "(P)", - "Inclusion points (will automatically be projected onto Brep)", GH_ParamAccess.list); - pManager.AddCurveParameter("Incl. Curves", "(C)", - "Inclusion curves (will automatically be made planar and projected onto brep, and converted to Arcs and Lines)", - GH_ParamAccess.list); - pManager.AddParameter(new GsaProperty2dParameter()); - pManager.AddGenericParameter("Mesh Size [" + unitAbbreviation + "]", "Ms", "Target mesh size", - GH_ParamAccess.item); - - pManager.HideParameter(0); - pManager.HideParameter(1); - pManager.HideParameter(2); - - pManager[1].Optional = true; - pManager[2].Optional = true; - pManager[3].Optional = true; - pManager[4].Optional = true; - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaMember2dParameter()); - } - - protected override void SolveInternal(IGH_DataAccess da) { - var ghbrep = new GH_Brep(); - if (!da.GetData(0, ref ghbrep)) { - return; - } - - if (ghbrep == null) { - this.AddRuntimeWarning("Brep input is null"); - } - - var brep = new Brep(); - if (!GH_Convert.ToBrep(ghbrep, ref brep, GH_Conversion.Both)) { - return; - } - - var point3ds = new Point3dList(); - var ghpts = new List(); - if (da.GetDataList(1, ghpts)) { - foreach (GH_Point point in ghpts) { - var pt = new Point3d(); - if (GH_Convert.ToPoint3d(point, ref pt, GH_Conversion.Both)) { - point3ds.Add(pt); - } - } - } - - var curves = new List(); - var ghCurves = new List(); - if (da.GetDataList(2, ghCurves)) { - foreach (GH_Curve curve in ghCurves) { - Curve crv = null; - if (GH_Convert.ToCurve(curve, ref crv, GH_Conversion.Both)) { - curves.Add(crv); - } - } - } - - var mem = new GsaMember2d(brep, curves, point3ds); - - GsaProperty2dGoo prop2dGoo = null; - if (da.GetData(3, ref prop2dGoo)) { - mem.Prop2d = prop2dGoo.Value; - } - - if (Params.Input[4].SourceCount > 0) { - mem.ApiMember.MeshSize = ((Length)Input.UnitNumber(this, da, 4, _lengthUnit, true)).Meters; - } - - da.SetData(0, new GsaMember2dGoo(mem)); - } - - protected override void UpdateUIFromSelectedItems() { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[0]); - base.UpdateUIFromSelectedItems(); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/CreateMember3d_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateMember3d_OBSOLETE.cs deleted file mode 100644 index 48d77f649..000000000 --- a/GsaGH/Components/GraveyardComp/CreateMember3d_OBSOLETE.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; -using Rhino.Geometry; - -namespace GsaGH.Components { - /// - /// Component to create new 3d Member - /// - // ReSharper disable once InconsistentNaming - public class CreateMember3d_OBSOLETE : GH_OasysDropDownComponent { - public override Guid ComponentGuid => new Guid("df0c7608-9e46-4500-ab63-0c4162a580d4"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Create3dMember; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - - public CreateMember3d_OBSOLETE() : base("Create 3D Member", "Mem3D", "Create GSA Member 3D", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - public override void SetSelected(int i, int j) { - _selectedItems[i] = _dropDownItems[i][j]; - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[i]); - base.UpdateUI(); - } - - public override void VariableParameterMaintenance() { - Params.Input[2].Name = "Mesh Size [" + Length.GetAbbreviation(_lengthUnit) + "]"; - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Unit", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - string unitAbbreviation = Length.GetAbbreviation(_lengthUnit); - - pManager.AddGeometryParameter("Solid", "S", "Solid Geometry - Closed Brep or Mesh", - GH_ParamAccess.item); - pManager.AddParameter(new GsaProperty3dParameter()); - pManager.AddGenericParameter("Mesh Size [" + unitAbbreviation + "]", "Ms", "Targe mesh size", - GH_ParamAccess.item); - - pManager[1].Optional = true; - pManager[2].Optional = true; - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaMember3dParameter()); - } - - protected override void SolveInternal(IGH_DataAccess da) { - var ghTyp = new GH_ObjectWrapper(); - if (!da.GetData(0, ref ghTyp)) { - return; - } - - if (ghTyp == null) { - this.AddRuntimeWarning("Solid input is null"); - } - - GsaMember3d member; - var brep = new Brep(); - var mesh = new Mesh(); - if (GH_Convert.ToBrep(ghTyp.Value, ref brep, GH_Conversion.Both)) { - if (brep.IsValid) { - member = new GsaMember3d(brep); - } else { - this.AddRuntimeError("S input is not a valid Brep geometry"); - return; - } - } else if (GH_Convert.ToMesh(ghTyp.Value, ref mesh, GH_Conversion.Both)) { - member = new GsaMember3d(mesh); - } else { - this.AddRuntimeError("Unable to convert Geometry input to a 3D Member"); - return; - } - - GsaProperty3dGoo prop3dGoo = null; - if (da.GetData(1, ref prop3dGoo)) { - member.Prop3d = prop3dGoo.Value; - } - - if (Params.Input[2].SourceCount > 0) { - member.ApiMember.MeshSize = ((Length)Input.UnitNumber(this, da, 2, _lengthUnit, true)).Meters; - } - - da.SetData(0, new GsaMember3dGoo(member)); - } - - protected override void UpdateUIFromSelectedItems() { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[0]); - base.UpdateUIFromSelectedItems(); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/CreateProfile_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateProfile_OBSOLETE.cs deleted file mode 100644 index e52fea350..000000000 --- a/GsaGH/Components/GraveyardComp/CreateProfile_OBSOLETE.cs +++ /dev/null @@ -1,1576 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text.RegularExpressions; -using GH_IO.Serialization; -using Grasshopper; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Data; -using Grasshopper.Kernel.Parameters; -using Grasshopper.Kernel.Types; -using GsaGH.Graveyard; -using GsaGH.Helpers.GH; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; -using Rhino.Collections; -using Rhino.Geometry; - -namespace GsaGH.Components { - /// - /// Component to create AdSec profile - /// - public class CreateProfile_OBSOLETE : GH_OasysDropDownComponent { - private enum FoldMode { - Catalogue, - Other, - } - - public override Guid ComponentGuid => new Guid("ea1741e5-905e-4ecb-8270-a584e3f99aa3"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.CreateProfile; - private static readonly List easterCat = new List() { - "▌─────────────────────────▐█─────▐" + Environment.NewLine - + "▌────▄──────────────────▄█▓█▌────▐" + Environment.NewLine - + "▌───▐██▄───────────────▄▓░░▓▓────▐" + Environment.NewLine - + "▌───▐█░██▓────────────▓▓░░░▓▌────▐" + Environment.NewLine - + "▌───▐█▌░▓██──────────█▓░░░░▓─────▐" + Environment.NewLine - + "▌────▓█▌░░▓█▄███████▄███▓░▓█─────▐" + Environment.NewLine - + "▌────▓██▌░▓██░░░░░░░░░░▓█░▓▌─────▐" + Environment.NewLine - + "▌─────▓█████░░░░░░░░░░░░▓██──────▐" + Environment.NewLine - + "▌─────▓██▓░░░░░░░░░░░░░░░▓█──────▐" + Environment.NewLine - + "▌─────▐█▓░░░░░░█▓░░▓█░░░░▓█▌─────▐" + Environment.NewLine - + "▌─────▓█▌░▓█▓▓██▓░█▓▓▓▓▓░▓█▌─────▐" + Environment.NewLine - + "▌─────▓▓░▓██████▓░▓███▓▓▌░█▓─────▐" + Environment.NewLine - + "▌────▐▓▓░█▄▐▓▌█▓░░▓█▐▓▌▄▓░██─────▐" + Environment.NewLine - + "▌────▓█▓░▓█▄▄▄█▓░░▓█▄▄▄█▓░██▌────▐" + Environment.NewLine - + "▌────▓█▌░▓█████▓░░░▓███▓▀░▓█▓────▐" + Environment.NewLine - + "▌───▐▓█░░░▀▓██▀░░░░░─▀▓▀░░▓█▓────▐" + Environment.NewLine - + "▌───▓██░░░░░░░░▀▄▄▄▄▀░░░░░░▓▓────▐" + Environment.NewLine - + "▌───▓█▌░░░░░░░░░░▐▌░░░░░░░░▓▓▌───▐" + Environment.NewLine - + "▌───▓█░░░░░░░░░▄▀▀▀▀▄░░░░░░░█▓───▐" + Environment.NewLine - + "▌──▐█▌░░░░░░░░▀░░░░░░▀░░░░░░█▓▌──▐" + Environment.NewLine - + "▌──▓█░░░░░░░░░░░░░░░░░░░░░░░██▓──▐" + Environment.NewLine - + "▌──▓█░░░░░░░░░░░░░░░░░░░░░░░▓█▓──▐" + Environment.NewLine - + "▌──██░░░░░░░░░░░░░░░░░░░░░░░░█▓──▐" + Environment.NewLine - + "▌──█▌░░░░░░░░░░░░░░░░░░░░░░░░▐▓▌─▐" + Environment.NewLine - + "▌─▐▓░░░░░░░░░░░░░░░░░░░░░░░░░░█▓─▐" + Environment.NewLine - + "▌─█▓░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓─▐" + Environment.NewLine - + "▌─█▓░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▌▐" + Environment.NewLine - + "▌▐█▓░░░░░░░░░░░░░░░░░░░░░░░░░░░██▐" + Environment.NewLine - + "▌█▓▌░░░░░░░░░░░░░░░░░░░░░░░░░░░▓█▐", }; - private static readonly Dictionary profileTypes - = new Dictionary { - { - "Angle", "IAngleProfile" - }, { - "Catalogue", "ICatalogueProfile" - }, { - "Channel", "IChannelProfile" - }, { - "Circle Hollow", "ICircleHollowProfile" - }, { - "Circle", "ICircleProfile" - }, { - "Cruciform Symmetrical", "ICruciformSymmetricalProfile" - }, { - "Ellipse Hollow", "IEllipseHollowProfile" - }, { - "Ellipse", "IEllipseProfile" - }, { - "General C", "IGeneralCProfile" - }, { - "General Z", "IGeneralZProfile" - }, { - "I Beam Asymmetrical", "IIBeamAsymmetricalProfile" - }, { - "I Beam Cellular", "IIBeamCellularProfile" - }, { - "I Beam Symmetrical", "IIBeamSymmetricalProfile" - }, { - "Perimeter", "IPerimeterProfile" - }, { - "Rectangle Hollow", "IRectangleHollowProfile" - }, { - "Rectangle", "IRectangleProfile" - }, { - "Recto Ellipse", "IRectoEllipseProfile" - }, { - "Recto Circle", "IStadiumProfile" - }, { - "Secant Pile", "ISecantPileProfile" - }, { - "Sheet Pile", "ISheetPileProfile" - }, { - "Trapezoid", "ITrapezoidProfile" - }, { - "T Section", "ITSectionProfile" - }, - }; - private readonly Tuple, List> _cataloguedata; - private int _catalogueIndex = -1; - private List _catalogueNames = new List(); - private List _catalogueNumbers = new List(); - private bool _inclSs; - private bool _lastInputWasSecant; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitSection; - private FoldMode _mode = FoldMode.Other; - private int _numberOfInputs; - private List _profileString = new List() { - "CAT HE HE200.B", - }; - private string _search = string.Empty; - private List _sectionList; - private string _type = "IRectangleProfile"; - private Tuple, List> _typedata; - private int _typeIndex = -1; - private List _typeNames = new List(); - private List _typeNumbers = new List(); - - public CreateProfile_OBSOLETE() : base("Create Profile", "Profile", - "Create Profile text-string for a GSA Section", CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - _cataloguedata - = SqlReader.Instance.GetCataloguesDataFromSQLite( - Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3")); - _typedata = SqlReader.Instance.GetTypesDataFromSQLite(-1, - Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3")); - _sectionList = SqlReader.Instance.GetSectionsDataFromSQLite(new List { - -1, - }, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3")); - } - - public override bool Read(GH_IReader reader) { - _mode = (FoldMode)Enum.Parse(typeof(FoldMode), reader.GetString("mode")); - _lengthUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("lengthUnit")); - _inclSs = reader.GetBoolean("inclSS"); - _numberOfInputs = reader.GetInt32("NumberOfInputs"); - _catalogueIndex = reader.GetInt32("catalogueIndex"); - _typeIndex = reader.GetInt32("typeIndex"); - _search = reader.GetString("search"); - - bool flag = base.Read(reader); - Params.Output[0].Access = GH_ParamAccess.tree; - return flag; - } - - public override void SetSelected(int i, int j) { - bool updateCat = false; - if (i == -1) { - _selectedItems[0] = "Catalogue"; - updateCat = true; - i = 0; - } else { - _selectedItems[i] = _dropDownItems[i][j]; - } - - if (_selectedItems[0] == "Catalogue") { - _spacerDescriptions[1] = "Catalogue"; - - if ((_mode != FoldMode.Catalogue) | updateCat) { - while (_selectedItems.Count > 1) { - _selectedItems.RemoveAt(1); - } - - _catalogueIndex = -1; - - _catalogueNames = _cataloguedata.Item1; - _catalogueNumbers = _cataloguedata.Item2; - - _typeIndex = -1; - UpdateTypeData(); - - _sectionList = SqlReader.Instance.GetSectionsDataFromSQLite(_typeNumbers, - Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSs); - - _selectedItems.Add(_catalogueNames[0]); - _selectedItems.Add(_typeNames[0]); - _selectedItems.Add(_sectionList[0]); - - Mode1Clicked(); - } - - while (_dropDownItems.Count > 1) { - _dropDownItems.RemoveAt(1); - } - - _dropDownItems.Add(_catalogueNames); - - if (i == 1) { - _catalogueIndex = _catalogueNumbers[j]; - _selectedItems[1] = _catalogueNames[j]; - - _typedata = SqlReader.Instance.GetTypesDataFromSQLite(_catalogueIndex, - Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSs); - _typeNames = _typedata.Item1; - _typeNumbers = _typedata.Item2; - - var types = _typeNumbers.ToList(); - types.RemoveAt(0); - _sectionList = SqlReader.Instance.GetSectionsDataFromSQLite(types, - Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSs); - - _selectedItems[2] = _typeNames[0]; - _selectedItems[3] = _sectionList[0]; - } - - _dropDownItems.Add(_typeNames); - - if (i == 2) { - _typeIndex = _typeNumbers[j]; - _selectedItems[2] = _typeNames[j]; - - List types; - if (_typeIndex == -1) { - types = _typeNumbers.ToList(); - types.RemoveAt(0); - } else { - types = new List { - _typeIndex, - }; - } - - _sectionList = SqlReader.Instance.GetSectionsDataFromSQLite(types, - Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSs); - - _selectedItems[3] = _sectionList[0]; - } - - _dropDownItems.Add(_sectionList); - - if (i == 3) { - _selectedItems[3] = _sectionList[j]; - } - - if (_search == string.Empty) { - UpdateProfileString(); - } - - base.UpdateUI(); - } else { - _spacerDescriptions[1] = "Measure"; - - if (_mode != FoldMode.Other) { - while (_dropDownItems.Count > 1) { - _dropDownItems.RemoveAt(1); - } - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - - _selectedItems[1] = _lengthUnit.ToString(); - } - - if (i == 0) { - _type = profileTypes[_selectedItems[0]]; - Mode2Clicked(); - } else { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[i]); - - base.UpdateUI(); - } - } - } - - public override void VariableParameterMaintenance() { - if (_mode == FoldMode.Catalogue) { - int i = 0; - Params.Input[i].NickName = "S"; - Params.Input[i].Name = "Search"; - Params.Input[i].Description = "Text to search from"; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = true; - - i++; - Params.Input[i].NickName = "iSS"; - Params.Input[i].Name = "InclSuperseeded"; - Params.Input[i].Description = "Input true to include superseeded catalogue sections"; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = true; - } else { - string unitAbbreviation = Length.GetAbbreviation(_lengthUnit); - - int i = 0; - switch (_type) { - case "IAngleProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description - = "The depth of the angle profile (leg in the local z axis)."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "W"; - Params.Input[i].Name = "Width [" + unitAbbreviation + "]"; - Params.Input[i].Description - = "The width of the angle profile (leg in the local y axis)."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tw"; - Params.Input[i].Name = "Web Thk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The web thickness of the angle profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tf"; - Params.Input[i].Name = "Flange Thk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The flange thickness of the angle profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "IChannelProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The depth of the channel profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "B"; - Params.Input[i].Name = "Width [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The width of the flange of the channel profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tw"; - Params.Input[i].Name = "Web Thk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The web thickness of the channel profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tf"; - Params.Input[i].Name = "Flange Thk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The flange thickness of the channel profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - Params.Input[i].Optional = false; - break; - - case "ICircleHollowProfile": - Params.Input[i].NickName = "Ø"; - Params.Input[i].Name = "Diameter [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The diameter of the hollow circle."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "t"; - Params.Input[i].Name = "Thickness [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The wall thickness of the hollow circle."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "ICircleProfile": - Params.Input[i].NickName = "Ø"; - Params.Input[i].Name = "Diameter [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The diameter of the circle."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "ICruciformSymmetricalProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The depth (local z axis leg) of the profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "B"; - Params.Input[i].Name = "Width [" + unitAbbreviation + "]"; - Params.Input[i].Description - = "The width of the flange (local y axis leg) of the cruciform."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tw"; - Params.Input[i].Name = "Web Thk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The web thickness of the cruciform."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tf"; - Params.Input[i].Name = "Flange Thk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The flange thickness of the cruciform."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "IEllipseHollowProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The depth of the hollow ellipse."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "B"; - Params.Input[i].Name = "Width [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The width of the hollow ellipse."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "t"; - Params.Input[i].Name = "Thickness [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The wall thickness of the hollow ellipse."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "IEllipseProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The depth of the ellipse."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "B"; - Params.Input[i].Name = "Width [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The width of the ellipse."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "IGeneralCProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The depth of the generic c section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "B"; - Params.Input[i].Name = "Width [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The flange width of the generic c section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "L"; - Params.Input[i].Name = "Lip [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The lip of the generic c section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "t"; - Params.Input[i].Name = "Thickness [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The thickness of the generic c section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "IGeneralZProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The depth of the generic z section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Bt"; - Params.Input[i].Name = "TopWidth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The top flange width of the generic z section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Bb"; - Params.Input[i].Name = "BottomWidth [" + unitAbbreviation + "]"; - Params.Input[i].Description - = "The bottom flange width of the generic z section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Lt"; - Params.Input[i].Name = "Top Lip [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The top lip of the generic z section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Lb"; - Params.Input[i].Name = "Lip [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The top lip of the generic z section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "t"; - Params.Input[i].Name = "Thickness [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The thickness of the generic z section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "IIBeamAsymmetricalProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The depth of the profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Bt"; - Params.Input[i].Name = "TopFlangeWidth [" + unitAbbreviation + "]"; - Params.Input[i].Description - = "The width of the top flange of the beam. Top is relative to the beam local access."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Bb"; - Params.Input[i].Name = "BottomFlangeWidth [" + unitAbbreviation + "]"; - Params.Input[i].Description - = "The width of the bottom flange of the beam. Bottom is relative to the beam local access."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Web"; - Params.Input[i].Name = "Web Thickness [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The web thickness of the beam."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tt"; - Params.Input[i].Name = "TopFlangeThk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The top flange thickness."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tb"; - Params.Input[i].Name = "BottomFlangeThk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The bpttom flange thickness."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "IIBeamCellularProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The depth of the profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "B"; - Params.Input[i].Name = "Width [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The width of the flanges of the beam."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tw"; - Params.Input[i].Name = "Web Thk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The web thickness of the angle profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tf"; - Params.Input[i].Name = "Flange Thk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The flange thickness of the angle profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "O"; - Params.Input[i].Name = "WebOpening [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The size of the web opening."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "P"; - Params.Input[i].Name = "Pitch [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The pitch (spacing) between the web openings."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "IIBeamSymmetricalProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The depth of the profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "B"; - Params.Input[i].Name = "Width [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The width of the flanges of the beam."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tw"; - Params.Input[i].Name = "Web Thk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The web thickness of the angle profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tf"; - Params.Input[i].Name = "Flange Thk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The flange thickness of the angle profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "IRectangleHollowProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The depth of the hollow rectangle."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "B"; - Params.Input[i].Name = "Width [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The width of the hollow rectangle."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tw"; - Params.Input[i].Name = "Web Thk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The side thickness of the hollow rectangle."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tf"; - Params.Input[i].Name = "Flange Thk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The top/bottom thickness of the hollow rectangle."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "IRectangleProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "Depth of the rectangle, in local z-axis direction."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "B"; - Params.Input[i].Name = "Width [" + unitAbbreviation + "]"; - Params.Input[i].Description = "Width of the rectangle, in local y-axis direction."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "IRectoEllipseProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The overall depth of the recto-ellipse profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Df"; - Params.Input[i].Name = "DepthFlat [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The flat length of the profile's overall depth."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "B"; - Params.Input[i].Name = "Width [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The overall width of the recto-ellipse profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Bf"; - Params.Input[i].Name = "WidthFlat [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The flat length of the profile's overall width."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "ISecantPileProfile": - Params.Input[i].NickName = "Ø"; - Params.Input[i].Name = "Diameter [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The diameter of the piles."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "c/c"; - Params.Input[i].Name = "PileCentres [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The centre to centre distance between adjacent piles."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "No"; - Params.Input[i].Name = "PileCount"; - Params.Input[i].Description = "The number of piles in the profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "W/S"; - Params.Input[i].Name = "isWall"; - Params.Input[i].Description - = "Converts the profile into a wall secant pile profile if true -- Converts the profile into a section secant pile profile if false."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "ISheetPileProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The depth of the sheet pile section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "B"; - Params.Input[i].Name = "Width [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The overall width of the sheet pile section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Bt"; - Params.Input[i].Name = "TopFlangeWidth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The top flange width of the sheet pile section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Bb"; - Params.Input[i].Name = "BottomFlangeWidth [" + unitAbbreviation + "]"; - Params.Input[i].Description - = "The bottom flange width of the sheet pile section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Ft"; - Params.Input[i].Name = "FlangeThickness [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The flange thickness of the sheet pile section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Wt"; - Params.Input[i].Name = "WebThickness [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The web thickness of the sheet pile section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "IStadiumProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description - = "The profile's overall depth considering the side length of the rectangle and the radii of the semicircles on the two ends."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "B"; - Params.Input[i].Name = "Width [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The profile's width (diameter of the semicircles)."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "ITrapezoidProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The depth in z-axis direction of trapezoidal profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Bt"; - Params.Input[i].Name = "TopWidth [" + unitAbbreviation + "]"; - Params.Input[i].Description - = "The top width of trapezoidal profile. Top is relative to the local z-axis."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Bb"; - Params.Input[i].Name = "BottomWidth [" + unitAbbreviation + "]"; - Params.Input[i].Description - = "The bottom width of trapezoidal profile. Bottom is relative to the local z-axis."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "ITSectionProfile": - Params.Input[i].NickName = "D"; - Params.Input[i].Name = "Depth [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The depth of the T section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "B"; - Params.Input[i].Name = "Width [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The width of the T section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tw"; - Params.Input[i].Name = "Web Thk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The web thickness of the T section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - i++; - Params.Input[i].NickName = "Tf"; - Params.Input[i].Name = "Flange Thk [" + unitAbbreviation + "]"; - Params.Input[i].Description = "The flange thickness of the T section profile."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - break; - - case "IPerimeterProfile": - Params.Input[i].NickName = "B"; - Params.Input[i].Name = "Boundary"; - Params.Input[i].Description = "Planar Brep or closed planar curve."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = false; - - if (Params.Input.Count == 1) { - Params.RegisterInputParam(new Param_Plane()); - } - - i++; - Params.Input[i].NickName = "P"; - Params.Input[i].Name = "Plane"; - Params.Input[i].Description - = "Optional plane in which to project boundary onto. Profile will get coordinates in this plane."; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = true; - break; - } - } - } - - public override bool Write(GH_IWriter writer) { - writer.SetString("mode", _mode.ToString()); - writer.SetString("lengthUnit", _lengthUnit.ToString()); - writer.SetBoolean("inclSS", _inclSs); - writer.SetInt32("NumberOfInputs", _numberOfInputs); - writer.SetInt32("catalogueIndex", _catalogueIndex); - writer.SetInt32("typeIndex", _typeIndex); - writer.SetString("search", _search); - return base.Write(writer); - } - - protected override string HtmlHelp_Source() { - string help - = "GOTO:https://arup-group.github.io/oasys-combined/adsec-api/api/Oasys.Profiles.html"; - return help; - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Profile type", - "Measure", - "Type", - "Profile", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(profileTypes.Keys.ToList()); - _selectedItems.Add("Rectangle"); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - string unitAbbreviation = Length.GetAbbreviation(_lengthUnit); - pManager.AddGenericParameter("Width [" + unitAbbreviation + "]", "B", "Profile width", - GH_ParamAccess.item); - pManager.AddGenericParameter("Depth [" + unitAbbreviation + "]", "H", "Profile depth", - GH_ParamAccess.item); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddTextParameter("Profile", "Pf", "Profile for a GSA Section", GH_ParamAccess.tree); - } - - protected override void SolveInternal(IGH_DataAccess da) { - ClearRuntimeMessages(); - foreach (IGH_Param input in Params.Input) { - input.ClearRuntimeMessages(); - } - - #region catalogue - - ClearRuntimeMessages(); - if (_mode == FoldMode.Catalogue) { - bool incl = false; - if (da.GetData(1, ref incl)) { - if (_inclSs != incl) { - _inclSs = incl; - UpdateTypeData(); - _sectionList = SqlReader.Instance.GetSectionsDataFromSQLite(_typeNumbers, - Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSs); - - _selectedItems[2] = _typeNames[0]; - _dropDownItems[2] = _typeNames; - - _selectedItems[3] = _sectionList[0]; - _dropDownItems[3] = _sectionList; - - base.UpdateUI(); - } - } - - _search = null; - string inSearch = string.Empty; - if (da.GetData(0, ref inSearch)) { - _search = inSearch.Trim().ToLower().Replace(".", string.Empty).Replace("*", ".*") - .Replace(" ", ".*"); - if (_search == "cat") { - string eventName = "EasterCat"; - var properties = new Dictionary(); - _ = PostHog.SendToPostHog(GsaGH.PluginInfo.Instance, eventName, properties); - da.SetDataList(0, easterCat); - return; - } - - if (_search.Contains("cat")) { - string[] s = _search.Split(new[] { - "cat", - }, StringSplitOptions.None); - _search = s[s.Length - 1]; - } - - bool tryHard = Regex.Match(_search, "he[abcm]", RegexOptions.Singleline).Success; - - var filteredlist = new List(); - if (_selectedItems[3] != "All") { - if (!MatchAndAdd(_selectedItems[3], _search, ref filteredlist, tryHard)) { - _profileString = new List(); - this.AddRuntimeWarning("No profile found that matches selected profile and search!"); - } - } else if (_search != string.Empty) { - foreach (string section in _sectionList) { - if (MatchAndAdd(section, _search, ref filteredlist, tryHard)) { } else if ( - !_search.Any(char.IsDigit)) { - string test = section; - test = Regex.Replace(test, "[0-9]", string.Empty); - test = test.Replace(".", string.Empty); - test = test.Replace("-", string.Empty); - test = test.ToLower(); - if (test.Contains(_search)) { - filteredlist.Add(section); - } - } - } - } - - _profileString = new List(); - if (filteredlist.Count > 0) { - foreach (string profile in filteredlist) { - _profileString.Add("CAT " + profile); - } - } else { - this.AddRuntimeWarning("No profile found that matches selection and search!"); - } - } - - if (_search == null) { - UpdateProfileString(); - } - - var tree = new DataTree(); - - int pathCount = 0; - if (Params.Output[0].VolatileDataCount > 0) { - pathCount = Params.Output[0].VolatileData.PathCount; - } - - var path = new GH_Path(new[] { - pathCount, - }); - if (_profileString.Count > 0) { - tree.AddRange(_profileString, path); - } else { - tree.Add(null, path); - } - - da.SetDataTree(0, tree); - } - - #endregion - - #region std - - if (_mode != FoldMode.Other) { - return; - } else { - string unit = "(" + Length.GetAbbreviation(_lengthUnit, new CultureInfo("en")) + ") "; - string profile = "STD "; - switch (_type) { - case "IAngleProfile": - profile += "A" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 2, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 3, _lengthUnit).As(_lengthUnit); - break; - - case "IChannelProfile": - profile += "CH" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 2, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 3, _lengthUnit).As(_lengthUnit); - break; - - case "ICircleHollowProfile": - profile += "CHS" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit); - break; - - case "ICircleProfile": - profile += "C" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit); - break; - - case "ICruciformSymmetricalProfile": - profile += "X" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 2, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 3, _lengthUnit).As(_lengthUnit); - break; - - case "IEllipseHollowProfile": - profile += "OVAL" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 2, _lengthUnit).As(_lengthUnit); - break; - - case "IEllipseProfile": - profile += "E" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " 2"; - break; - - case "IGeneralCProfile": - profile += "GC" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 2, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 3, _lengthUnit).As(_lengthUnit); - break; - - case "IGeneralZProfile": - profile += "GZ" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 2, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 3, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 4, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 5, _lengthUnit).As(_lengthUnit); - break; - - case "IIBeamAsymmetricalProfile": - profile += "GI" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 2, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 3, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 4, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 5, _lengthUnit).As(_lengthUnit); - break; - - case "IIBeamCellularProfile": - profile += "CB" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 2, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 3, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 4, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 5, _lengthUnit).As(_lengthUnit); - break; - - case "IIBeamSymmetricalProfile": - profile += "I" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 2, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 3, _lengthUnit).As(_lengthUnit); - break; - - case "IRectangleHollowProfile": - profile += "RHS" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 2, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 3, _lengthUnit).As(_lengthUnit); - break; - - case "IRectangleProfile": - profile += "R" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit); - break; - - case "IRectoEllipseProfile": - profile += "RE" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 2, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 3, _lengthUnit).As(_lengthUnit) + " 2"; - break; - - case "ISecantPileProfile": - int pileCount = 0; - if (!da.GetData(2, ref pileCount)) { - this.AddRuntimeError("Unable to convert input PileCount to integer."); - return; - } - - bool isWallNotSection = false; - if (!da.GetData(3, ref isWallNotSection)) { - this.AddRuntimeError("Unable to convert input isWall to boolean."); - return; - } - - profile += (isWallNotSection ? "SP" : "SPW") + unit - + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " " + pileCount; - break; - - case "ISheetPileProfile": - profile += "SHT" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 2, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 3, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 4, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 5, _lengthUnit).As(_lengthUnit); - break; - - case "IStadiumProfile": - profile += "RC" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit); - break; - - case "ITrapezoidProfile": - profile += "TR" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 2, _lengthUnit).As(_lengthUnit); - break; - - case "ITSectionProfile": - profile += "T" + unit + Input.LengthOrRatio(this, da, 0, _lengthUnit).As(_lengthUnit) - + " " + Input.LengthOrRatio(this, da, 1, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 2, _lengthUnit).As(_lengthUnit) + " " - + Input.LengthOrRatio(this, da, 3, _lengthUnit).As(_lengthUnit); - break; - - case "IPerimeterProfile": - var perimeter = new ProfileHelper() { - ProfileType = ProfileHelper.ProfileTypes.Geometric, - }; - var ghBrep = new GH_Brep(); - - if (da.GetData(0, ref ghBrep)) { - var brep = new Brep(); - if (GH_Convert.ToBrep(ghBrep, ref brep, GH_Conversion.Both)) { - Curve[] edgeSegments = brep.DuplicateEdgeCurves(); - Curve[] edges = Curve.JoinCurves(edgeSegments); - - var ctrlPts = new Point3dList(); - if (edges[0].TryGetPolyline(out Polyline tempCrv)) { - ctrlPts = new Point3dList(tempCrv); - } else { - this.AddRuntimeError("Cannot convert edge to Polyline"); - return; - } - - bool localPlaneNotSet = true; - Plane plane = Plane.Unset; - if (da.GetData(1, ref plane)) { - localPlaneNotSet = false; - } - - var origin = new Point3d(); - if (localPlaneNotSet) { - foreach (Point3d p in ctrlPts) { - origin.X += p.X; - origin.Y += p.Y; - origin.Z += p.Z; - } - - origin.X /= origin.X / ctrlPts.Count; - origin.Y /= ctrlPts.Count; - origin.Z /= ctrlPts.Count; - - Plane.FitPlaneToPoints(ctrlPts, out plane); - - var xDirection = new Vector3d(Math.Abs(plane.XAxis.X), Math.Abs(plane.XAxis.Y), - Math.Abs(plane.XAxis.Z)); - xDirection.Unitize(); - var yDirection = new Vector3d(Math.Abs(plane.YAxis.X), Math.Abs(plane.YAxis.Y), - Math.Abs(plane.YAxis.Z)); - xDirection.Unitize(); - - Vector3d normal = plane.Normal; - normal.Unitize(); - plane = normal.X == 1 ? - Plane.WorldYZ : - normal.Y == 1 ? - Plane.WorldZX : - normal.Z == 1 ? - Plane.WorldXY : - new Plane(Point3d.Origin, xDirection, yDirection); - - plane.Origin = origin; - } else { - origin = plane.Origin; - } - - var translation = Transform.Translation(-origin.X, -origin.Y, -origin.Z); - var rotation = Transform.ChangeBasis(Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis, - plane.XAxis, plane.YAxis, plane.ZAxis); - if (localPlaneNotSet) { - rotation = Transform.ChangeBasis(Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis, - plane.YAxis, plane.XAxis, plane.ZAxis); - } - - perimeter.GeoType = ProfileHelper.GeoTypes.Perim; - - var pts = new List(); - foreach (Point3d pt3d in ctrlPts) { - pt3d.Transform(translation); - pt3d.Transform(rotation); - var pt2d = new Point2d(pt3d); - pts.Add(pt2d); - } - - perimeter.PerimeterPoints = pts; - - if (edges.Length > 1) { - var voidPoints = new List>(); - for (int i = 1; i < edges.Length; i++) { - ctrlPts.Clear(); - if (!edges[i].IsPlanar()) { - for (int j = 0; j < edges.Length; j++) { - edges[j] = Curve.ProjectToPlane(edges[j], plane); - } - } - - if (edges[i].TryGetPolyline(out tempCrv)) { - ctrlPts = new Point3dList(tempCrv); - pts = new List(); - foreach (Point3d pt3d in ctrlPts) { - pt3d.Transform(translation); - pt3d.Transform(rotation); - var pt2d = new Point2d(pt3d); - pts.Add(pt2d); - } - - voidPoints.Add(pts); - } else { - this.AddRuntimeError("Cannot convert internal edge to Polyline"); - return; - } - } - - perimeter.VoidPoints = voidPoints; - } - } - } - - switch (_lengthUnit) { - case LengthUnit.Millimeter: - perimeter.SectUnit = ProfileHelper.SectUnitOptions.UMm; - break; - - case LengthUnit.Centimeter: - perimeter.SectUnit = ProfileHelper.SectUnitOptions.UCm; - break; - - case LengthUnit.Meter: - perimeter.SectUnit = ProfileHelper.SectUnitOptions.Um; - break; - - case LengthUnit.Foot: - perimeter.SectUnit = ProfileHelper.SectUnitOptions.UFt; - break; - - case LengthUnit.Inch: - perimeter.SectUnit = ProfileHelper.SectUnitOptions.UIn; - break; - } - - da.SetData(0, ConvertSection.ProfileConversion(perimeter)); - return; - default: - this.AddRuntimeError("Unable to create profile"); - return; - } - - da.SetData(0, profile); - } - - #endregion - } - - protected override void UpdateUIFromSelectedItems() { - if (_selectedItems[0] == "Catalogue") { - _spacerDescriptions = new List(new[] { - "Profile type", - "Catalogue", - "Type", - "Profile", - }); - - _catalogueNames = _cataloguedata.Item1; - _catalogueNumbers = _cataloguedata.Item2; - _typedata = SqlReader.Instance.GetTypesDataFromSQLite(_catalogueIndex, - Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSs); - _typeNames = _typedata.Item1; - _typeNumbers = _typedata.Item2; - - Mode1Clicked(); - - _profileString = new List() { - "CAT " + _selectedItems[3], - }; - } else { - _spacerDescriptions = new List(new[] { - "Profile type", - "Measure", - "Type", - "Profile", - }); - - _type = profileTypes[_selectedItems[0]]; - Mode2Clicked(); - } - - base.UpdateUIFromSelectedItems(); - } - - private static Tuple, List> GetTypesDataFromSqLite( - int catalogueIndex, string filePath, bool inclSuperseeded) { - return SqlReader.Instance.GetTypesDataFromSQLite(catalogueIndex, filePath, - inclSuperseeded); - } - - private static bool MatchAndAdd( - string item, string pattern, ref List list, bool tryHard = false) { - string input = item.ToLower().Replace(".", string.Empty); - if (Regex.Match(input, pattern, RegexOptions.Singleline).Success) { - list.Add(item); - return true; - } - - if (!tryHard || !Regex.Match(pattern, "he[abcm]", RegexOptions.Singleline).Success) { - return false; - } - - string[] substring = pattern.Split(new[] { - "he", - }, StringSplitOptions.None); - int count = 1; - if (substring[substring.Length - 1].Length > 1 - && !char.IsNumber(substring[substring.Length - 1][1])) { - count = 2; - } - - pattern = "he" + substring[substring.Length - 1].Remove(0, count) - + substring[substring.Length - 1].Substring(0, count); - if (!Regex.Match(input, pattern, RegexOptions.Singleline).Success) { - return false; - } - - list.Add(item); - return true; - } - - private void Mode1Clicked() { - while (Params.Input.Count > 0) { - Params.UnregisterInputParameter(Params.Input[0], true); - } - - Params.RegisterInputParam(new Param_String()); - Params.RegisterInputParam(new Param_Boolean()); - - _mode = FoldMode.Catalogue; - - base.UpdateUI(); - } - - private void Mode2Clicked() { - if (_mode != FoldMode.Other) { - while (Params.Input.Count > 0) { - Params.UnregisterInputParameter(Params.Input[0], true); - } - - _mode = FoldMode.Other; - } - - switch (_type) { - case "IAngleProfile": - case "IChannelProfile": - SetNumberOfGenericInputs(4); - break; - - case "ICircleHollowProfile": - SetNumberOfGenericInputs(2); - break; - - case "ICircleProfile": - SetNumberOfGenericInputs(1); - break; - - case "ICruciformSymmetricalProfile": - SetNumberOfGenericInputs(4); - break; - - case "IEllipseHollowProfile": - SetNumberOfGenericInputs(3); - break; - - case "IEllipseProfile": - SetNumberOfGenericInputs(2); - break; - - case "IGeneralCProfile": - SetNumberOfGenericInputs(4); - break; - - case "IGeneralZProfile": - case "IIBeamAsymmetricalProfile": - case "IIBeamCellularProfile": - SetNumberOfGenericInputs(6); - break; - - case "IIBeamSymmetricalProfile": - case "IRectangleHollowProfile": - SetNumberOfGenericInputs(4); - break; - - case "IRectangleProfile": - SetNumberOfGenericInputs(2); - break; - - case "IRectoEllipseProfile": - SetNumberOfGenericInputs(4); - break; - - case "ISecantPileProfile": - SetNumberOfGenericInputs(4, true); - break; - - case "ISheetPileProfile": - SetNumberOfGenericInputs(6); - break; - - case "IStadiumProfile": - SetNumberOfGenericInputs(2); - break; - - case "ITrapezoidProfile": - SetNumberOfGenericInputs(3); - break; - - case "ITSectionProfile": - SetNumberOfGenericInputs(4); - break; - - case "IPerimeterProfile": - SetNumberOfGenericInputs(1, false, true); - break; - } - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - - private void SetNumberOfGenericInputs( - int inputs, bool isSecantPile = false, bool isPerimeter = false) { - _numberOfInputs = inputs; - if (_lastInputWasSecant || isSecantPile || isPerimeter) { - if (Params.Input.Count > 0) { - Params.UnregisterInputParameter(Params.Input[Params.Input.Count - 1], true); - Params.UnregisterInputParameter(Params.Input[Params.Input.Count - 1], true); - } - } - - while (Params.Input.Count > inputs) { - Params.UnregisterInputParameter(Params.Input[inputs], true); - } - - if (isSecantPile) { - while (Params.Input.Count > inputs + 2) { - Params.UnregisterInputParameter(Params.Input[inputs + 2], true); - } - - inputs -= 2; - } - - while (Params.Input.Count < inputs) { - Params.RegisterInputParam(new Param_GenericObject()); - } - - if (isSecantPile) { - Params.RegisterInputParam(new Param_Integer()); - Params.RegisterInputParam(new Param_Boolean()); - _lastInputWasSecant = true; - } else { - _lastInputWasSecant = false; - } - - if (isPerimeter) { - Params.RegisterInputParam(new Param_Plane()); - } - } - - private void UpdateProfileString() { - if (_selectedItems[3] == "All") { - _profileString = new List(); - foreach (string profile in _sectionList.Where(profile => profile != "All")) { - _profileString.Add("CAT " + profile); - } - } else { - _profileString = new List() { - "CAT " + _selectedItems[3], - }; - } - } - - private void UpdateTypeData() { - _typedata = GetTypesDataFromSqLite(_catalogueIndex, - Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSs); - _typeNames = _typedata.Item1; - _typeNumbers = _typedata.Item2; - } - } -} diff --git a/GsaGH/Components/GraveyardComp/CreateProp2d2_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateProp2d2_OBSOLETE.cs deleted file mode 100644 index b8531fd39..000000000 --- a/GsaGH/Components/GraveyardComp/CreateProp2d2_OBSOLETE.cs +++ /dev/null @@ -1,333 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Parameters; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to create a new Prop2d - /// - public class CreateProp2d2_OBSOLETE : GH_OasysDropDownComponent { - public override Guid ComponentGuid => new Guid("d693b4ad-7aaf-450e-a436-afbb9d2061fc"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Create2dProperty; - private readonly IReadOnlyDictionary _dropdownTopLevel - = new Dictionary { - { - Prop2dType.PlaneStress, "Plane Stress" - }, { - Prop2dType.Fabric, "Fabric" - }, { - Prop2dType.FlatPlate, "Flat Plate" - }, { - Prop2dType.Shell, "Shell" - }, { - Prop2dType.CurvedShell, "Curved Shell" - }, { - Prop2dType.LoadPanel, "Load Panel" - }, - }; - private readonly IReadOnlyDictionary _supportDropDown - = new Dictionary { - { - SupportType.Auto, "Automatic" - }, { - SupportType.AllEdges, "All edges" - }, { - SupportType.ThreeEdges, "Three edges" - }, { - SupportType.TwoEdges, "Two edges" - }, { - SupportType.TwoAdjacentEdges, "Two adjacent edges" - }, { - SupportType.OneEdge, "One edge" - }, { - SupportType.Cantilever, "Cantilever" - }, - }; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitSection; - private Prop2dType _mode = Prop2dType.Shell; - private int _supportTypeIndex; - - public CreateProp2d2_OBSOLETE() : base("Create 2D Property", "Prop2d", "Create GSA 2D Property", - CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - public override void SetSelected(int i, int j) { - _selectedItems[i] = _dropDownItems[i][j]; - - Prop2dType mode = GetModeBy(_selectedItems[0]); - if (i == 0) { - UpdateParameters(mode); - UpdateDropDownItems(mode); - } - - if (i != 0 && mode != Prop2dType.LoadPanel) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[i]); - } - - if (i == 1 && mode == Prop2dType.LoadPanel) { - _supportTypeIndex = j; - UpdateParameters(mode); - UpdateDropDownItems(mode); - } - - base.UpdateUI(); - } - - public override void VariableParameterMaintenance() { - switch (_mode) { - case Prop2dType.LoadPanel: - if (_supportTypeIndex != _supportDropDown.Keys.ToList().IndexOf(SupportType.Auto) - && _supportTypeIndex != _supportDropDown.Keys.ToList().IndexOf(SupportType.AllEdges)) { - SetReferenceEdgeInputAt(0); - } - - return; - - case Prop2dType.Fabric: - SetMaterialInputAt(0); - break; - - case Prop2dType.Shell: - case Prop2dType.PlaneStress: - case Prop2dType.FlatPlate: - case Prop2dType.CurvedShell: - SetInputProperties(0, "Thk", $"Thickness [{Length.GetAbbreviation(_lengthUnit)}]", - "Section thickness", optional: false); - SetMaterialInputAt(1); - break; - } - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Type", - "Unit", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(_dropdownTopLevel.Values.ToList()); - _selectedItems.Add(_dropdownTopLevel.Values.ElementAt(3)); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddGenericParameter("Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]", "Thk", - "Section thickness", GH_ParamAccess.item); - pManager.AddParameter(new GsaMaterialParameter()); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaProperty2dParameter()); - } - - protected override void SolveInternal(IGH_DataAccess da) { - var prop = new GsaProperty2d(); - switch (_mode) { - case Prop2dType.PlaneStress: - case Prop2dType.Fabric: - case Prop2dType.FlatPlate: - case Prop2dType.Shell: - case Prop2dType.CurvedShell: - case Prop2dType.LoadPanel: - prop.ApiProp2d.Type = (Property2D_Type)(int)_mode; - break; - - default: - this.AddRuntimeWarning("Property type is undefined"); - prop.ApiProp2d.Type = Property2D_Type.UNDEF; - break; - } - - if (_mode != Prop2dType.LoadPanel) { - prop.ApiProp2d.AxisProperty = 0; - - if (_mode != Prop2dType.Fabric) { - prop.Thickness = (Length)Input.UnitNumber(this, da, 0, _lengthUnit); - var ghTyp = new GH_ObjectWrapper(); - if (da.GetData(1, ref ghTyp)) { - if (ghTyp.Value is GsaMaterialGoo materialGoo) { - prop.Material = GsaMaterialFactory.CreateMaterial(materialGoo.Value); - } else { - if (GH_Convert.ToInt32(ghTyp.Value, out int id, GH_Conversion.Both)) { - prop.Material = new GsaReferencedMaterial(id, MatType.Custom); - } else { - this.AddRuntimeError( - "Unable to convert PB input to a Section Property of reference integer"); - return; - } - } - } - } else { - prop.Material = new GsaReferencedMaterial(1, MatType.Fabric); - } - } else { - prop.ApiProp2d.SupportType = _supportDropDown.FirstOrDefault(x => x.Value == _selectedItems[1]).Key; - if (prop.ApiProp2d.SupportType != SupportType.Auto && prop.ApiProp2d.SupportType != SupportType.AllEdges) { - int referenceEdge = 0; - if (da.GetData("Reference edge", ref referenceEdge) && referenceEdge > 0 - && referenceEdge <= 4) { - prop.ApiProp2d.ReferenceEdge = referenceEdge; - } else { - this.AddRuntimeWarning("Input RE failed to collect data"); - } - } - } - - da.SetData(0, new GsaProperty2dGoo(prop)); - } - - protected override void UpdateUIFromSelectedItems() { - Prop2dType mode = GetModeBy(_selectedItems[0]); - - if (mode == Prop2dType.LoadPanel) { - _supportTypeIndex = _supportDropDown.ToList().FindIndex(x => x.Value == _selectedItems[1]); - } else if (mode != Prop2dType.Fabric) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[1]); - } - - UpdateDropDownItems(mode); - UpdateParameters(mode); - - base.UpdateUIFromSelectedItems(); - } - - private void AddLengthUnitDropDown() { - _spacerDescriptions.Add("Unit"); - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - } - - private void AddSupportTypeDropDown() { - if (_supportTypeIndex < 0 || _supportTypeIndex >= _supportDropDown.Count) { - this.AddRuntimeError("Index for selected items out of range!"); - _supportTypeIndex = 0; - } - - _spacerDescriptions.Add("Support Type"); - _dropDownItems.Add(_supportDropDown.Values.ToList()); - _selectedItems.Add(_supportDropDown.Values.ElementAt(_supportTypeIndex)); - } - - private Prop2dType GetModeBy(string name) { - foreach (KeyValuePair item in _dropdownTopLevel) { - if (item.Value.Equals(name)) { - return item.Key; - } - } - - throw new Exception("Unable to convert " + name + " to Prop2d Type"); - } - - private void ResetDropdownMenus() { - while (_spacerDescriptions.Count > 1) { - _spacerDescriptions.RemoveAt(_spacerDescriptions.Count - 1); - } - - while (_dropDownItems.Count > 1) { - _dropDownItems.RemoveAt(_dropDownItems.Count - 1); - } - - while (_selectedItems.Count > 1) { - _selectedItems.RemoveAt(_selectedItems.Count - 1); - } - } - - private void SetInputProperties( - int index, string nickname, string name, string description, - bool optional = true) { - Params.Input[index].NickName = nickname; - Params.Input[index].Name = name; - Params.Input[index].Description = description; - Params.Input[index].Access = GH_ParamAccess.item; - Params.Input[index].Optional = optional; - } - - private void SetMaterialInputAt(int index) { - SetInputProperties(index, "Mat", "Material", "GSA Material"); - } - - private void SetReferenceEdgeInputAt(int index) { - SetInputProperties(index, "RE", "Reference edge", - "Reference edge for automatic support type"); - } - - private void UpdateDropDownItems(Prop2dType mode) { - ResetDropdownMenus(); - switch (mode) { - case Prop2dType.PlaneStress: - case Prop2dType.FlatPlate: - case Prop2dType.Shell: - case Prop2dType.CurvedShell: - AddLengthUnitDropDown(); - break; - - case Prop2dType.Fabric: break; - - case Prop2dType.LoadPanel: - AddSupportTypeDropDown(); - break; - } - } - - private void UpdateParameters(Prop2dType mode) { - if (_mode == mode && mode != Prop2dType.LoadPanel) { - return; - } - - _dropdownTopLevel.TryGetValue(mode, out string eventName); - RecordUndoEvent($"{eventName} Parameters"); - - while (Params.Input.Count > 0) { - Params.UnregisterInputParameter(Params.Input[0], true); - } - - switch (mode) { - case Prop2dType.Shell: - case Prop2dType.PlaneStress: - case Prop2dType.FlatPlate: - case Prop2dType.CurvedShell: - Params.RegisterInputParam(new Param_GenericObject()); - Params.RegisterInputParam(new GsaMaterialParameter()); - break; - - case Prop2dType.Fabric: - Params.RegisterInputParam(new Param_GenericObject()); - break; - - case Prop2dType.LoadPanel: - if (_supportTypeIndex != _supportDropDown.Keys.ToList().IndexOf(SupportType.Auto) - && _supportTypeIndex != _supportDropDown.Keys.ToList().IndexOf(SupportType.AllEdges)) { - Params.RegisterInputParam(new Param_Integer()); - } - - break; - } - - _mode = mode; - } - } -} \ No newline at end of file diff --git a/GsaGH/Components/GraveyardComp/CreateProp2d_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateProp2d_OBSOLETE.cs deleted file mode 100644 index 55ceaf55e..000000000 --- a/GsaGH/Components/GraveyardComp/CreateProp2d_OBSOLETE.cs +++ /dev/null @@ -1,491 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Parameters; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.GsaApi; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.UI; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to create a new Prop2d - /// - // ReSharper disable once InconsistentNaming - public class CreateProp2d_OBSOLETE : GH_OasysComponent, IGH_VariableParameterComponent { - private enum FoldMode { - PlaneStress, - Fabric, - FlatPlate, - Shell, - CurvedShell, - LoadPanel, - } - - public override Guid ComponentGuid => new Guid("3fd61492-b5ff-47ea-8c7c-89cf639b32dc"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Create2dProperty; - private readonly List _dropdownTopList = new List(new[] { - "Plane Stress", - "Fabric", - "Flat Plate", - "Shell", - "Curved Shell", - "Load Panel", - }); - private List> _dropDownItems; - private bool _first = true; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - private FoldMode _mode = FoldMode.Shell; - private List _selectedItems; - private List _spacerDescriptions = new List(new[] { - "Element Type", - "Unit", - }); - private string _unitAbbreviation; - - public CreateProp2d_OBSOLETE() : base("Create 2D Property", "Prop2d", "Create GSA 2D Property", - CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - bool IGH_VariableParameterComponent.CanInsertParameter(GH_ParameterSide side, int index) { - return false; - } - - bool IGH_VariableParameterComponent.CanRemoveParameter(GH_ParameterSide side, int index) { - return false; - } - - public override void CreateAttributes() { - if (_first) { - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(_dropdownTopList); - _dropDownItems.Add(FilteredUnits.FilteredLengthUnits); - - _selectedItems.Add(_dropdownTopList[3]); - _selectedItems.Add(_lengthUnit.ToString()); - - IQuantity quantity = new Length(0, _lengthUnit); - _unitAbbreviation = string.Concat(quantity.ToString().Where(char.IsLetter)); - - _first = false; - } - - m_attributes = new DropDownComponentAttributes(this, SetSelected, _dropDownItems, - _selectedItems, _spacerDescriptions); - } - - IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index) { - return null; - } - - bool IGH_VariableParameterComponent.DestroyParameter(GH_ParameterSide side, int index) { - return false; - } - - public override bool Read(GH_IReader reader) { - try // if users has an old version of this component then dropdown menu wont read - { - ReadDropDownComponents(ref reader, ref _dropDownItems, ref _selectedItems, - ref _spacerDescriptions); - _mode = (FoldMode)Enum.Parse(typeof(FoldMode), - _selectedItems[0].Replace(" ", string.Empty)); - _lengthUnit = (LengthUnit)Enum.Parse(typeof(LengthUnit), _selectedItems[1]); - } catch (Exception) { - _dropDownItems = new List>(); - _selectedItems = new List(); - _dropDownItems.Add(_dropdownTopList); - _dropDownItems.Add(FilteredUnits.FilteredLengthUnits); - - _mode = (FoldMode)reader.GetInt32("Mode"); //old version would have this set - _selectedItems.Add(reader.GetString("select")); // same - _selectedItems.Add(_lengthUnit.ToString()); - - _lengthUnit = LengthUnit.Meter; - - IQuantity quantity = new Length(0, _lengthUnit); - _unitAbbreviation = string.Concat(quantity.ToString().Where(char.IsLetter)); - } - - UpdateUiFrom_selectedItems(); - _first = false; - return base.Read(reader); - } - - public void SetSelected(int i, int j) { - _selectedItems[i] = _dropDownItems[i][j]; - - if (i == 0) { - switch (_selectedItems[i]) { - case "Plane Stress": - if (_dropDownItems.Count < 2) { - _dropDownItems.Add(FilteredUnits.FilteredLengthUnits); - } - - Mode1Clicked(); - break; - - case "Fabric": - if (_dropDownItems.Count > 1) { - _dropDownItems.RemoveAt(1); - } - - Mode2Clicked(); - break; - - case "Flat Plate": - if (_dropDownItems.Count < 2) { - _dropDownItems.Add(FilteredUnits.FilteredLengthUnits); - } - - Mode3Clicked(); - break; - - case "Shell": - if (_dropDownItems.Count < 2) { - _dropDownItems.Add(FilteredUnits.FilteredLengthUnits); - } - - Mode4Clicked(); - break; - - case "Curved Shell": - if (_dropDownItems.Count < 2) { - _dropDownItems.Add(FilteredUnits.FilteredLengthUnits); - } - - Mode5Clicked(); - break; - - case "Load Panel": - if (_dropDownItems.Count > 1) { - _dropDownItems.RemoveAt(1); - } - - Mode6Clicked(); - break; - } - } else { - _lengthUnit = (LengthUnit)Enum.Parse(typeof(LengthUnit), _selectedItems[i]); - } - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - ExpireSolution(true); - Params.OnParametersChanged(); - OnDisplayExpired(true); - } - - void IGH_VariableParameterComponent.VariableParameterMaintenance() { - if (_mode != FoldMode.LoadPanel && _mode != FoldMode.Fabric) { - IQuantity length = new Length(0, _lengthUnit); - _unitAbbreviation = string.Concat(length.ToString().Where(char.IsLetter)); - - int i = 0; - Params.Input[i].NickName = "Mat"; - Params.Input[i].Name = "Material"; - Params.Input[i].Description - = "GsaMaterial or Number referring to a Material already in Existing GSA Model." - + Environment.NewLine + "Accepted inputs are: " + Environment.NewLine + "0 : Generic" - + Environment.NewLine + "1 : Steel" + Environment.NewLine + "2 : Concrete (default)" - + Environment.NewLine + "3 : Aluminium" + Environment.NewLine + "4 : Glass" - + Environment.NewLine + "5 : FRP" + Environment.NewLine + "7 : Timber" - + Environment.NewLine + "8 : Fabric"; - - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = true; - - i++; - Params.Input[i].NickName = "Thk"; - Params.Input[i].Name = "Thickness [" + _unitAbbreviation + "]"; - Params.Input[i].Description = "Section thickness"; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = true; - } - - if (_mode != FoldMode.Fabric) { - return; - } - - { - const int i = 0; - Params.Input[i].NickName = "Mat"; - Params.Input[i].Name = "Material"; - Params.Input[i].Description - = "GsaMaterial or Reference ID for Material Property in Existing GSA Model"; - Params.Input[i].Access = GH_ParamAccess.item; - Params.Input[i].Optional = true; - } - } - - public override bool Write(GH_IWriter writer) { - WriteDropDownComponents(ref writer, _dropDownItems, _selectedItems, _spacerDescriptions); - return base.Write(writer); - } - - internal static void ReadDropDownComponents( - ref GH_IReader reader, ref List> dropDownItems, ref List selectedItems, - ref List spacerDescriptions) { - if (reader.ItemExists("dropdown")) { - int dropdownCount = reader.GetInt32("dropdownCount"); - dropDownItems = new List>(); - for (int i = 0; i < dropdownCount; i++) { - int dropdowncontentsCount = reader.GetInt32("dropdowncontentsCount" + i); - var tempcontent = new List(); - for (int j = 0; j < dropdowncontentsCount; j++) { - tempcontent.Add(reader.GetString("dropdowncontents" + i + j)); - } - - dropDownItems.Add(tempcontent); - } - } else { - throw new Exception("Component doesnt have 'dropdown' content stored"); - } - - if (reader.ItemExists("spacer")) { - int dropdownspacerCount = reader.GetInt32("spacerCount"); - spacerDescriptions = new List(); - for (int i = 0; i < dropdownspacerCount; i++) { - spacerDescriptions.Add(reader.GetString("spacercontents" + i)); - } - } - - if (!reader.ItemExists("select")) { - return; - } - - { - int selectionsCount = reader.GetInt32("selectionCount"); - selectedItems = new List(); - for (int i = 0; i < selectionsCount; i++) { - selectedItems.Add(reader.GetString("selectioncontents" + i)); - } - } - } - - internal static GH_IWriter WriteDropDownComponents( - ref GH_IWriter writer, List> dropDownItems, List selectedItems, - List spacerDescriptions) { - bool dropdown = false; - if (dropDownItems != null) { - writer.SetInt32("dropdownCount", dropDownItems.Count); - for (int i = 0; i < dropDownItems.Count; i++) { - writer.SetInt32("dropdowncontentsCount" + i, dropDownItems[i].Count); - for (int j = 0; j < dropDownItems[i].Count; j++) { - writer.SetString("dropdowncontents" + i + j, dropDownItems[i][j]); - } - } - - dropdown = true; - } - - writer.SetBoolean("dropdown", dropdown); - - bool spacer = false; - if (spacerDescriptions != null) { - writer.SetInt32("spacerCount", spacerDescriptions.Count); - for (int i = 0; i < spacerDescriptions.Count; i++) { - writer.SetString("spacercontents" + i, spacerDescriptions[i]); - } - - spacer = true; - } - - writer.SetBoolean("spacer", spacer); - - bool select = false; - if (selectedItems != null) { - writer.SetInt32("selectionCount", selectedItems.Count); - for (int i = 0; i < selectedItems.Count; i++) { - writer.SetString("selectioncontents" + i, selectedItems[i]); - } - - select = true; - } - - writer.SetBoolean("select", select); - - return writer; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - Params.RegisterInputParam(new Param_GenericObject()); - Params.RegisterInputParam(new Param_Number()); - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddGenericParameter("2D Property", "PA", "GSA 2D Property", GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var prop = new GsaProperty2d(); - - prop.ApiProp2d.Type = Mappings.GetProperty2D_Type(_mode.ToString()); - - if (_mode != FoldMode.LoadPanel) { - prop.ApiProp2d.AxisProperty = 0; - - if (_mode != FoldMode.Fabric) { - GsaMaterialGoo materialGoo = null; - if (da.GetData(0, ref materialGoo)) { - prop.Material = materialGoo.Value; - } - - prop.Thickness = (Length)Input.UnitNumber(this, da, 1, _lengthUnit); - } - } - - da.SetData(0, new GsaProperty2dGoo(prop)); - } - - private void Mode1Clicked() { - if (_mode == FoldMode.PlaneStress) { - return; - } - - RecordUndoEvent("Plane Stress Parameters"); - if (_mode == FoldMode.LoadPanel || _mode == FoldMode.Fabric) { - while (Params.Input.Count > 0) { - Params.UnregisterInputParameter(Params.Input[0], true); - } - - Params.RegisterInputParam(new Param_GenericObject()); - Params.RegisterInputParam(new Param_GenericObject()); - } - - _mode = FoldMode.PlaneStress; - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - - private void Mode2Clicked() { - if (_mode == FoldMode.Fabric) { - return; - } - - RecordUndoEvent("Fabric Parameters"); - _mode = FoldMode.Fabric; - - while (Params.Input.Count > 0) { - Params.UnregisterInputParameter(Params.Input[0], true); - } - - Params.RegisterInputParam(new Param_GenericObject()); - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - - private void Mode3Clicked() { - if (_mode == FoldMode.FlatPlate) { - return; - } - - RecordUndoEvent("Flat Plate Parameters"); - if (_mode == FoldMode.LoadPanel || _mode == FoldMode.Fabric) { - while (Params.Input.Count > 0) { - Params.UnregisterInputParameter(Params.Input[0], true); - } - - Params.RegisterInputParam(new Param_GenericObject()); - Params.RegisterInputParam(new Param_GenericObject()); - } - - _mode = FoldMode.FlatPlate; - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - - private void Mode4Clicked() { - if (_mode == FoldMode.Shell) { - return; - } - - RecordUndoEvent("Shell Parameters"); - if (_mode == FoldMode.LoadPanel || _mode == FoldMode.Fabric) { - while (Params.Input.Count > 0) { - Params.UnregisterInputParameter(Params.Input[0], true); - } - - Params.RegisterInputParam(new Param_GenericObject()); - Params.RegisterInputParam(new Param_GenericObject()); - } - - _mode = FoldMode.Shell; - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - - private void Mode5Clicked() { - if (_mode == FoldMode.CurvedShell) { - return; - } - - RecordUndoEvent("Curved Shell Parameters"); - if (_mode == FoldMode.LoadPanel || _mode == FoldMode.Fabric) { - while (Params.Input.Count > 0) { - Params.UnregisterInputParameter(Params.Input[0], true); - } - - Params.RegisterInputParam(new Param_GenericObject()); - Params.RegisterInputParam(new Param_GenericObject()); - } - - _mode = FoldMode.CurvedShell; - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - - private void Mode6Clicked() { - if (_mode == FoldMode.LoadPanel) { - return; - } - - RecordUndoEvent("Load Panel Parameters"); - _mode = FoldMode.LoadPanel; - - while (Params.Input.Count > 0) { - Params.UnregisterInputParameter(Params.Input[0], true); - } - - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - Params.OnParametersChanged(); - ExpireSolution(true); - } - - private void UpdateUiFrom_selectedItems() { - CreateAttributes(); - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - ExpireSolution(true); - Params.OnParametersChanged(); - OnDisplayExpired(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/CreateSection_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/CreateSection_OBSOLETE.cs deleted file mode 100644 index beeb6040b..000000000 --- a/GsaGH/Components/GraveyardComp/CreateSection_OBSOLETE.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Drawing; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; - -namespace GsaGH.Components { - /// - /// Component to create a new Section - /// - public class CreateSection_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("1167c4aa-b98b-47a7-ae85-1a3c976a1973"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - - protected override Bitmap Icon => Resources.CreateSection; - - public CreateSection_OBSOLETE() : base("Create Section", "Section", "Create GSA Section", - CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddTextParameter("Profile", "Pf", - "Cross-Section Profile defined using the GSA Profile string syntax", GH_ParamAccess.item); - pManager.AddParameter(new GsaMaterialParameter()); - pManager[1].Optional = true; - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaSectionParameter()); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var gsaSection = new GsaSection(); - var ghProfile = new GH_String(); - if (!da.GetData(0, ref ghProfile)) { - return; - } - - if (GH_Convert.ToString(ghProfile, out string profile, GH_Conversion.Both)) { - if (GsaSection.IsValidProfile(profile)) { - gsaSection = new GsaSection(profile); - } else { - this.AddRuntimeWarning("Invalid profile syntax: " + profile); - return; - } - - GsaMaterialGoo materialGoo = null; - if (da.GetData(1, ref materialGoo)) { - gsaSection.Material = materialGoo.Value; - } - } - - da.SetData(0, new GsaSectionGoo(gsaSection)); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditElement1d2_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditElement1d2_OBSOLETE.cs deleted file mode 100644 index 9af2c7736..000000000 --- a/GsaGH/Components/GraveyardComp/EditElement1d2_OBSOLETE.cs +++ /dev/null @@ -1,253 +0,0 @@ -using System; -using System.Drawing; -using System.Linq; -using Grasshopper; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Data; -using Grasshopper.Kernel.Parameters; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.GsaApi; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysUnits; -using Rhino.Geometry; -using AngleUnit = OasysUnits.Units.AngleUnit; -using Line = Rhino.Geometry.Line; - -namespace GsaGH.Components { - /// - /// Component to edit a 1D Element - /// - // ReSharper disable once InconsistentNaming - public class EditElement1d2_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("5aa4635c-b60e-4812-ab45-6af9437255e4"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit1dElement; - private AngleUnit _angleUnit = AngleUnit.Radian; - - public EditElement1d2_OBSOLETE() : base("Edit 1D Element", "Elem1dEdit", - "Modify GSA 1D Element", CategoryName.Name(), SubCategoryName.Cat2()) { } - - protected override void BeforeSolveInstance() { - base.BeforeSolveInstance(); - if (!(Params.Input[9] is Param_Number angleParameter)) { - return; - } - - _angleUnit = angleParameter.UseDegrees ? AngleUnit.Degree : AngleUnit.Radian; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaElement1dParameter(), GsaElement1dGoo.Name, - GsaElement1dGoo.NickName, - GsaElement1dGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaElement1dGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Number", "ID", - "Set Element Number. If ID is set it will replace any existing 1D Element in the model", - GH_ParamAccess.item); - pManager.AddLineParameter("Line", "L", "Reposition Element Line", GH_ParamAccess.item); - pManager.AddParameter(new GsaSectionParameter(), "Section", "PB", "Set new Section Property", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Group", "Gr", "Set Element Group", GH_ParamAccess.item); - pManager.AddTextParameter("Type", "eT", - "Set Element Type" + Environment.NewLine + "Accepted inputs are:" + Environment.NewLine - + "1: Bar" + Environment.NewLine + "2: Beam" + Environment.NewLine + "3: Spring" - + Environment.NewLine + "9: Link" + Environment.NewLine + "10: Cable" + Environment.NewLine - + "19: Spacer" + Environment.NewLine + "20: Strut" + Environment.NewLine + "21: Tie" - + Environment.NewLine + "23: Rod" + Environment.NewLine + "24: Damper", - GH_ParamAccess.item); - - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Set Element Offset", - GH_ParamAccess.item); - - pManager.AddParameter(new GsaBool6Parameter(), "Start release", "⭰", - "Set Release (Bool6) at Start of Element", GH_ParamAccess.item); - pManager.AddParameter(new GsaBool6Parameter(), "End release", "⭲", - "Set Release (Bool6) at End of Element", GH_ParamAccess.item); - - pManager.AddAngleParameter("Orientation Angle", "⭮A", "Set Element Orientation Angle", - GH_ParamAccess.item); - pManager.AddParameter(new GsaNodeParameter(), "Orientation Node", "⭮N", - "Set Element Orientation Node", GH_ParamAccess.item); - - pManager.AddTextParameter("Name", "Na", "Set Element Name", GH_ParamAccess.item); - pManager.AddColourParameter("Colour", "Co", "Set Element Colour", GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Element", "Dm", "Set Element to Dummy", - GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - - pManager.HideParameter(0); - pManager.HideParameter(2); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaElement1dParameter(), GsaElement1dGoo.Name, - GsaElement1dGoo.NickName, GsaElement1dGoo.Description + " with applied changes.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Number", "ID", - "Get Element Number. If ID is set it will replace any existing 1D Element in the model", - GH_ParamAccess.item); - pManager.AddLineParameter("Line", "L", "Element Line", GH_ParamAccess.item); - pManager.HideParameter(2); - pManager.AddParameter(new GsaSectionParameter(), "Section", "PB", "Get Section Property", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Group", "Gr", "Get Element Group", GH_ParamAccess.item); - pManager.AddTextParameter("Type", "eT", "Get Element Type", GH_ParamAccess.item); - - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Get Element Offset", - GH_ParamAccess.item); - - pManager.AddParameter(new GsaBool6Parameter(), "Start release", "⭰", - "Get Release (Bool6) at Start of Element", GH_ParamAccess.item); - pManager.AddParameter(new GsaBool6Parameter(), "End release", "⭲", - "Get Release (Bool6) at End of Element", GH_ParamAccess.item); - - pManager.AddNumberParameter("Orientation Angle", "⭮A", "Get Element Orientation Angle", - GH_ParamAccess.item); - pManager.AddGenericParameter("Orientation Node", "⭮N", "Get Element Orientation Node", - GH_ParamAccess.item); - - pManager.AddTextParameter("Name", "Na", "Get Element Name", GH_ParamAccess.item); - 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.tree); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var elem = new GsaElement1d(); - - GsaElement1dGoo element1dGoo = null; - if (da.GetData(0, ref element1dGoo)) { - elem = new GsaElement1d(element1dGoo.Value); - } - - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - elem.Id = id; - } - } - - var ghLine = new GH_Line(); - if (da.GetData(2, ref ghLine)) { - var line = new Line(); - if (GH_Convert.ToLine(ghLine, ref line, GH_Conversion.Both)) { - var ln = new LineCurve(line); - elem.Line = ln; - } - } - - GsaSectionGoo sectionGoo = null; - if (da.GetData(3, ref sectionGoo)) { - elem.Section = sectionGoo.Value; - } - - var ghGroup = new GH_Integer(); - if (da.GetData(4, ref ghGroup)) { - if (GH_Convert.ToInt32(ghGroup, out int grp, GH_Conversion.Both)) { - elem.ApiElement.Group = grp; - } - } - - var ghString = new GH_String(); - if (da.GetData(5, ref ghString)) { - if (GH_Convert.ToInt32(ghString, out int typeInt, GH_Conversion.Both)) { - elem.ApiElement.Type = (ElementType)typeInt; - } else if (GH_Convert.ToString(ghString, out string typestring, GH_Conversion.Both)) { - try { - elem.ApiElement.Type = Mappings.GetElementType(typestring); - } catch (ArgumentException) { - this.AddRuntimeError("Unable to change Element Type"); - } - } - } - - GsaOffsetGoo offset = null; - if (da.GetData(6, ref offset)) { - elem.Offset = offset.Value; - } - - GsaBool6Goo start = null; - if (da.GetData(7, ref start)) { - elem.ReleaseStart = start.Value; - } - - GsaBool6Goo end = null; - if (da.GetData(8, ref end)) { - elem.ReleaseEnd = end.Value; - } - - var ghAngle = new GH_Number(); - if (da.GetData(9, ref ghAngle)) { - if (GH_Convert.ToDouble(ghAngle, out double angle, GH_Conversion.Both)) { - elem.OrientationAngle = new Angle(angle, _angleUnit); - } - } - - GsaNodeGoo nodeGoo = null; - if (da.GetData(10, ref nodeGoo)) { - elem.OrientationNode = nodeGoo.Value; - } - - var ghName = new GH_String(); - if (da.GetData(11, ref ghName)) { - if (GH_Convert.ToString(ghName, out string name, GH_Conversion.Both)) { - elem.ApiElement.Name = name; - } - } - - var ghColour = new GH_Colour(); - if (da.GetData(12, ref ghColour)) { - if (GH_Convert.ToColor(ghColour, out Color col, GH_Conversion.Both)) { - elem.ApiElement.Colour = col; - } - } - - var ghDummy = new GH_Boolean(); - if (da.GetData(13, ref ghDummy)) { - if (GH_Convert.ToBoolean(ghDummy, out bool dum, GH_Conversion.Both)) { - elem.ApiElement.IsDummy = dum; - } - } - - da.SetData(0, new GsaElement1dGoo(elem)); - da.SetData(1, elem.Id); - da.SetData(2, new GH_Line(elem.Line.Line)); - da.SetData(3, new GsaSectionGoo(elem.Section)); - da.SetData(4, elem.ApiElement.Group); - da.SetData(5, - Mappings.elementTypeMapping.FirstOrDefault(x => x.Value == elem.ApiElement.Type).Key); - da.SetData(6, new GsaOffsetGoo(elem.Offset)); - da.SetData(7, new GsaBool6Goo(elem.ReleaseStart)); - da.SetData(8, new GsaBool6Goo(elem.ReleaseEnd)); - da.SetData(9, elem.OrientationAngle.As(AngleUnit.Degree)); - da.SetData(10, new GsaNodeGoo(elem.OrientationNode)); - da.SetData(11, elem.ApiElement.Name); - da.SetData(12, elem.ApiElement.Colour); - da.SetData(13, elem.ApiElement.IsDummy); - - try { - da.SetData(14, elem.ApiElement.ParentMember.Member); - } catch (Exception) { - // ignored - } - - var topo = new DataTree(); - topo.AddRange(elem.ApiElement.Topology, new GH_Path(elem.Id)); - da.SetDataTree(15, topo); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditElement1d_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditElement1d_OBSOLETE.cs deleted file mode 100644 index 06e1ef4a1..000000000 --- a/GsaGH/Components/GraveyardComp/EditElement1d_OBSOLETE.cs +++ /dev/null @@ -1,234 +0,0 @@ -using System; -using System.Collections.ObjectModel; -using System.Drawing; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysUnits; -using Rhino.Geometry; -using AngleUnit = OasysUnits.Units.AngleUnit; -using Line = Rhino.Geometry.Line; - -namespace GsaGH.Components { - /// - /// Component to edit a 1D Element - /// - // ReSharper disable once InconsistentNaming - public class EditElement1d_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("aeb5f765-8721-41fc-a1b4-cfd78e05ce67"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit1dElement; - - public EditElement1d_OBSOLETE() : base("Edit 1D Element", "Elem1dEdit", "Modify GSA 1D Element", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaElement1dParameter(), GsaElement1dGoo.Name, - GsaElement1dGoo.NickName, - GsaElement1dGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaElement1dGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Number", "ID", - "Set Element Number. If ID is set it will replace any existing 1D Element in the model", - GH_ParamAccess.item); - pManager.AddLineParameter("Line", "L", "Reposition Element Line", GH_ParamAccess.item); - pManager.AddParameter(new GsaSectionParameter(), "Section", "PB", "Set new Section Property", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Group", "Gr", "Set Element Group", GH_ParamAccess.item); - pManager.AddIntegerParameter("Type", "eT", - "Set Element Type" + Environment.NewLine + "Accepted inputs are:" + Environment.NewLine - + "1: Bar" + Environment.NewLine + "2: Beam" + Environment.NewLine + "3: Spring" - + Environment.NewLine + "9: Link" + Environment.NewLine + "10: Cable" + Environment.NewLine - + "19: Spacer" + Environment.NewLine + "20: Strut" + Environment.NewLine + "21: Tie" - + Environment.NewLine + "23: Rod" + Environment.NewLine + "24: Damper", - GH_ParamAccess.item); - - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Set Element Offset", - GH_ParamAccess.item); - - pManager.AddParameter(new GsaBool6Parameter(), "Start release", "⭰", - "Set Release (Bool6) at Start of Element", GH_ParamAccess.item); - pManager.AddParameter(new GsaBool6Parameter(), "End release", "⭲", - "Set Release (Bool6) at End of Element", GH_ParamAccess.item); - - pManager.AddNumberParameter("Orientation Angle", "⭮A", - "Set Element Orientation Angle in degrees", GH_ParamAccess.item); - pManager.AddGenericParameter("Orientation Node", "⭮N", "Set Element Orientation Node", - GH_ParamAccess.item); - - pManager.AddTextParameter("Name", "Na", "Set Element Name", GH_ParamAccess.item); - pManager.AddColourParameter("Colour", "Co", "Set Element Colour", GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Element", "Dm", "Set Element to Dummy", - GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - - pManager.HideParameter(0); - pManager.HideParameter(2); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaElement1dParameter(), GsaElement1dGoo.Name, - GsaElement1dGoo.NickName, GsaElement1dGoo.Description + " with applied changes.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Number", "ID", - "Get Element Number. If ID is set it will replace any existing 1D Element in the model", - GH_ParamAccess.item); - pManager.AddLineParameter("Line", "L", "Element Line", GH_ParamAccess.item); - pManager.HideParameter(2); - pManager.AddParameter(new GsaSectionParameter(), "Section", "PB", "Get Section Property", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Group", "Gr", "Get Element Group", GH_ParamAccess.item); - pManager.AddIntegerParameter("Type", "eT", "Get Element Type", GH_ParamAccess.item); - - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Get Element Offset", - GH_ParamAccess.item); - - pManager.AddParameter(new GsaBool6Parameter(), "Start release", "⭰", - "Get Release (Bool6) at Start of Element", GH_ParamAccess.item); - pManager.AddParameter(new GsaBool6Parameter(), "End release", "⭲", - "Get Release (Bool6) at End of Element", GH_ParamAccess.item); - - pManager.AddNumberParameter("Orientation Angle", "⭮A", - "Get Element Orientation Angle in degrees", GH_ParamAccess.item); - pManager.AddGenericParameter("Orientation Node", "⭮N", "Get Element Orientation Node", - GH_ParamAccess.item); - - pManager.AddTextParameter("Name", "Na", "Get Element Name", GH_ParamAccess.item); - 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); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var elem = new GsaElement1d(); - - GsaElement1dGoo element1dGoo = null; - if (da.GetData(0, ref element1dGoo)) { - elem = new GsaElement1d(element1dGoo.Value); - } - - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - elem.Id = id; - } - } - - var ghLine = new GH_Line(); - if (da.GetData(2, ref ghLine)) { - var curve = new Line(); - if (GH_Convert.ToLine(ghLine, ref curve, GH_Conversion.Both)) { - var ln = new LineCurve(curve); - elem.Line = ln; - } - } - - GsaSectionGoo sectionGoo = null; - if (da.GetData(3, ref sectionGoo)) { - elem.Section = sectionGoo.Value; - } - - var ghgrp = new GH_Integer(); - if (da.GetData(4, ref ghgrp)) { - if (GH_Convert.ToInt32(ghgrp, out int grp, GH_Conversion.Both)) { - elem.ApiElement.Group = grp; - } - } - - var ghinteg = new GH_Integer(); - if (da.GetData(5, ref ghinteg)) { - if (GH_Convert.ToInt32(ghinteg, out int type, GH_Conversion.Both)) { - elem.ApiElement.Type = (ElementType)type; - } - } - - GsaOffsetGoo offset = null; - if (da.GetData(6, ref offset)) { - elem.Offset = offset.Value; - } - - GsaBool6Goo start = null; - if (da.GetData(7, ref start)) { - elem.ReleaseStart = start.Value; - } - - GsaBool6Goo end = null; - if (da.GetData(8, ref end)) { - elem.ReleaseEnd = end.Value; - } - - var ghangle = new GH_Number(); - if (da.GetData(9, ref ghangle)) { - if (GH_Convert.ToDouble(ghangle, out double angle, GH_Conversion.Both)) { - elem.OrientationAngle = new Angle(angle, AngleUnit.Degree); - } - } - - var ghTyp = new GH_ObjectWrapper(); - if (da.GetData(10, ref ghTyp)) { - if (ghTyp.Value is GsaNodeGoo nodeGoo) { - elem.OrientationNode = nodeGoo.Value; - } else { - this.AddRuntimeWarning("Unable to convert Orientation Node input to GsaNode"); - } - } - - var ghnm = new GH_String(); - if (da.GetData(11, ref ghnm)) { - if (GH_Convert.ToString(ghnm, out string name, GH_Conversion.Both)) { - elem.ApiElement.Name = name; - } - } - - var ghcol = new GH_Colour(); - if (da.GetData(12, ref ghcol)) { - if (GH_Convert.ToColor(ghcol, out Color col, GH_Conversion.Both)) { - elem.ApiElement.Colour = col; - } - } - - var ghdum = new GH_Boolean(); - if (da.GetData(13, ref ghdum)) { - if (GH_Convert.ToBoolean(ghdum, out bool dum, GH_Conversion.Both)) { - elem.ApiElement.IsDummy = dum; - } - } - - da.SetData(0, new GsaElement1dGoo(elem)); - da.SetData(1, elem.Id); - da.SetData(2, elem.Line.Line); - da.SetData(3, new GsaSectionGoo(elem.Section)); - da.SetData(4, elem.ApiElement.Group); - da.SetData(5, elem.ApiElement.Type); - da.SetData(6, new GsaOffsetGoo(elem.Offset)); - da.SetData(7, new GsaBool6Goo(elem.ReleaseStart)); - da.SetData(8, new GsaBool6Goo(elem.ReleaseEnd)); - da.SetData(9, elem.OrientationAngle.Degrees); - da.SetData(10, new GsaNodeGoo(elem.OrientationNode)); - da.SetData(11, elem.ApiElement.Name); - da.SetData(12, elem.ApiElement.Colour); - da.SetData(13, elem.ApiElement.IsDummy); - - try { - da.SetData(14, elem.ApiElement.ParentMember.Member); - } catch (Exception) { - // ignored - } - - da.SetDataList(15, new Collection(elem.ApiElement.Topology)); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditElement2d_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditElement2d_OBSOLETE.cs deleted file mode 100644 index 4e28c9aa1..000000000 --- a/GsaGH/Components/GraveyardComp/EditElement2d_OBSOLETE.cs +++ /dev/null @@ -1,168 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; - -namespace GsaGH.Components { - /// - /// Component to edit a 2D Element - /// - // ReSharper disable once InconsistentNaming - public class EditElement2d_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("e9611aa7-88c1-4b5b-83d6-d9629e21ad8a"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit2dElement; - - public EditElement2d_OBSOLETE() : base("Edit 2D Element", "Elem2dEdit", "Modify GSA 2D Element", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaElement2dParameter(), GsaElement2dGoo.Name, - GsaElement2dGoo.NickName, - GsaElement2dGoo.Description + " to get or set information for." + GsaElement2dGoo.Name, - GH_ParamAccess.item); - pManager.AddIntegerParameter("Element2d Number", "ID", - "Set Element Number. If ID is set it will replace any existing 2D Element in the model", - GH_ParamAccess.list); - pManager.AddParameter(new GsaProperty2dParameter(), "2D Property", "PA", - "Change 2D Property. Input either a GSA 2D Property or an Integer to use a Property already defined in model", - GH_ParamAccess.list); - pManager.AddIntegerParameter("Element2d Group", "Gr", "Set Element Group", - GH_ParamAccess.list); - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Set Element Offset", - GH_ParamAccess.list); - pManager.AddTextParameter("Element2d Name", "Na", "Set Name of Element", GH_ParamAccess.list); - pManager.AddColourParameter("Element2d Colour", "Co", "Set Element Colour", - GH_ParamAccess.list); - pManager.AddBooleanParameter("Dummy Element", "Dm", "Set Element to Dummy", - GH_ParamAccess.list); - - for (int i = 1; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - - pManager.HideParameter(0); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaElement2dParameter(), GsaElement2dGoo.Name, - GsaElement2dGoo.NickName, GsaElement2dGoo.Description + " with applied changes.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Number", "ID", "Get Element Number", GH_ParamAccess.list); - pManager.AddMeshParameter("Analysis Mesh", "M", "Get Analysis Mesh", GH_ParamAccess.item); - pManager.HideParameter(2); - pManager.AddParameter(new GsaProperty2dParameter(), "2D Property", "PA", - "Get 2D Property. Input either a GSA 2D Property or an Integer to use a Property already defined in model", - GH_ParamAccess.list); - pManager.AddIntegerParameter("Group", "Gr", "Get Element Group", GH_ParamAccess.list); - pManager.AddTextParameter("Element Type", "eT", - "Get Element 2D Type." + Environment.NewLine - + "Type can not be set; it is either Tri3 or Quad4" + Environment.NewLine - + "depending on Rhino/Grasshopper mesh face type", GH_ParamAccess.list); - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Get Element Offset", - GH_ParamAccess.list); - pManager.AddTextParameter("Name", "Na", "Set Element Name", GH_ParamAccess.list); - pManager.AddColourParameter("Colour", "Co", "Get Element Colour", GH_ParamAccess.list); - pManager.AddBooleanParameter("Dummy Element", "Dm", "Get if Element is Dummy", - GH_ParamAccess.list); - 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); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var elem = new GsaElement2d(); - - GsaElement2dGoo element2dGoo = null; - if (da.GetData(0, ref element2dGoo)) { - elem = new GsaElement2d(element2dGoo.Value); - } - - // 1 ID - var ghIds = new List(); - if (da.GetDataList(1, ghIds)) { - if (ghIds.Count != elem.ApiElements.Count) { - this.AddRuntimeError("ID input must be a list matching the number of elements " + - $"({elem.ApiElements.Count})"); - return; - } - elem.Ids = ghIds.Select(x => x.Value).ToList(); - } - - // 2 property - var prop2dGoos = new List(); - if (da.GetDataList(2, prop2dGoos)) { - if (prop2dGoos.Count == 1) { - elem.Prop2ds = new List(); - for (int i = 0; i < elem.ApiElements.Count; i++) { - elem.Prop2ds.Add(prop2dGoos[0].Value); - } - } else { - if (prop2dGoos.Count != elem.ApiElements.Count) { - this.AddRuntimeWarning("PA input must either be a single Prop2d or a" + - $"{Environment.NewLine}list matching the number of elements ({elem.ApiElements.Count})"); - } - elem.Prop2ds = prop2dGoos.Select(x => x.Value).ToList(); - } - } - - // 3 Group - var ghGrps = new List(); - if (da.GetDataList(3, ghGrps)) { - elem.ApiElements.SetMembers(ghGrps.Select(x => x.Value).ToList()); - } - - // 4 offset - var offsetGoos = new List(); - if (da.GetDataList(4, offsetGoos)) { - elem.ApiElements.SetMembers(offsetGoos.Select(x => x.Value).ToList()); - } - - // 5 name - var ghnm = new List(); - if (da.GetDataList(5, ghnm)) { - elem.ApiElements.SetMembers(ghnm.Select(x => x.Value).ToList()); - } - - // 6 Colour - var ghcols = new List(); - if (da.GetDataList(6, ghcols)) { - elem.ApiElements.SetMembers(ghcols.Select(x => x.Value).ToList()); - } - - // 7 Dummy - var ghdummies = new List(); - if (da.GetDataList(7, ghdummies)) { - elem.ApiElements.SetMembers(ghdummies.Select(x => x.Value).ToList()); - } - - da.SetData(0, new GsaElement2dGoo(elem)); - da.SetDataList(1, elem.Ids); - da.SetData(2, elem.Mesh); - da.SetDataList(3, - new List(elem.Prop2ds.ConvertAll(prop2d => new GsaProperty2dGoo(prop2d)))); - da.SetDataList(4, elem.ApiElements.Select(x => x.Group)); - da.SetDataList(5, elem.ApiElements.Select(x => x.Type)); - da.SetDataList(6, - new List(elem.Offsets.ConvertAll(offset => new GsaOffsetGoo(offset)))); - da.SetDataList(7, elem.ApiElements.Select(x => x.Name)); - da.SetDataList(8, elem.ApiElements.Select(x => (Color)x.Colour)); - da.SetDataList(9, elem.ApiElements.Select(x => x.IsDummy)); - try { - da.SetData(10, elem.ApiElements[0].ParentMember.Member); - } catch (Exception) { } - da.SetDataTree(11, elem.GetTopologyIDs()); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditMaterial_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditMaterial_OBSOLETE.cs deleted file mode 100644 index 8b5137773..000000000 --- a/GsaGH/Components/GraveyardComp/EditMaterial_OBSOLETE.cs +++ /dev/null @@ -1,169 +0,0 @@ -using System; -using System.Drawing; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; - -namespace GsaGH.Components { - /// - /// Component to edit a Material and ouput the information - /// - public class EditMaterial_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("865f73c7-a057-481a-834b-c7e12873dd39"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.EditMaterial; - - public EditMaterial_OBSOLETE() : base("Edit Material", "MaterialEdit", "Modify GSA Material", - CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaMaterialParameter(), GsaMaterialGoo.Name, - GsaMaterialGoo.NickName, - GsaMaterialGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaMaterialGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Analysis Property", "An", - "Set Material Analysis Property Number (0 -> 'from Grade'", GH_ParamAccess.item); - pManager.AddTextParameter("Material Type", "mT", - "Set Material Type" + Environment.NewLine + "Input either text string or integer:" - + Environment.NewLine + "Generic : 0" + Environment.NewLine + "Steel : 1" - + Environment.NewLine + "Concrete : 2" + Environment.NewLine + "Aluminium : 3" - + Environment.NewLine + "Glass : 4" + Environment.NewLine + "FRP : 5" + Environment.NewLine - + "Timber : 7" + Environment.NewLine + "Fabric : 8", GH_ParamAccess.item); - pManager.AddIntegerParameter("Material Grade", "Grd", "Set Material Grade", - GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaMaterialParameter(), GsaMaterialGoo.Name, - GsaMaterialGoo.NickName, GsaMaterialGoo.Description + " with applied changes.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Analysis Property", "An", - "Get Material Analysis Property (0 -> 'from Grade')", GH_ParamAccess.item); - pManager.AddTextParameter("Material Type", "mT", "Get Material Type", GH_ParamAccess.item); - pManager.AddIntegerParameter("Material Grade", "Grd", "Get Material Grade", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - GsaMaterial material = null; - - GsaMaterialGoo materialGoo = null; - if (da.GetData(0, ref materialGoo)) { - material = GsaMaterialFactory.CreateMaterial(materialGoo.Value); - } - - int id = 0; - if (da.GetData(1, ref id)) { - material.Id = id; - } - - var ghTyp = new GH_ObjectWrapper(); - if (da.GetData(2, ref ghTyp)) { - if (material.MaterialType != MatType.Custom) { - this.AddRuntimeWarning("MaterialType can only be changed for Custom Materials"); - } - - MatType type = material.MaterialType; - switch (ghTyp.Value) { - case GH_Integer ghInt: { - switch (ghInt.Value) { - case 1: - type = MatType.Steel; - break; - - case 2: - type = MatType.Concrete; - break; - - case 5: - type = MatType.Frp; - break; - - case 3: - type = MatType.Aluminium; - break; - - case 7: - type = MatType.Timber; - break; - - case 4: - type = MatType.Glass; - break; - - case 8: - type = MatType.Fabric; - break; - - case 0: - type = MatType.Custom; - break; - } - - break; - } - - case GH_String ghString: { - switch (ghString.Value.ToUpper()) { - case "STEEL": - type = MatType.Steel; - break; - - case "CONCRETE": - type = MatType.Concrete; - break; - - case "FRP": - type = MatType.Frp; - break; - - case "ALUMINIUM": - type = MatType.Aluminium; - break; - - case "TIMBER": - type = MatType.Timber; - break; - - case "GLASS": - type = MatType.Glass; - break; - - case "FABRIC": - type = MatType.Fabric; - break; - - case "GENERIC": - type = MatType.Custom; - break; - } - - break; - } - - default: - this.AddRuntimeError("Unable to convert Material Type input"); - return; - } - - material = new GsaCustomMaterial(material.AnalysisMaterial, id, type); - } - - da.SetData(0, new GsaMaterialGoo(material)); - da.SetData(1, material.Id); - da.SetData(2, material.MaterialType.ToString()); - da.SetData(3, material.Id); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditMember1d2_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditMember1d2_OBSOLETE.cs deleted file mode 100644 index 331e917fa..000000000 --- a/GsaGH/Components/GraveyardComp/EditMember1d2_OBSOLETE.cs +++ /dev/null @@ -1,269 +0,0 @@ -using System; -using System.Drawing; -using System.Linq; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysUnits; -using Rhino.Geometry; -using AngleUnit = OasysUnits.Units.AngleUnit; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to edit a 1D Member - /// - // ReSharper disable once InconsistentNaming - public class EditMember1d2_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("2a121578-f9ff-4d80-ae90-2982faa425a6"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit1dMember; - - public EditMember1d2_OBSOLETE() : base("Edit 1D Member", "Mem1dEdit", "Modify GSA 1D Member", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddGenericParameter("1D Member", "M1D", "GSA 1D Member to Modify", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member1d Number", "ID", - "Set Member Number. If ID is set it will replace any existing 1D Member in the model", - GH_ParamAccess.item); - pManager.AddCurveParameter("Curve", "C", "Member Curve", GH_ParamAccess.item); - pManager.AddGenericParameter("Section", "PB", "Change Section Property", GH_ParamAccess.item); - pManager.AddIntegerParameter("Member1d Group", "Gr", "Set Member 1D Group", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member Type", "mT", - "Set 1D Member Type" + Environment.NewLine - + "Default is 0: Generic 1D - Accepted inputs are:" + Environment.NewLine + "2: Beam" - + Environment.NewLine + "3: Column" + Environment.NewLine + "6: Cantilever" - + Environment.NewLine + "8: Compos" + Environment.NewLine + "9: Pile" + Environment.NewLine - + "11: Void cutter", GH_ParamAccess.item); - pManager.AddIntegerParameter("1D Element Type", "eT", - "Set Element 1D Type" + Environment.NewLine + "Accepted inputs are:" + Environment.NewLine - + "1: Bar" + Environment.NewLine + "2: Beam" + Environment.NewLine + "3: Spring" - + Environment.NewLine + "9: Link" + Environment.NewLine + "10: Cable" + Environment.NewLine - + "19: Spacer" + Environment.NewLine + "20: Strut" + Environment.NewLine + "21: Tie" - + Environment.NewLine + "23: Rod" + Environment.NewLine + "24: Damper", - GH_ParamAccess.item); - pManager.AddGenericParameter("Offset", "Of", "Set Member Offset", GH_ParamAccess.item); - pManager.AddGenericParameter("Start release", "⭰", "Set Release (Bool6) at Start of Member", - GH_ParamAccess.item); - pManager.AddGenericParameter("End release", "⭲", "Set Release (Bool6) at End of Member", - GH_ParamAccess.item); - pManager.AddNumberParameter("Orientation Angle", "⭮A", - "Set Member Orientation Angle in degrees", GH_ParamAccess.item); - pManager.AddGenericParameter("Orientation Node", "⭮N", "Set Member Orientation Node", - GH_ParamAccess.item); - var ms = new Length(1, DefaultUnits.LengthUnitGeometry); - pManager.AddGenericParameter("Mesh Size [" + ms.ToString("a") + "]", "Ms", - "Set Member Mesh Size", GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Mesh with others?", - GH_ParamAccess.item); - - pManager.AddTextParameter("Member1d Name", "Na", "Set Name of Member1d", GH_ParamAccess.item); - pManager.AddColourParameter("Member1d Colour", "Co", "Set Member 1D Colour", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Set Member to Dummy", - GH_ParamAccess.item); - - for (int i = 1; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - - pManager.HideParameter(0); - pManager.HideParameter(2); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddGenericParameter("1D Member", "M1D", "Modified GSA 1D Member", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member1d Number", "ID", "Get Member Number", - GH_ParamAccess.item); - pManager.AddCurveParameter("Curve", "C", "Member Curve", GH_ParamAccess.item); - pManager.HideParameter(2); - pManager.AddGenericParameter("Section", "PB", - "Change Section Property. Input either a GSA Section or an Integer to use a Section already defined in model", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member Group", "Gr", "Get Member Group", GH_ParamAccess.item); - pManager.AddIntegerParameter("Member Type", "mT", "Get 1D Member Type", GH_ParamAccess.item); - pManager.AddIntegerParameter("1D Element Type", "eT", "Get Element 1D Type", - GH_ParamAccess.item); - pManager.AddGenericParameter("Offset", "Of", "Get Member Offset", GH_ParamAccess.item); - pManager.AddGenericParameter("Start release", "⭰", "Get Release (Bool6) at Start of Member", - GH_ParamAccess.item); - pManager.AddGenericParameter("End release", "⭲", "Get Release (Bool6) at End of Member", - GH_ParamAccess.item); - pManager.AddNumberParameter("Orientation Angle", "⭮A", - "Get Member Orientation Angle in degrees", GH_ParamAccess.item); - pManager.AddGenericParameter("Orientation Node", "⭮N", "Get Member Orientation Node", - GH_ParamAccess.item); - pManager.AddGenericParameter("Mesh Size", "Ms", "Get Member Mesh Size", GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Get if to mesh with others", - GH_ParamAccess.item); - - pManager.AddTextParameter("Member Name", "Na", "Get Name of Member1d", GH_ParamAccess.item); - - pManager.AddColourParameter("Member Colour", "Co", "Get Member Colour", GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Get it Member is Dummy", - GH_ParamAccess.item); - pManager.AddTextParameter("Topology", "Tp", - "Get the Member's original topology list referencing node IDs in Model that Model was created from", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var mem = new GsaMember1d(); - - GsaMember1dGoo member1dGoo = null; - if (da.GetData(0, ref member1dGoo)) { - mem = new GsaMember1d(member1dGoo.Value); - } - - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - mem.Id = id; - } - } - - var ghCurve = new GH_Curve(); - if (da.GetData(2, ref ghCurve)) { - Curve crv = null; - if (GH_Convert.ToCurve(ghCurve, ref crv, GH_Conversion.Both)) { - mem.UpdateGeometry(crv); - } - } - - GsaSectionGoo sectionGoo = null; - if (da.GetData(3, ref sectionGoo)) { - mem.Section = sectionGoo.Value; - } - - var ghGroup = new GH_Integer(); - if (da.GetData(4, ref ghGroup)) { - if (GH_Convert.ToInt32(ghGroup, out int grp, GH_Conversion.Both)) { - mem.ApiMember.Group = grp; - } - } - - var ghInteger = new GH_Integer(); - if (da.GetData(5, ref ghInteger)) { - if (GH_Convert.ToInt32(ghInteger, out int type, GH_Conversion.Both)) { - mem.ApiMember.Type = (MemberType)type; - } - } - - var integer = new GH_Integer(); - if (da.GetData(6, ref integer)) { - if (GH_Convert.ToInt32(integer, out int type, GH_Conversion.Both)) { - mem.ApiMember.Type1D = (ElementType)type; - } - } - - GsaOffsetGoo offset = null; - if (da.GetData(7, ref offset)) { - mem.Offset = offset.Value; - } - - GsaBool6Goo start = null; - if (da.GetData(8, ref start)) { - mem.ReleaseStart = start.Value; - } - - GsaBool6Goo end = null; - if (da.GetData(9, ref end)) { - mem.ReleaseEnd = end.Value; - } - - var ghAngle = new GH_Number(); - if (da.GetData(10, ref ghAngle)) { - if (GH_Convert.ToDouble(ghAngle, out double angle, GH_Conversion.Both)) { - mem.OrientationAngle = new Angle(angle, AngleUnit.Degree); - } - } - - var ghTyp = new GH_ObjectWrapper(); - if (da.GetData(11, ref ghTyp)) { - if (ghTyp.Value is GsaNodeGoo nodeGoo) { - mem.OrientationNode = nodeGoo.Value; - } else { - this.AddRuntimeWarning("Unable to convert Orientation Node input to GsaNode"); - } - } - - if (Params.Input[12].Sources.Count > 0) { - mem.ApiMember.MeshSize - = ((Length)Input.UnitNumber(this, da, 12, DefaultUnits.LengthUnitGeometry, true)).Meters; - if (DefaultUnits.LengthUnitGeometry != LengthUnit.Meter) { - this.AddRuntimeRemark("Mesh size input set in [" - + string.Concat(mem.ApiMember.MeshSize.ToString().Where(char.IsLetter)) + "]. " - + Environment.NewLine - + "Note that this is based on your unit settings and may be changed to a different unit if you share this file or change your 'Length - geometry' unit settings. Use a UnitNumber input to use a specific unit."); - } - } - - var ghBoolean = new GH_Boolean(); - if (da.GetData(13, ref ghBoolean)) { - if (GH_Convert.ToBoolean(ghBoolean, out bool mbool, GH_Conversion.Both)) { - mem.ApiMember.IsIntersector = mbool; - } - } - - var ghName = new GH_String(); - if (da.GetData(14, ref ghName)) { - if (GH_Convert.ToString(ghName, out string name, GH_Conversion.Both)) { - mem.ApiMember.Name = name; - } - } - - var ghColour = new GH_Colour(); - if (da.GetData(15, ref ghColour)) { - if (GH_Convert.ToColor(ghColour, out Color col, GH_Conversion.Both)) { - mem.ApiMember.Colour = col; - } - } - - var ghDummy = new GH_Boolean(); - if (da.GetData(16, ref ghDummy)) { - if (GH_Convert.ToBoolean(ghDummy, out bool dum, GH_Conversion.Both)) { - mem.ApiMember.IsDummy = dum; - } - } - - da.SetData(0, new GsaMember1dGoo(mem)); - da.SetData(1, mem.Id); - da.SetData(2, mem.PolyCurve); - da.SetData(3, new GsaSectionGoo(mem.Section)); - da.SetData(4, mem.ApiMember.Group); - da.SetData(5, mem.ApiMember.Type); - da.SetData(6, mem.ApiMember.Type1D); - - da.SetData(7, new GsaOffsetGoo(mem.Offset)); - - da.SetData(8, mem.ReleaseStart); - da.SetData(9, mem.ReleaseEnd); - - da.SetData(10, mem.OrientationAngle); - da.SetData(11, new GsaNodeGoo(mem.OrientationNode)); - - da.SetData(12, new GH_UnitNumber(new Length(mem.ApiMember.MeshSize, LengthUnit.Meter) - .ToUnit(DefaultUnits.LengthUnitGeometry))); - da.SetData(13, mem.ApiMember.IsIntersector); - - da.SetData(14, mem.ApiMember.Name); - - da.SetData(15, mem.ApiMember.Colour); - da.SetData(16, mem.ApiMember.IsDummy); - da.SetData(17, mem.ApiMember.Topology); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditMember1d3_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditMember1d3_OBSOLETE.cs deleted file mode 100644 index 27e8314d6..000000000 --- a/GsaGH/Components/GraveyardComp/EditMember1d3_OBSOLETE.cs +++ /dev/null @@ -1,369 +0,0 @@ -using System; -using System.Drawing; -using System.Linq; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Parameters; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.GsaApi; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using Rhino.Geometry; -using AngleUnit = OasysUnits.Units.AngleUnit; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components.GraveyardComp { - /// - /// Component to edit a 1D Member - /// - public class EditMember1d3_OBSOLETE : GH_OasysComponent, IGH_VariableParameterComponent { - public override Guid ComponentGuid => new Guid("06ae2d01-b152-49c1-9356-c83714c4e5f4"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit1dMember; - private AngleUnit _angleUnit = AngleUnit.Radian; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - - public EditMember1d3_OBSOLETE() : base("Edit 1D Member", "Mem1dEdit", "Modify GSA 1D Member", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - - var unitsMenu = new ToolStripMenuItem("Select unit", Resources.ModelUnits) { - Enabled = true, - ImageScaling = ToolStripItemImageScaling.SizeToFit, - }; - foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => Update(unit)) { - Enabled = true, - Checked = unit == Length.GetAbbreviation(_lengthUnit), - }; - unitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - menu.Items.Add(unitsMenu); - - Menu_AppendSeparator(menu); - } - - bool IGH_VariableParameterComponent.CanInsertParameter(GH_ParameterSide side, int index) { - return false; - } - - bool IGH_VariableParameterComponent.CanRemoveParameter(GH_ParameterSide side, int index) { - return false; - } - - IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index) { - return null; - } - - bool IGH_VariableParameterComponent.DestroyParameter(GH_ParameterSide side, int index) { - return false; - } - - public override bool Read(GH_IReader reader) { - _lengthUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("LengthUnit")); - return base.Read(reader); - } - - public void VariableParameterMaintenance() { } - - public override bool Write(GH_IWriter writer) { - writer.SetString("LengthUnit", _lengthUnit.ToString()); - return base.Write(writer); - } - - protected override void BeforeSolveInstance() { - base.BeforeSolveInstance(); - if (Params.Input[10] is Param_Number angleParameter) { - _angleUnit = angleParameter.UseDegrees ? AngleUnit.Degree : AngleUnit.Radian; - } - - Message = Length.GetAbbreviation(_lengthUnit); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaMember1dParameter(), GsaMember1dGoo.Name, - GsaMember1dGoo.NickName, - GsaMember1dGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaMember1dGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Member1d Number", "ID", - "Set Member Number. If ID is set it will replace any existing 1D Member in the model.", - GH_ParamAccess.item); - pManager.AddCurveParameter("Curve", "C", "Member Curve", GH_ParamAccess.item); - pManager.AddParameter(new GsaSectionParameter(), "Section", "PB", "Set new Section Property.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member1d Group", "Gr", "Set Member 1D Group", - GH_ParamAccess.item); - pManager.AddTextParameter("Member Type", "mT", - "Set 1D Member Type" + Environment.NewLine - + "Default is 0: Generic 1D - Accepted inputs are:" + Environment.NewLine + "2: Beam" - + Environment.NewLine + "3: Column" + Environment.NewLine + "6: Cantilever" - + Environment.NewLine + "8: Compos" + Environment.NewLine + "9: Pile" + Environment.NewLine - + "11: Void cutter", GH_ParamAccess.item); - pManager.AddTextParameter("1D Element Type", "eT", - "Set Element 1D Type" + Environment.NewLine + "Accepted inputs are:" + Environment.NewLine - + "1: Bar" + Environment.NewLine + "2: Beam" + Environment.NewLine + "3: Spring" - + Environment.NewLine + "9: Link" + Environment.NewLine + "10: Cable" + Environment.NewLine - + "19: Spacer" + Environment.NewLine + "20: Strut" + Environment.NewLine + "21: Tie" - + Environment.NewLine + "23: Rod" + Environment.NewLine + "24: Damper", - GH_ParamAccess.item); - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Set Member Offset", - GH_ParamAccess.item); - pManager.AddParameter(new GsaBool6Parameter(), "Start release", "⭰", - "Set Release (Bool6) at Start of Member", GH_ParamAccess.item); - pManager.AddParameter(new GsaBool6Parameter(), "End release", "⭲", - "Set Release (Bool6) at End of Member", GH_ParamAccess.item); - pManager.AddAngleParameter("Orientation Angle", "⭮A", "Set Member Orientation Angle", - GH_ParamAccess.item); - pManager.AddParameter(new GsaNodeParameter(), "Orientation Node", "⭮N", - "Set Member Orientation Node", GH_ParamAccess.item); - pManager.AddNumberParameter("Mesh Size in model units", "Ms", "Set Member Mesh Size", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Mesh with others?", - GH_ParamAccess.item); - pManager.AddParameter(new GsaBucklingFactorsParameter(), - "Set " + GsaBucklingFactorsGoo.Name, GsaBucklingFactorsGoo.NickName, - GsaBucklingFactorsGoo.Description, GH_ParamAccess.item); - pManager.AddTextParameter("Member1d Name", "Na", "Set Name of Member1d", GH_ParamAccess.item); - pManager.AddColourParameter("Member1d Colour", "Co", "Set Member 1D Colour", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Set Member to Dummy", - GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - - pManager.HideParameter(0); - pManager.HideParameter(2); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaMember1dParameter(), GsaMember1dGoo.Name, - GsaMember1dGoo.NickName, GsaMember1dGoo.Description + " with applied changes.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member1d Number", "ID", "Get Member Number", - GH_ParamAccess.item); - pManager.AddCurveParameter("Curve", "C", "Member Curve", GH_ParamAccess.item); - pManager.HideParameter(2); - pManager.AddParameter(new GsaSectionParameter(), "Section", "PB", "Get Section Property", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member Group", "Gr", "Get Member Group", GH_ParamAccess.item); - pManager.AddTextParameter("Member Type", "mT", "Get 1D Member Type", GH_ParamAccess.item); - pManager.AddTextParameter("1D Element Type", "eT", "Get Element 1D Type", - GH_ParamAccess.item); - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Get Member Offset", - GH_ParamAccess.item); - pManager.AddParameter(new GsaBool6Parameter(), "Start release", "⭰", - "Get Release (Bool6) at Start of Member", GH_ParamAccess.item); - pManager.AddParameter(new GsaBool6Parameter(), "End release", "⭲", - "Get Release (Bool6) at End of Member", GH_ParamAccess.item); - pManager.AddNumberParameter("Orientation Angle", "⭮A", - "Get Member Orientation Angle in radians", GH_ParamAccess.item); - pManager.AddGenericParameter("Orientation Node", "⭮N", "Get Member Orientation Node", - GH_ParamAccess.item); - pManager.AddNumberParameter("Mesh Size in model units", "Ms", "Get Member Mesh Size", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Get if to mesh with others", - GH_ParamAccess.item); - pManager.AddParameter(new GsaBucklingFactorsParameter(), - "Get " + GsaBucklingFactorsGoo.Name, GsaBucklingFactorsGoo.NickName, - GsaBucklingFactorsGoo.Description, GH_ParamAccess.item); - pManager.AddTextParameter("Member Name", "Na", "Get Name of Member1d", GH_ParamAccess.item); - - pManager.AddColourParameter("Member Colour", "Co", "Get Member Colour", GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Get it Member is Dummy", - GH_ParamAccess.item); - pManager.AddTextParameter("Topology", "Tp", - "Get the Member's original topology list referencing node IDs in Model that Model was created from", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var mem = new GsaMember1d(); - - GsaMember1dGoo member1dGoo = null; - if (da.GetData(0, ref member1dGoo)) { - mem = new GsaMember1d(member1dGoo.Value); - } - - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - mem.Id = id; - } - } - - var ghcrv = new GH_Curve(); - if (da.GetData(2, ref ghcrv)) { - Curve crv = null; - if (GH_Convert.ToCurve(ghcrv, ref crv, GH_Conversion.Both)) { - mem.UpdateGeometry(crv); - } - } - - GsaSectionGoo sectionGoo = null; - if (da.GetData(3, ref sectionGoo)) { - mem.Section = sectionGoo.Value; - } - - var ghgrp = new GH_Integer(); - if (da.GetData(4, ref ghgrp)) { - if (GH_Convert.ToInt32(ghgrp, out int grp, GH_Conversion.Both)) { - mem.ApiMember.Group = grp; - } - } - - var ghstring = new GH_String(); - if (da.GetData(5, ref ghstring)) { - if (GH_Convert.ToInt32(ghstring, out int typeInt, GH_Conversion.Both)) { - mem.ApiMember.Type = (MemberType)typeInt; - } else if (GH_Convert.ToString(ghstring, out string typestring, GH_Conversion.Both)) { - try { - mem.ApiMember.Type = Mappings.GetMemberType(typestring); - } catch (ArgumentException) { - this.AddRuntimeError("Unable to change Member Type"); - } - } - } - - ghstring = new GH_String(); - if (da.GetData(6, ref ghstring)) { - if (GH_Convert.ToInt32(ghstring, out int typeInt, GH_Conversion.Both)) { - mem.ApiMember.Type1D = (ElementType)typeInt; - } else if (GH_Convert.ToString(ghstring, out string typestring, GH_Conversion.Both)) { - try { - mem.ApiMember.Type1D = Mappings.GetElementType(typestring); - } catch (ArgumentException) { - this.AddRuntimeError("Unable to change Element Type"); - } - } - } - - GsaOffsetGoo offset = null; - if (da.GetData(7, ref offset)) { - mem.Offset = offset.Value; - } - - GsaBool6Goo start = null; - if (da.GetData(8, ref start)) { - mem.ReleaseStart = start.Value; - } - - GsaBool6Goo end = null; - if (da.GetData(9, ref end)) { - mem.ReleaseEnd = end.Value; - } - - var ghangle = new GH_Number(); - if (da.GetData(10, ref ghangle)) { - if (GH_Convert.ToDouble(ghangle, out double angle, GH_Conversion.Both)) { - mem.OrientationAngle = new Angle(angle, _angleUnit); - } - } - - var ghTyp = new GH_ObjectWrapper(); - if (da.GetData(11, ref ghTyp)) { - if (ghTyp.Value is GsaNodeGoo nodeGoo) { - mem.OrientationNode = nodeGoo.Value; - } else { - this.AddRuntimeWarning("Unable to convert Orientation Node input to GsaNode"); - } - } - - double meshSize = 0; - if (da.GetData(12, ref meshSize)) { - mem.ApiMember.MeshSize = meshSize; - } - - var ghbool = new GH_Boolean(); - if (da.GetData(13, ref ghbool)) { - if (GH_Convert.ToBoolean(ghbool, out bool mbool, GH_Conversion.Both)) { - mem.ApiMember.IsIntersector = mbool; - } - } - - ghTyp = new GH_ObjectWrapper(); - if (da.GetData(14, ref ghTyp)) { - var bucklingLengthFactors = new GsaBucklingFactors(); - if (ghTyp.Value is GsaBucklingFactorsGoo blfGoo) { - bucklingLengthFactors = blfGoo.Value; - mem.ApiMember.MomentAmplificationFactorStrongAxis - = bucklingLengthFactors.MomentAmplificationFactorStrongAxis; - mem.ApiMember.MomentAmplificationFactorWeakAxis - = bucklingLengthFactors.MomentAmplificationFactorWeakAxis; - mem.ApiMember.EquivalentUniformMomentFactor - = bucklingLengthFactors.EquivalentUniformMomentFactor; - } else { - this.AddRuntimeWarning("Unable to change buckling length factors"); - } - } - - var ghnm = new GH_String(); - if (da.GetData(15, ref ghnm)) { - if (GH_Convert.ToString(ghnm, out string name, GH_Conversion.Both)) { - mem.ApiMember.Name = name; - } - } - - var ghcol = new GH_Colour(); - if (da.GetData(16, ref ghcol)) { - if (GH_Convert.ToColor(ghcol, out Color col, GH_Conversion.Both)) { - mem.ApiMember.Colour = col; - } - } - - var ghdum = new GH_Boolean(); - if (da.GetData(17, ref ghdum)) { - if (GH_Convert.ToBoolean(ghdum, out bool dum, GH_Conversion.Both)) { - mem.ApiMember.IsDummy = dum; - } - } - - da.SetData(0, new GsaMember1dGoo(mem)); - da.SetData(1, mem.Id); - da.SetData(2, mem.PolyCurve); - da.SetData(3, new GsaSectionGoo(mem.Section)); - da.SetData(4, mem.ApiMember.Group); - da.SetData(5, - Mappings.memberTypeMapping.FirstOrDefault(x => x.Value == mem.ApiMember.Type).Key); - da.SetData(6, - Mappings.elementTypeMapping.FirstOrDefault(x => x.Value == mem.ApiMember.Type1D).Key); - da.SetData(7, new GsaOffsetGoo(mem.Offset)); - da.SetData(8, new GsaBool6Goo(mem.ReleaseStart)); - da.SetData(9, new GsaBool6Goo(mem.ReleaseEnd)); - da.SetData(10, mem.OrientationAngle.Radians); - da.SetData(11, new GsaNodeGoo(mem.OrientationNode)); - da.SetData(12, mem.ApiMember.MeshSize); - da.SetData(13, mem.ApiMember.IsIntersector); - da.SetData(14, new GsaBucklingFactorsGoo(new GsaBucklingFactors(mem))); - da.SetData(15, mem.ApiMember.Name); - da.SetData(16, mem.ApiMember.Colour); - da.SetData(17, mem.ApiMember.IsDummy); - da.SetData(18, mem.ApiMember.Topology); - } - - private void Update(string unit) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), unit); - Message = unit; - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - ExpireSolution(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditMember1d_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditMember1d_OBSOLETE.cs deleted file mode 100644 index 409cdc004..000000000 --- a/GsaGH/Components/GraveyardComp/EditMember1d_OBSOLETE.cs +++ /dev/null @@ -1,365 +0,0 @@ -using System; -using System.Drawing; -using System.Linq; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Parameters; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.GsaApi; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using Rhino.Geometry; -using AngleUnit = OasysUnits.Units.AngleUnit; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to edit a 1D Member - /// - // ReSharper disable once InconsistentNaming - public class EditMember1d_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("094f676f-c384-4d49-9d7f-64515004bf4b"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit1dMember; - private AngleUnit _angleUnit = AngleUnit.Radian; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - - public EditMember1d_OBSOLETE() : base("Edit 1D Member", "Mem1dEdit", "Modify GSA 1D Member", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - - var unitsMenu = new ToolStripMenuItem("Select unit", Resources.ModelUnits) { - Enabled = true, - ImageScaling = ToolStripItemImageScaling.SizeToFit, - }; - foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => Update(unit)) { - Checked = unit == Length.GetAbbreviation(_lengthUnit), - Enabled = true, - }; - unitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - menu.Items.Add(unitsMenu); - - Menu_AppendSeparator(menu); - } - - public override bool Read(GH_IReader reader) { - if (reader.ItemExists("LengthUnit")) { - _lengthUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("LengthUnit")); - return base.Read(reader) || Params.ReadAllParameterData(reader); - } - - _lengthUnit = DefaultUnits.LengthUnitGeometry; - return base.Read(reader); - } - - public override bool Write(GH_IWriter writer) { - writer.SetString("LengthUnit", _lengthUnit.ToString()); - return base.Write(writer); - } - - protected override void BeforeSolveInstance() { - base.BeforeSolveInstance(); - if (Params.Input[10] is Param_Number angleParameter) { - _angleUnit = angleParameter.UseDegrees ? AngleUnit.Degree : AngleUnit.Radian; - } - - Message = Length.GetAbbreviation(_lengthUnit); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaMember1dParameter(), GsaMember1dGoo.Name, - GsaMember1dGoo.NickName, - GsaMember1dGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaMember1dGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Member1d Number", "ID", - "Set Member Number. If ID is set it will replace any existing 1D Member in the model.", - GH_ParamAccess.item); - pManager.AddCurveParameter("Curve", "C", "Member Curve", GH_ParamAccess.item); - pManager.AddParameter(new GsaSectionParameter(), "Section", "PB", "Set new Section Property.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member1d Group", "Gr", "Set Member 1D Group", - GH_ParamAccess.item); - pManager.AddTextParameter("Member Type", "mT", - "Set 1D Member Type" + Environment.NewLine - + "Default is 0: Generic 1D - Accepted inputs are:" + Environment.NewLine + "2: Beam" - + Environment.NewLine + "3: Column" + Environment.NewLine + "6: Cantilever" - + Environment.NewLine + "8: Compos" + Environment.NewLine + "9: Pile" + Environment.NewLine - + "11: Void cutter", GH_ParamAccess.item); - pManager.AddTextParameter("1D Element Type", "eT", - "Set Element 1D Type" + Environment.NewLine + "Accepted inputs are:" + Environment.NewLine - + "1: Bar" + Environment.NewLine + "2: Beam" + Environment.NewLine + "3: Spring" - + Environment.NewLine + "9: Link" + Environment.NewLine + "10: Cable" + Environment.NewLine - + "19: Spacer" + Environment.NewLine + "20: Strut" + Environment.NewLine + "21: Tie" - + Environment.NewLine + "23: Rod" + Environment.NewLine + "24: Damper", - GH_ParamAccess.item); - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Set Member Offset", - GH_ParamAccess.item); - pManager.AddParameter(new GsaBool6Parameter(), "Start release", "⭰", - "Set Release (Bool6) at Start of Member", GH_ParamAccess.item); - pManager.AddParameter(new GsaBool6Parameter(), "End release", "⭲", - "Set Release (Bool6) at End of Member", GH_ParamAccess.item); - pManager.AddAngleParameter("Orientation Angle", "⭮A", "Set Member Orientation Angle", - GH_ParamAccess.item); - pManager.AddGenericParameter("Orientation Node", "⭮N", "Set Member Orientation Node", - GH_ParamAccess.item); - pManager.AddGenericParameter("Mesh Size [" + Length.GetAbbreviation(_lengthUnit) + "]", "Ms", - "Set Member Mesh Size", GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Mesh with others?", - GH_ParamAccess.item); - pManager.AddParameter(new GsaBucklingFactorsParameter(), - "Set " + GsaBucklingFactorsGoo.Name, GsaBucklingFactorsGoo.NickName, - GsaBucklingFactorsGoo.Description, GH_ParamAccess.item); - pManager.AddTextParameter("Member1d Name", "Na", "Set Name of Member1d", GH_ParamAccess.item); - pManager.AddColourParameter("Member1d Colour", "Co", "Set Member 1D Colour", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Set Member to Dummy", - GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - - pManager.HideParameter(0); - pManager.HideParameter(2); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaMember1dParameter(), GsaMember1dGoo.Name, - GsaMember1dGoo.NickName, GsaMember1dGoo.Description + " with applied changes.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member1d Number", "ID", "Get Member Number", - GH_ParamAccess.item); - pManager.AddCurveParameter("Curve", "C", "Member Curve", GH_ParamAccess.item); - pManager.HideParameter(2); - pManager.AddParameter(new GsaSectionParameter(), "Section", "PB", "Get Section Property", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member Group", "Gr", "Get Member Group", GH_ParamAccess.item); - pManager.AddTextParameter("Member Type", "mT", "Get 1D Member Type", GH_ParamAccess.item); - pManager.AddTextParameter("1D Element Type", "eT", "Get Element 1D Type", - GH_ParamAccess.item); - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Get Member Offset", - GH_ParamAccess.item); - pManager.AddParameter(new GsaBool6Parameter(), "Start release", "⭰", - "Get Release (Bool6) at Start of Member", GH_ParamAccess.item); - pManager.AddParameter(new GsaBool6Parameter(), "End release", "⭲", - "Get Release (Bool6) at End of Member", GH_ParamAccess.item); - pManager.AddNumberParameter("Orientation Angle", "⭮A", - "Get Member Orientation Angle in radians", GH_ParamAccess.item); - pManager.AddGenericParameter("Orientation Node", "⭮N", "Get Member Orientation Node", - GH_ParamAccess.item); - pManager.AddGenericParameter("Mesh Size [" + Length.GetAbbreviation(_lengthUnit) + "]", "Ms", - "Get Member Mesh Size", GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Get if to mesh with others", - GH_ParamAccess.item); - pManager.AddParameter(new GsaBucklingFactorsParameter(), - "Get " + GsaBucklingFactorsGoo.Name, GsaBucklingFactorsGoo.NickName, - GsaBucklingFactorsGoo.Description, GH_ParamAccess.item); - pManager.AddTextParameter("Member Name", "Na", "Get Name of Member1d", GH_ParamAccess.item); - - pManager.AddColourParameter("Member Colour", "Co", "Get Member Colour", GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Get it Member is Dummy", - GH_ParamAccess.item); - pManager.AddTextParameter("Topology", "Tp", - "Get the Member's original topology list referencing node IDs in Model that Model was created from", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var mem = new GsaMember1d(); - - GsaMember1dGoo member1dGoo = null; - if (da.GetData(0, ref member1dGoo)) { - mem = new GsaMember1d(member1dGoo.Value); - } - - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - mem.Id = id; - } - } - - var ghCurve = new GH_Curve(); - if (da.GetData(2, ref ghCurve)) { - Curve crv = null; - if (GH_Convert.ToCurve(ghCurve, ref crv, GH_Conversion.Both)) { - mem.UpdateGeometry(crv); - } - } - - GsaSectionGoo sectionGoo = null; - if (da.GetData(3, ref sectionGoo)) { - mem.Section = sectionGoo.Value; - } - - var ghgrp = new GH_Integer(); - if (da.GetData(4, ref ghgrp)) { - if (GH_Convert.ToInt32(ghgrp, out int grp, GH_Conversion.Both)) { - mem.ApiMember.Group = grp; - } - } - - var ghString = new GH_String(); - if (da.GetData(5, ref ghString)) { - if (GH_Convert.ToInt32(ghString, out int typeInt, GH_Conversion.Both)) { - mem.ApiMember.Type = (MemberType)typeInt; - } - - if (GH_Convert.ToString(ghString, out string typestring, GH_Conversion.Both)) { - if (Mappings.elementTypeMapping.ContainsKey(typestring)) { - mem.ApiMember.Type = Mappings.memberTypeMapping[typestring]; - } else { - this.AddRuntimeError("Unable to change Element1D Type"); - } - } - } - - ghString = new GH_String(); - if (da.GetData(6, ref ghString)) { - if (GH_Convert.ToInt32(ghString, out int typeInt, GH_Conversion.Both)) { - mem.ApiMember.Type1D = (ElementType)typeInt; - } else if (GH_Convert.ToString(ghString, out string typestring, GH_Conversion.Both)) { - if (Mappings.elementTypeMapping.ContainsKey(typestring)) { - mem.ApiMember.Type1D = Mappings.elementTypeMapping[typestring]; - } else { - this.AddRuntimeError("Unable to change Element1D Type"); - } - } - } - - GsaOffsetGoo offset = null; - if (da.GetData(7, ref offset)) { - mem.Offset = offset.Value; - } - - GsaBool6Goo start = null; - if (da.GetData(8, ref start)) { - mem.ReleaseStart = start.Value; - } - - GsaBool6Goo end = null; - if (da.GetData(9, ref end)) { - mem.ReleaseEnd = end.Value; - } - - var ghAngle = new GH_Number(); - if (da.GetData(10, ref ghAngle)) { - if (GH_Convert.ToDouble(ghAngle, out double angle, GH_Conversion.Both)) { - mem.OrientationAngle = new Angle(angle, _angleUnit); - } - } - - var ghTyp = new GH_ObjectWrapper(); - if (da.GetData(11, ref ghTyp)) { - if (ghTyp.Value is GsaNodeGoo nodeGoo) { - mem.OrientationNode = nodeGoo.Value; ; - } else { - this.AddRuntimeWarning("Unable to convert Orientation Node input to GsaNode"); - } - } - - if (Params.Input[12].Sources.Count > 0) { - mem.ApiMember.MeshSize = ((Length)Input.UnitNumber(this, da, 4, _lengthUnit, true)).Meters; - } - - var ghbool = new GH_Boolean(); - if (da.GetData(13, ref ghbool)) { - if (GH_Convert.ToBoolean(ghbool, out bool mbool, GH_Conversion.Both)) { - mem.ApiMember.IsIntersector = mbool; - } - } - - ghTyp = new GH_ObjectWrapper(); - if (da.GetData(14, ref ghTyp)) { - var fls = new GsaBucklingFactors(); - if (ghTyp.Value is GsaBucklingFactorsGoo flsGoo) { - fls = flsGoo.Value; - mem.ApiMember.MomentAmplificationFactorStrongAxis - = fls.MomentAmplificationFactorStrongAxis; - mem.ApiMember.MomentAmplificationFactorWeakAxis = fls.MomentAmplificationFactorWeakAxis; - mem.ApiMember.EquivalentUniformMomentFactor = fls.EquivalentUniformMomentFactor; - } else { - this.AddRuntimeWarning("Unable to convert Orientation Node input to GsaNode"); - } - } - - var ghnm = new GH_String(); - if (da.GetData(15, ref ghnm)) { - if (GH_Convert.ToString(ghnm, out string name, GH_Conversion.Both)) { - mem.ApiMember.Name = name; - } - } - - var ghcol = new GH_Colour(); - if (da.GetData(16, ref ghcol)) { - if (GH_Convert.ToColor(ghcol, out Color col, GH_Conversion.Both)) { - mem.ApiMember.Colour = col; - } - } - - var ghdum = new GH_Boolean(); - if (da.GetData(17, ref ghdum)) { - if (GH_Convert.ToBoolean(ghdum, out bool dum, GH_Conversion.Both)) { - mem.ApiMember.IsDummy = dum; - } - } - - da.SetData(0, new GsaMember1dGoo(mem)); - da.SetData(1, mem.Id); - da.SetData(2, mem.PolyCurve); - da.SetData(3, new GsaSectionGoo(mem.Section)); - da.SetData(4, mem.ApiMember.Group); - da.SetData(5, - Mappings.memberTypeMapping.FirstOrDefault(x => x.Value == mem.ApiMember.Type).Key); - da.SetData(6, - Mappings.elementTypeMapping.FirstOrDefault(x => x.Value == mem.ApiMember.Type1D).Key); - - da.SetData(7, new GsaOffsetGoo(mem.Offset)); - - da.SetData(8, new GsaBool6Goo(mem.ReleaseStart)); - da.SetData(9, new GsaBool6Goo(mem.ReleaseEnd)); - - da.SetData(10, mem.OrientationAngle.As(AngleUnit.Radian)); - da.SetData(11, new GsaNodeGoo(mem.OrientationNode)); - - da.SetData(12, new GH_UnitNumber(new Length(mem.ApiMember.MeshSize, LengthUnit.Meter) - .ToUnit(_lengthUnit))); - da.SetData(13, mem.ApiMember.IsIntersector); - - da.SetData(14, new GsaBucklingFactorsGoo(new GsaBucklingFactors(mem))); - - da.SetData(15, mem.ApiMember.Name); - - da.SetData(16, (Color)mem.ApiMember.Colour); - da.SetData(17, mem.ApiMember.IsDummy); - da.SetData(18, mem.ApiMember.Topology); - } - - private void Update(string unit) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), unit); - Message = unit; - ExpireSolution(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditMember2d2_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditMember2d2_OBSOLETE.cs deleted file mode 100644 index 1e8319fec..000000000 --- a/GsaGH/Components/GraveyardComp/EditMember2d2_OBSOLETE.cs +++ /dev/null @@ -1,289 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.GsaApi; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using Rhino.Collections; -using Rhino.Geometry; - -namespace GsaGH.Components { - /// - /// Component to edit a 2D Member - /// - // ReSharper disable once InconsistentNaming - public class EditMember2d2_OBSOLETE : GH_OasysComponent, IGH_VariableParameterComponent { - public override Guid ComponentGuid => new Guid("54bcb967-d3a1-4878-925b-5fd765d1b476"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit2dMember; - - public EditMember2d2_OBSOLETE() : base("Edit 2D Member", "Mem2dEdit", "Modify GSA 2D Member", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - bool IGH_VariableParameterComponent.CanInsertParameter(GH_ParameterSide side, int index) { - return false; - } - - bool IGH_VariableParameterComponent.CanRemoveParameter(GH_ParameterSide side, int index) { - return false; - } - - IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index) { - return null; - } - - bool IGH_VariableParameterComponent.DestroyParameter(GH_ParameterSide side, int index) { - return false; - } - - public void VariableParameterMaintenance() { } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaMember2dParameter(), GsaMember2dGoo.Name, - GsaMember2dGoo.NickName, - GsaMember2dGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaMember2dGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Member2d Number", "ID", - "Set Member Number. If ID is set it will replace any existing 2d Member in the model", - GH_ParamAccess.item); - pManager.AddBrepParameter("Brep", "B", - "Reposition Member Brep (non-planar geometry will be automatically converted to an average plane from exterior boundary control points)", - GH_ParamAccess.item); - pManager.AddPointParameter("Incl. Points", "(P)", - "Add inclusion points (will automatically be projected onto Brep)", GH_ParamAccess.list); - pManager.AddCurveParameter("Incl. Curves", "(C)", - "Add inclusion curves (will automatically be made planar and projected onto brep, and converted to Arcs and Lines)", - GH_ParamAccess.list); - pManager.AddParameter(new GsaProperty2dParameter(), "2D Property", "PA", "Set new 2D Property.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member2d Group", "Gr", "Set Member 2d Group", - GH_ParamAccess.item); - pManager.AddTextParameter("Member Type", "mT", - "Set 2D Member Type" + Environment.NewLine - + "Default is 1: Generic 2D - Accepted inputs are:" + Environment.NewLine + "4: Slab" - + Environment.NewLine + "5: Wall" + Environment.NewLine + "7: Ribbed Slab" - + Environment.NewLine + "12: Void-cutter", GH_ParamAccess.item); - pManager.AddTextParameter("2D Element Type", "eT", - "Set Member 2D Analysis Element Type" + Environment.NewLine + "Accepted inputs are:" - + Environment.NewLine + "0: Linear - Tri3/Quad4 Elements (default)" + Environment.NewLine - + "1: Quadratic - Tri6/Quad8 Elements" + Environment.NewLine + "2: Rigid Diaphragm", - GH_ParamAccess.item); - - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Set Member Offset", - GH_ParamAccess.item); - - pManager.AddNumberParameter("Mesh Size in model units", "Ms", "Set target mesh size", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Mesh with others?", - GH_ParamAccess.item); - pManager.AddTextParameter("Member2d Name", "Na", "Set Name of Member2d", GH_ParamAccess.item); - pManager.AddColourParameter("Member2d Colour", "Co", "Set Member 2d Colour", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Set Member to Dummy", - GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - - pManager.HideParameter(0); - pManager.HideParameter(2); - pManager.HideParameter(3); - pManager.HideParameter(4); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaMember2dParameter(), GsaMember2dGoo.Name, - GsaMember2dGoo.NickName, GsaMember2dGoo.Description + " with applied changes.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member Number", "ID", "Get Member Number", GH_ParamAccess.item); - pManager.AddBrepParameter("Brep", "B", "Member Brep", GH_ParamAccess.item); - pManager.HideParameter(2); - pManager.AddPointParameter("Incl. Points", "(P)", "Get Inclusion points", - GH_ParamAccess.list); - pManager.HideParameter(3); - pManager.AddCurveParameter("Incl. Curves", "(C)", "Get Inclusion curves", - GH_ParamAccess.list); - pManager.HideParameter(4); - pManager.AddParameter(new GsaProperty2dParameter(), "2D Property", "PA", - "Get 2D Section Property", GH_ParamAccess.item); - pManager.AddIntegerParameter("Member Group", "Gr", "Get Member Group", GH_ParamAccess.item); - - pManager.AddTextParameter("Member Type", "mT", "Get 2D Member Type", GH_ParamAccess.item); - pManager.AddTextParameter("2D Element Type", "eT", - "Get Member 2D Analysis Element Type" + Environment.NewLine - + "0: Linear (Tri3/Quad4), 1: Quadratic (Tri6/Quad8), 2: Rigid Diaphragm", - GH_ParamAccess.item); - - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Get Member Offset", - GH_ParamAccess.item); - pManager.AddNumberParameter("Mesh Size in model units", "Ms", "Get Member Mesh Size", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Get if to mesh with others", - GH_ParamAccess.item); - - pManager.AddTextParameter("Member Name", "Na", "Get Name of Member", GH_ParamAccess.item); - pManager.AddColourParameter("Member Colour", "Co", "Get Member Colour", GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Get if Member is Dummy", - GH_ParamAccess.item); - pManager.AddTextParameter("Topology", "Tp", - "Get the Member's original topology list referencing node IDs in Model that Model was created from", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var mem = new GsaMember2d(); - - GsaMember2dGoo member2dGoo = null; - if (da.GetData(0, ref member2dGoo)) { - mem = new GsaMember2d(member2dGoo.Value); - } - - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - mem.Id = id; - } - } - - Brep brep = mem.Brep; - var ghBrep = new GH_Brep(); - var curveList = new CurveList(mem.InclusionLines ?? new List()); - var curves = curveList.ToList(); - var ghCurves = new List(); - var ghPoints = new List(); - Point3dList points = mem.InclusionPoints; - - if (da.GetData(2, ref ghBrep) || da.GetDataList(3, ghPoints) || da.GetDataList(4, ghCurves)) { - if (da.GetData(2, ref ghBrep)) { - GH_Convert.ToBrep(ghBrep, ref brep, GH_Conversion.Both); - } - - ghPoints = new List(); - if (da.GetDataList(3, ghPoints)) { - points = new Point3dList(); - foreach (GH_Point point in ghPoints) { - var pt = new Point3d(); - if (GH_Convert.ToPoint3d(point, ref pt, GH_Conversion.Both)) { - points.Add(pt); - } - } - } - - ghCurves = new List(); - if (da.GetDataList(4, ghCurves)) { - curves = new List(); - foreach (GH_Curve curve in ghCurves) { - Curve crv = null; - if (GH_Convert.ToCurve(curve, ref crv, GH_Conversion.Both)) { - curves.Add(crv); - } - } - } - - mem.UpdateGeometry(brep, curves, points); - } - - GsaProperty2dGoo prop2dGoo = null; - if (da.GetData(5, ref prop2dGoo)) { - mem.Prop2d = prop2dGoo.Value; - } - - var ghGroup = new GH_Integer(); - if (da.GetData(6, ref ghGroup)) { - if (GH_Convert.ToInt32(ghGroup, out int grp, GH_Conversion.Both)) { - mem.ApiMember.Group = grp; - } - } - - var ghString = new GH_String(); - if (da.GetData(7, ref ghString)) { - if (GH_Convert.ToInt32(ghString, out int typeInt, GH_Conversion.Both)) { - mem.ApiMember.Type = (MemberType)typeInt; - } else if (GH_Convert.ToString(ghString, out string typestring, GH_Conversion.Both)) { - try { - mem.ApiMember.Type = Mappings.GetMemberType(typestring); - } catch (ArgumentException) { - this.AddRuntimeError("Unable to change Member Type"); - } - } - } - - ghString = new GH_String(); - if (da.GetData(8, ref ghString)) { - if (GH_Convert.ToInt32(ghString, out int typeInt, GH_Conversion.Both)) { - mem.ApiMember.Type2D = (AnalysisOrder)typeInt; - } else if (GH_Convert.ToString(ghString, out string typestring, GH_Conversion.Both)) { - try { - mem.ApiMember.Type2D = Mappings.GetAnalysisOrder(typestring); - } catch (ArgumentException) { - this.AddRuntimeError("Unable to change Analysis Element Type"); - } - } - } - - GsaOffsetGoo offset = null; - if (da.GetData(9, ref offset)) { - mem.Offset = offset.Value; - } - - double meshSize = 0; - if (da.GetData(10, ref meshSize)) { - mem.ApiMember.MeshSize = meshSize; - } - - var ghBoolean = new GH_Boolean(); - if (da.GetData(11, ref ghBoolean)) { - if (GH_Convert.ToBoolean(ghBoolean, out bool mbool, GH_Conversion.Both)) { - mem.ApiMember.IsIntersector = mbool; - } - } - - var ghName = new GH_String(); - if (da.GetData(12, ref ghName)) { - if (GH_Convert.ToString(ghName, out string name, GH_Conversion.Both)) { - mem.ApiMember.Name = name; - } - } - - var ghColour = new GH_Colour(); - if (da.GetData(13, ref ghColour)) { - if (GH_Convert.ToColor(ghColour, out Color col, GH_Conversion.Both)) { - mem.ApiMember.Colour = col; - } - } - - var ghDummy = new GH_Boolean(); - if (da.GetData(14, ref ghDummy)) { - if (GH_Convert.ToBoolean(ghDummy, out bool dum, GH_Conversion.Both)) { - mem.ApiMember.IsDummy = dum; - } - } - - da.SetData(0, new GsaMember2dGoo(mem)); - da.SetData(1, mem.Id); - da.SetData(2, mem.Brep); - da.SetDataList(3, mem.InclusionPoints); - da.SetDataList(4, mem.InclusionLines); - da.SetData(5, new GsaProperty2dGoo(mem.Prop2d)); - da.SetData(6, mem.ApiMember.Group); - da.SetData(7, Mappings.memberTypeMapping.FirstOrDefault(x => x.Value == mem.ApiMember.Type).Key); - da.SetData(8, Mappings.analysisOrderMapping.FirstOrDefault(x => x.Value == mem.ApiMember.Type2D).Key); - da.SetData(9, new GsaOffsetGoo(mem.Offset)); - da.SetData(10, mem.ApiMember.MeshSize); - da.SetData(11, mem.ApiMember.IsIntersector); - da.SetData(12, mem.ApiMember.Name); - da.SetData(13, mem.ApiMember.Colour); - da.SetData(14, mem.ApiMember.IsDummy); - da.SetData(15, mem.ApiMember.Topology.ToString()); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditMember2d3_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditMember2d3_OBSOLETE.cs deleted file mode 100644 index d7410298c..000000000 --- a/GsaGH/Components/GraveyardComp/EditMember2d3_OBSOLETE.cs +++ /dev/null @@ -1,312 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Parameters; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.GsaApi; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysUnits; -using Rhino.Collections; -using Rhino.Geometry; -using AngleUnit = OasysUnits.Units.AngleUnit; - -namespace GsaGH.Components { - /// - /// Component to edit a 2D Member - /// - public class EditMember2d3_OBSOLETE : GH_OasysComponent, IGH_VariableParameterComponent { - public override Guid ComponentGuid => new Guid("e28ff1bf-b2ea-450a-8fd1-14e3d0981340"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit2dMember; - private AngleUnit _angleUnit = AngleUnit.Radian; - - public EditMember2d3_OBSOLETE() : base("Edit 2D Member", "Mem2dEdit", "Modify GSA 2D Member", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - bool IGH_VariableParameterComponent.CanInsertParameter(GH_ParameterSide side, int index) { - return false; - } - - bool IGH_VariableParameterComponent.CanRemoveParameter(GH_ParameterSide side, int index) { - return false; - } - - IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index) { - return null; - } - - bool IGH_VariableParameterComponent.DestroyParameter(GH_ParameterSide side, int index) { - return false; - } - - public void VariableParameterMaintenance() { } - - protected override void BeforeSolveInstance() { - base.BeforeSolveInstance(); - if (Params.Input[12] is Param_Number angleParameter) { - _angleUnit = angleParameter.UseDegrees ? AngleUnit.Degree : AngleUnit.Radian; - } - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaMember2dParameter(), GsaMember2dGoo.Name, - GsaMember2dGoo.NickName, - GsaMember2dGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaMember2dGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Member2d Number", "ID", - "Set Member Number. If ID is set it will replace any existing 2d Member in the model", - GH_ParamAccess.item); - pManager.AddBrepParameter("Brep", "B", - "Reposition Member Brep (non-planar geometry will be automatically converted to an average plane from exterior boundary control points)", - GH_ParamAccess.item); - pManager.AddPointParameter("Incl. Points", "(P)", - "Add inclusion points (will automatically be projected onto Brep)", GH_ParamAccess.list); - pManager.AddCurveParameter("Incl. Curves", "(C)", - "Add inclusion curves (will automatically be made planar and projected onto brep, and converted to Arcs and Lines)", - GH_ParamAccess.list); - pManager.AddParameter(new GsaProperty2dParameter(), "2D Property", "PA", "Set new 2D Property.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member2d Group", "Gr", "Set Member 2d Group", - GH_ParamAccess.item); - pManager.AddTextParameter("Member Type", "mT", - "Set 2D Member Type" + Environment.NewLine - + "Default is 1: Generic 2D - Accepted inputs are:" + Environment.NewLine + "4: Slab" - + Environment.NewLine + "5: Wall" + Environment.NewLine + "7: Ribbed Slab" - + Environment.NewLine + "12: Void-cutter", GH_ParamAccess.item); - pManager.AddTextParameter("2D Element Type", "eT", - "Set Member 2D Analysis Element Type" + Environment.NewLine + "Accepted inputs are:" - + Environment.NewLine + "0: Linear - Tri3/Quad4 Elements (default)" + Environment.NewLine - + "1: Quadratic - Tri6/Quad8 Elements" + Environment.NewLine + "2: Rigid Diaphragm", - GH_ParamAccess.item); - - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Set Member Offset", - GH_ParamAccess.item); - - pManager.AddNumberParameter("Mesh Size in model units", "Ms", "Set target mesh size", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Mesh with others?", - GH_ParamAccess.item); - pManager.AddAngleParameter("Orientation Angle", "⭮A", "Set Member Orientation Angle", - GH_ParamAccess.item); - - pManager.AddTextParameter("Member2d Name", "Na", "Set Name of Member2d", GH_ParamAccess.item); - pManager.AddColourParameter("Member2d Colour", "Co", "Set Member 2d Colour", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Set Member to Dummy", - GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - - pManager.HideParameter(0); - pManager.HideParameter(2); - pManager.HideParameter(3); - pManager.HideParameter(4); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaMember2dParameter(), GsaMember2dGoo.Name, - GsaMember2dGoo.NickName, GsaMember2dGoo.Description + " with applied changes.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member Number", "ID", "Get Member Number", GH_ParamAccess.item); - pManager.AddBrepParameter("Brep", "B", "Member Brep", GH_ParamAccess.item); - pManager.HideParameter(2); - pManager.AddPointParameter("Incl. Points", "(P)", "Get Inclusion points", - GH_ParamAccess.list); - pManager.HideParameter(3); - pManager.AddCurveParameter("Incl. Curves", "(C)", "Get Inclusion curves", - GH_ParamAccess.list); - pManager.HideParameter(4); - pManager.AddParameter(new GsaProperty2dParameter(), "2D Property", "PA", - "Get 2D Section Property", GH_ParamAccess.item); - pManager.AddIntegerParameter("Member Group", "Gr", "Get Member Group", GH_ParamAccess.item); - - pManager.AddTextParameter("Member Type", "mT", "Get 2D Member Type", GH_ParamAccess.item); - pManager.AddTextParameter("2D Element Type", "eT", - "Get Member 2D Analysis Element Type" + Environment.NewLine - + "0: Linear (Tri3/Quad4), 1: Quadratic (Tri6/Quad8), 2: Rigid Diaphragm", - GH_ParamAccess.item); - - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Get Member Offset", - GH_ParamAccess.item); - pManager.AddNumberParameter("Mesh Size in model units", "Ms", "Get Member Mesh Size", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Get if to mesh with others", - GH_ParamAccess.item); - pManager.AddNumberParameter("Orientation Angle", "⭮A", - "Get Member Orientation Angle in radians", GH_ParamAccess.item); - - pManager.AddTextParameter("Member Name", "Na", "Get Name of Member", GH_ParamAccess.item); - pManager.AddColourParameter("Member Colour", "Co", "Get Member Colour", GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Get if Member is Dummy", - GH_ParamAccess.item); - pManager.AddTextParameter("Topology", "Tp", - "Get the Member's original topology list referencing node IDs in Model that Model was created from", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var mem = new GsaMember2d(); - - GsaMember2dGoo member2dGoo = null; - if (da.GetData(0, ref member2dGoo)) { - mem = new GsaMember2d(member2dGoo.Value); - } - - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - mem.Id = id; - } - } - - Brep brep = mem.Brep; - var ghbrep = new GH_Brep(); - var crvlist = new CurveList(mem.InclusionLines ?? new List()); - var crvs = crvlist.ToList(); - var ghcrvs = new List(); - var ghpts = new List(); - Point3dList pts = mem.InclusionPoints; - - if (da.GetData(2, ref ghbrep) || da.GetDataList(3, ghpts) || da.GetDataList(4, ghcrvs)) { - if (da.GetData(2, ref ghbrep)) { - GH_Convert.ToBrep(ghbrep, ref brep, GH_Conversion.Both); - } - - ghpts = new List(); - if (da.GetDataList(3, ghpts)) { - pts = new Point3dList(); - foreach (GH_Point ghPoint in ghpts) { - var pt = new Point3d(); - if (GH_Convert.ToPoint3d(ghPoint, ref pt, GH_Conversion.Both)) { - pts.Add(pt); - } - } - } - - ghcrvs = new List(); - if (da.GetDataList(4, ghcrvs)) { - crvs = new List(); - foreach (GH_Curve curve in ghcrvs) { - Curve crv = null; - if (GH_Convert.ToCurve(curve, ref crv, GH_Conversion.Both)) { - crvs.Add(crv); - } - } - } - - mem.UpdateGeometry(brep, crvs, pts); - } - - GsaProperty2dGoo prop2dGoo = null; - if (da.GetData(5, ref prop2dGoo)) { - mem.Prop2d = prop2dGoo.Value; - } - - var ghgrp = new GH_Integer(); - if (da.GetData(6, ref ghgrp)) { - if (GH_Convert.ToInt32(ghgrp, out int grp, GH_Conversion.Both)) { - mem.ApiMember.Group = grp; - } - } - - var ghstring = new GH_String(); - if (da.GetData(7, ref ghstring)) { - if (GH_Convert.ToInt32(ghstring, out int typeInt, GH_Conversion.Both)) { - mem.ApiMember.Type = (MemberType)typeInt; - } else if (GH_Convert.ToString(ghstring, out string typestring, GH_Conversion.Both)) { - try { - mem.ApiMember.Type = Mappings.GetMemberType(typestring); - } catch (ArgumentException) { - this.AddRuntimeError("Unable to change Member Type"); - } - } - } - - ghstring = new GH_String(); - if (da.GetData(8, ref ghstring)) { - if (GH_Convert.ToInt32(ghstring, out int typeInt, GH_Conversion.Both)) { - mem.ApiMember.Type2D = (AnalysisOrder)typeInt; - } else if (GH_Convert.ToString(ghstring, out string typestring, GH_Conversion.Both)) { - try { - mem.ApiMember.Type2D = Mappings.GetAnalysisOrder(typestring); - } catch (ArgumentException) { - this.AddRuntimeError("Unable to change Analysis Element Type"); - } - } - } - - GsaOffsetGoo offset = null; - if (da.GetData(9, ref offset)) { - mem.Offset = offset.Value; - } - - double meshSize = 0; - if (da.GetData(10, ref meshSize)) { - mem.ApiMember.MeshSize = meshSize; - } - - var ghbool = new GH_Boolean(); - if (da.GetData(11, ref ghbool)) { - if (GH_Convert.ToBoolean(ghbool, out bool mbool, GH_Conversion.Both)) { - mem.ApiMember.IsIntersector = mbool; - } - } - - var ghangle = new GH_Number(); - if (da.GetData(12, ref ghangle)) { - if (GH_Convert.ToDouble(ghangle, out double angle, GH_Conversion.Both)) { - mem.OrientationAngle = new Angle(angle, _angleUnit); - } - } - - var ghnm = new GH_String(); - if (da.GetData(13, ref ghnm)) { - if (GH_Convert.ToString(ghnm, out string name, GH_Conversion.Both)) { - mem.ApiMember.Name = name; - } - } - - var ghcol = new GH_Colour(); - if (da.GetData(14, ref ghcol)) { - if (GH_Convert.ToColor(ghcol, out Color col, GH_Conversion.Both)) { - mem.ApiMember.Colour = col; - } - } - - var ghdum = new GH_Boolean(); - if (da.GetData(15, ref ghdum)) { - if (GH_Convert.ToBoolean(ghdum, out bool dum, GH_Conversion.Both)) { - mem.ApiMember.IsDummy = dum; - } - } - - da.SetData(0, new GsaMember2dGoo(mem)); - da.SetData(1, mem.Id); - da.SetData(2, mem.Brep); - da.SetDataList(3, mem.InclusionPoints); - da.SetDataList(4, mem.InclusionLines); - da.SetData(5, new GsaProperty2dGoo(mem.Prop2d)); - da.SetData(6, mem.ApiMember.Group); - da.SetData(7, Mappings.memberTypeMapping.FirstOrDefault(x => x.Value == mem.ApiMember.Type).Key); - da.SetData(8, Mappings.analysisOrderMapping.FirstOrDefault(x => x.Value == mem.ApiMember.Type2D).Key); - da.SetData(9, new GsaOffsetGoo(mem.Offset)); - da.SetData(10, mem.ApiMember.MeshSize); - da.SetData(11, mem.ApiMember.IsIntersector); - da.SetData(12, mem.OrientationAngle.Radians); - da.SetData(13, mem.ApiMember.Name); - da.SetData(14, mem.ApiMember.Colour); - da.SetData(15, mem.ApiMember.IsDummy); - da.SetData(16, mem.ApiMember.Topology); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditMember2d4_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditMember2d4_OBSOLETE.cs deleted file mode 100644 index 9ec7b6bf1..000000000 --- a/GsaGH/Components/GraveyardComp/EditMember2d4_OBSOLETE.cs +++ /dev/null @@ -1,290 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Parameters; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.GsaApi; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysUnits; -using Rhino.Collections; -using Rhino.Geometry; -using AngleUnit = OasysUnits.Units.AngleUnit; - -namespace GsaGH.Components { - /// - /// Component to edit a 2D Member - /// - public class EditMember2d4_OBSOLETE : GH_OasysComponent, IGH_VariableParameterComponent { - public override Guid ComponentGuid => new Guid("01390fdb-4319-46e9-9ff9-6a5d274e185d"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit2dMember; - private AngleUnit _angleUnit = AngleUnit.Radian; - - public EditMember2d4_OBSOLETE() : base("Edit 2D Member", "Mem2dEdit", "Modify GSA 2D Member", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - bool IGH_VariableParameterComponent.CanInsertParameter(GH_ParameterSide side, int index) { - return false; - } - - bool IGH_VariableParameterComponent.CanRemoveParameter(GH_ParameterSide side, int index) { - return false; - } - - IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index) { - return null; - } - - bool IGH_VariableParameterComponent.DestroyParameter(GH_ParameterSide side, int index) { - return false; - } - - public void VariableParameterMaintenance() { } - - protected override void BeforeSolveInstance() { - base.BeforeSolveInstance(); - if (Params.Input[12] is Param_Number angleParameter) { - _angleUnit = angleParameter.UseDegrees ? AngleUnit.Degree : AngleUnit.Radian; - } - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaMember2dParameter(), GsaMember2dGoo.Name, - GsaMember2dGoo.NickName, - GsaMember2dGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaMember2dGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Member2d Number", "ID", - "Set Member Number. If ID is set it will replace any existing 2d Member in the model", - GH_ParamAccess.item); - pManager.AddBrepParameter("Brep", "B", - "Reposition Member Brep (non-planar geometry will be automatically converted to an average plane from exterior boundary control points)", - GH_ParamAccess.item); - pManager.AddPointParameter("Incl. Points", "(P)", - "Add inclusion points (will automatically be projected onto Brep)", GH_ParamAccess.list); - pManager.AddCurveParameter("Incl. Curves", "(C)", - "Add inclusion curves (will automatically be made planar and projected onto brep, and converted to Arcs and Lines)", - GH_ParamAccess.list); - pManager.AddParameter(new GsaProperty2dParameter(), "2D Property", "PA", "Set new 2D Property.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member2d Group", "Gr", "Set Member 2d Group", - GH_ParamAccess.item); - pManager.AddTextParameter("Member Type", "mT", - "Set 2D Member Type" + Environment.NewLine - + "Default is 1: Generic 2D - Accepted inputs are:" + Environment.NewLine + "4: Slab" - + Environment.NewLine + "5: Wall" + Environment.NewLine + "7: Ribbed Slab" - + Environment.NewLine + "12: Void-cutter", GH_ParamAccess.item); - pManager.AddTextParameter("2D Element Type", "eT", - "Set Member 2D Analysis Element Type" + Environment.NewLine + "Accepted inputs are:" - + Environment.NewLine + "0: Linear - Tri3/Quad4 Elements (default)" + Environment.NewLine - + "1: Quadratic - Tri6/Quad8 Elements" + Environment.NewLine + "2: Rigid Diaphragm", - GH_ParamAccess.item); - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Set Member Offset", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Internal Offset", "IO", - "Set Automatic Internal Offset of Member", GH_ParamAccess.item); - pManager.AddNumberParameter("Mesh Size in model units", "Ms", "Set target mesh size", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Mesh with others?", - GH_ParamAccess.item); - pManager.AddAngleParameter("Orientation Angle", "⭮A", "Set Member Orientation Angle", - GH_ParamAccess.item); - pManager.AddTextParameter("Member2d Name", "Na", "Set Name of Member2d", GH_ParamAccess.item); - pManager.AddColourParameter("Member2d Colour", "Co", "Set Member 2d Colour", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Set Member to Dummy", - GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - - pManager.HideParameter(0); - pManager.HideParameter(2); - pManager.HideParameter(3); - pManager.HideParameter(4); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaMember2dParameter(), GsaMember2dGoo.Name, - GsaMember2dGoo.NickName, GsaMember2dGoo.Description + " with applied changes.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member Number", "ID", "Get Member Number", GH_ParamAccess.item); - pManager.AddBrepParameter("Brep", "B", "Member Brep", GH_ParamAccess.item); - pManager.HideParameter(2); - pManager.AddPointParameter("Incl. Points", "(P)", "Get Inclusion points", - GH_ParamAccess.list); - pManager.HideParameter(3); - pManager.AddCurveParameter("Incl. Curves", "(C)", "Get Inclusion curves", - GH_ParamAccess.list); - pManager.HideParameter(4); - pManager.AddParameter(new GsaProperty2dParameter(), "2D Property", "PA", - "Get 2D Section Property", GH_ParamAccess.item); - pManager.AddIntegerParameter("Member Group", "Gr", "Get Member Group", GH_ParamAccess.item); - pManager.AddTextParameter("Member Type", "mT", "Get 2D Member Type", GH_ParamAccess.item); - pManager.AddTextParameter("2D Element Type", "eT", - "Get Member 2D Analysis Element Type" + Environment.NewLine - + "0: Linear (Tri3/Quad4), 1: Quadratic (Tri6/Quad8), 2: Rigid Diaphragm", - GH_ParamAccess.item); - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Get Member Offset", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Internal Offset", "IO", - "Get Automatic Internal Offset of Member", GH_ParamAccess.item); - pManager.AddNumberParameter("Mesh Size in model units", "Ms", "Get Member Mesh Size", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Get if to mesh with others", - GH_ParamAccess.item); - pManager.AddNumberParameter("Orientation Angle", "⭮A", - "Get Member Orientation Angle in radians", GH_ParamAccess.item); - pManager.AddTextParameter("Member Name", "Na", "Get Name of Member", GH_ParamAccess.item); - pManager.AddColourParameter("Member Colour", "Co", "Get Member Colour", GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Get if Member is Dummy", - GH_ParamAccess.item); - pManager.AddTextParameter("Topology", "Tp", - "Get the Member's original topology list referencing node IDs in Model that Model was created from", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var mem = new GsaMember2d(); - - GsaMember2dGoo member2dGoo = null; - if (da.GetData(0, ref member2dGoo)) { - mem = new GsaMember2d(member2dGoo.Value); - } - - int id = 0; - if (da.GetData(1, ref id)) { - mem.Id = id; - } - - Brep brep = mem.Brep; - var ghbrep = new GH_Brep(); - var crvlist = new CurveList(mem.InclusionLines ?? new List()); - var crvs = crvlist.ToList(); - var ghcrvs = new List(); - var ghpts = new List(); - Point3dList points = mem.InclusionPoints; - - if (da.GetData(2, ref ghbrep) || da.GetDataList(3, ghpts) || da.GetDataList(4, ghcrvs)) { - if (da.GetData(2, ref ghbrep)) { - GH_Convert.ToBrep(ghbrep, ref brep, GH_Conversion.Both); - } - - ghpts = new List(); - if (da.GetDataList(3, ghpts)) { - points = new Point3dList(ghpts.ConvertAll(pt => pt.Value)); - } - - ghcrvs = new List(); - if (da.GetDataList(4, ghcrvs)) { - crvs = ghcrvs.Select(crv => crv.Value).ToList(); - } - - mem.UpdateGeometry(brep, crvs, points); - } - - GsaProperty2dGoo prop2dGoo = null; - if (da.GetData(5, ref prop2dGoo)) { - mem.Prop2d = prop2dGoo.Value; - } - - int group = 0; - if (da.GetData(6, ref group)) { - mem.ApiMember.Group = group; - } - - GH_String ghstring = null; - if (da.GetData(7, ref ghstring)) { - if (GH_Convert.ToInt32(ghstring, out int typeInt, GH_Conversion.Both)) { - mem.ApiMember.Type = (MemberType)typeInt; - } else { - try { - mem.ApiMember.Type = Mappings.GetMemberType(ghstring.Value); - } catch (ArgumentException) { - this.AddRuntimeError("Unable to change Member Type"); - } - } - } - - ghstring = null; - if (da.GetData(8, ref ghstring)) { - if (GH_Convert.ToInt32(ghstring, out int typeInt, GH_Conversion.Both)) { - mem.ApiMember.Type2D = (AnalysisOrder)typeInt; - } else { - try { - mem.ApiMember.Type2D = Mappings.GetAnalysisOrder(ghstring.Value); - } catch (ArgumentException) { - this.AddRuntimeError("Unable to change Analysis Element Type"); - } - } - } - - GsaOffsetGoo offset = null; - if (da.GetData(9, ref offset)) { - mem.Offset = offset.Value; - } - - bool internalOffset = false; - if (da.GetData(10, ref internalOffset)) { - mem.ApiMember.AutomaticOffset.Internal = internalOffset; - } - - double meshSize = 0; - if (da.GetData(11, ref meshSize)) { - mem.ApiMember.MeshSize = meshSize; - } - - bool intersector = false; - if (da.GetData(12, ref intersector)) { - mem.ApiMember.IsIntersector = intersector; - } - - double angle = 0; - if (da.GetData(13, ref angle)) { - mem.OrientationAngle = new Angle(angle, _angleUnit); - } - - string name = string.Empty; - if (da.GetData(14, ref name)) { - mem.ApiMember.Name = name; - } - - Color colour = Color.Empty; - if (da.GetData(15, ref colour)) { - mem.ApiMember.Colour = colour; - } - - bool dummy = false; - if (da.GetData(16, ref dummy)) { - mem.ApiMember.IsDummy = dummy; - } - - da.SetData(0, new GsaMember2dGoo(mem)); - da.SetData(1, mem.Id); - da.SetData(2, mem.Brep); - da.SetDataList(3, mem.InclusionPoints); - da.SetDataList(4, mem.InclusionLines); - da.SetData(5, new GsaProperty2dGoo(mem.Prop2d)); - da.SetData(6, mem.ApiMember.Group); - da.SetData(7, Mappings.memberTypeMapping.FirstOrDefault(x => x.Value == mem.ApiMember.Type).Key); - da.SetData(8, Mappings.analysisOrderMapping.FirstOrDefault(x => x.Value == mem.ApiMember.Type2D).Key); - da.SetData(9, new GsaOffsetGoo(mem.Offset)); - da.SetData(10, mem.ApiMember.AutomaticOffset.Internal); - da.SetData(11, mem.ApiMember.MeshSize); - da.SetData(12, mem.ApiMember.IsIntersector); - da.SetData(13, mem.OrientationAngle.Radians); - da.SetData(14, mem.ApiMember.Name); - da.SetData(15, mem.ApiMember.Colour); - da.SetData(16, mem.ApiMember.IsDummy); - da.SetData(17, mem.ApiMember.Topology); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditMember2d_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditMember2d_OBSOLETE.cs deleted file mode 100644 index fe8bf03e5..000000000 --- a/GsaGH/Components/GraveyardComp/EditMember2d_OBSOLETE.cs +++ /dev/null @@ -1,340 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.GsaApi; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using Rhino.Collections; -using Rhino.Geometry; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to edit a 2D Member - /// - // ReSharper disable once InconsistentNaming - public class EditMember2d_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("955e572d-1293-4ac6-b436-54135f7714f6"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit2dMember; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - - public EditMember2d_OBSOLETE() : base("Edit 2D Member", "Mem2dEdit", "Modify GSA 2D Member", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - - var unitsMenu = new ToolStripMenuItem("Select unit", Resources.ModelUnits) { - Enabled = true, - ImageScaling = ToolStripItemImageScaling.SizeToFit, - }; - foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => Update(unit)) { - Checked = unit == Length.GetAbbreviation(_lengthUnit), - Enabled = true, - }; - unitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - menu.Items.Add(unitsMenu); - - Menu_AppendSeparator(menu); - } - - public override bool Read(GH_IReader reader) { - if (reader.ItemExists("LengthUnit")) { - _lengthUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("LengthUnit")); - return base.Read(reader) || Params.ReadAllParameterData(reader); - } - - _lengthUnit = DefaultUnits.LengthUnitGeometry; - return base.Read(reader); - } - - public override bool Write(GH_IWriter writer) { - writer.SetString("LengthUnit", _lengthUnit.ToString()); - return base.Write(writer); - } - - protected override void BeforeSolveInstance() { - base.BeforeSolveInstance(); - Message = Length.GetAbbreviation(_lengthUnit); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaMember2dParameter(), GsaMember2dGoo.Name, - GsaMember2dGoo.NickName, - GsaMember2dGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaMember2dGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Member2d Number", "ID", - "Set Member Number. If ID is set it will replace any existing 2d Member in the model", - GH_ParamAccess.item); - pManager.AddBrepParameter("Brep", "B", - "Reposition Member Brep (non-planar geometry will be automatically converted to an average plane from exterior boundary control points)", - GH_ParamAccess.item); - pManager.AddPointParameter("Incl. Points", "(P)", - "Add inclusion points (will automatically be projected onto Brep)", GH_ParamAccess.list); - pManager.AddCurveParameter("Incl. Curves", "(C)", - "Add inclusion curves (will automatically be made planar and projected onto brep, and converted to Arcs and Lines)", - GH_ParamAccess.list); - pManager.AddParameter(new GsaProperty2dParameter(), "2D Property", "PA", "Set new 2D Property.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member2d Group", "Gr", "Set Member 2d Group", - GH_ParamAccess.item); - pManager.AddTextParameter("Member Type", "mT", - "Set 2D Member Type" + Environment.NewLine - + "Default is 1: Generic 2D - Accepted inputs are:" + Environment.NewLine + "4: Slab" - + Environment.NewLine + "5: Wall" + Environment.NewLine + "7: Ribbed Slab" - + Environment.NewLine + "12: Void-cutter", GH_ParamAccess.item); - pManager.AddTextParameter("2D Element Type", "aT", - "Set Member 2D Analysis Element Type" + Environment.NewLine + "Accepted inputs are:" - + Environment.NewLine + "0: Linear - Tri3/Quad4 Elements (default)" + Environment.NewLine - + "1: Quadratic - Tri6/Quad8 Elements" + Environment.NewLine + "2: Rigid Diaphragm", - GH_ParamAccess.item); - - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Set Member Offset", - GH_ParamAccess.item); - - pManager.AddGenericParameter("Mesh Size [" + Length.GetAbbreviation(_lengthUnit) + "]", "Ms", - "Set target mesh size", GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Mesh with others?", - GH_ParamAccess.item); - pManager.AddTextParameter("Member2d Name", "Na", "Set Name of Member2d", GH_ParamAccess.item); - pManager.AddColourParameter("Member2d Colour", "Co", "Set Member 2d Colour", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Set Member to Dummy", - GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - - pManager.HideParameter(0); - pManager.HideParameter(2); - pManager.HideParameter(3); - pManager.HideParameter(4); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaMember2dParameter(), GsaMember2dGoo.Name, - GsaMember2dGoo.NickName, GsaMember2dGoo.Description + " with applied changes.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member Number", "ID", "Get Member Number", GH_ParamAccess.item); - pManager.AddBrepParameter("Brep", "B", "Member Brep", GH_ParamAccess.item); - pManager.HideParameter(2); - pManager.AddPointParameter("Incl. Points", "(P)", "Get Inclusion points", - GH_ParamAccess.list); - pManager.HideParameter(3); - pManager.AddCurveParameter("Incl. Curves", "(C)", "Get Inclusion curves", - GH_ParamAccess.list); - pManager.HideParameter(4); - pManager.AddParameter(new GsaProperty2dParameter(), "2D Property", "PA", - "Get 2D Section Property", GH_ParamAccess.item); - pManager.AddIntegerParameter("Member Group", "Gr", "Get Member Group", GH_ParamAccess.item); - - pManager.AddTextParameter("Member Type", "mT", "Get 2D Member Type", GH_ParamAccess.item); - pManager.AddTextParameter("2D Element Type", "eT", - "Get Member 2D Analysis Element Type" + Environment.NewLine - + "0: Linear (Tri3/Quad4), 1: Quadratic (Tri6/Quad8), 2: Rigid Diaphragm", - GH_ParamAccess.item); - - pManager.AddParameter(new GsaOffsetParameter(), "Offset", "Of", "Get Member Offset", - GH_ParamAccess.item); - pManager.AddGenericParameter("Mesh Size [" + Length.GetAbbreviation(_lengthUnit) + "]", "Ms", - "Set Member Mesh Size", GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Get if to mesh with others", - GH_ParamAccess.item); - - pManager.AddTextParameter("Member Name", "Na", "Get Name of Member", GH_ParamAccess.item); - pManager.AddColourParameter("Member Colour", "Co", "Get Member Colour", GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Get if Member is Dummy", - GH_ParamAccess.item); - pManager.AddTextParameter("Topology", "Tp", - "Get the Member's original topology list referencing node IDs in Model that Model was created from", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var mem = new GsaMember2d(); - - GsaMember2dGoo member2dGoo = null; - if (da.GetData(0, ref member2dGoo)) { - mem = new GsaMember2d(member2dGoo.Value); - } - - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - mem.Id = id; - } - } - - Brep brep = mem.Brep; - var ghBrep = new GH_Brep(); - var curveList = new CurveList(mem.InclusionLines ?? new List()); - var curves = curveList.ToList(); - var ghCurves = new List(); - var ghPoints = new List(); - Point3dList pts = mem.InclusionPoints; - - if (da.GetData(2, ref ghBrep) || da.GetDataList(3, ghPoints) || da.GetDataList(4, ghCurves)) { - if (da.GetData(2, ref ghBrep)) { - GH_Convert.ToBrep(ghBrep, ref brep, GH_Conversion.Both); - } - - if (da.GetDataList(3, ghPoints)) { - pts = new Point3dList(); - foreach (GH_Point point in ghPoints) { - var pt = new Point3d(); - if (GH_Convert.ToPoint3d(point, ref pt, GH_Conversion.Both)) { - pts.Add(pt); - } - } - } - - if (da.GetDataList(4, ghCurves)) { - curves = new List(); - foreach (GH_Curve curve in ghCurves) { - Curve crv = null; - if (GH_Convert.ToCurve(curve, ref crv, GH_Conversion.Both)) { - curves.Add(crv); - } - } - } - - mem.UpdateGeometry(brep, curves, pts); - } - - GsaProperty2dGoo prop2dGoo = null; - if (da.GetData(5, ref prop2dGoo)) { - mem.Prop2d = prop2dGoo.Value; - } - - var ghGroup = new GH_Integer(); - if (da.GetData(6, ref ghGroup)) { - if (GH_Convert.ToInt32(ghGroup, out int grp, GH_Conversion.Both)) { - mem.ApiMember.Group = grp; - } - } - - var ghString = new GH_String(); - if (da.GetData(7, ref ghString)) { - if (GH_Convert.ToInt32(ghString, out int typeInt, GH_Conversion.Both)) { - mem.ApiMember.Type = (MemberType)typeInt; - } - - if (GH_Convert.ToString(ghString, out string typestring, GH_Conversion.Both)) { - if (Mappings.memberTypeMapping.ContainsKey(typestring)) { - mem.ApiMember.Type = Mappings.memberTypeMapping[typestring]; - } else { - this.AddRuntimeError("Unable to change Member Type"); - } - } - } - - ghString = new GH_String(); - if (da.GetData(8, ref ghString)) { - if (GH_Convert.ToInt32(ghString, out int typeInt, GH_Conversion.Both)) { - mem.ApiMember.Type2D = (AnalysisOrder)typeInt; - } - - if (GH_Convert.ToString(ghString, out string typestring, GH_Conversion.Both)) { - if (Mappings.analysisOrderMapping.ContainsKey(typestring)) { - mem.ApiMember.Type2D = Mappings.analysisOrderMapping[typestring]; - } else { - this.AddRuntimeError("Unable to change Analysis Element Type"); - } - } - } - - GsaOffsetGoo offset = null; - if (da.GetData(9, ref offset)) { - mem.Offset = offset.Value; - } - - if (Params.Input[10].Sources.Count > 0) { - mem.ApiMember.MeshSize = ((Length)Input.UnitNumber(this, da, 10, _lengthUnit, true)).Meters; - } - - var ghbool = new GH_Boolean(); - if (da.GetData(11, ref ghbool)) { - if (GH_Convert.ToBoolean(ghbool, out bool mbool, GH_Conversion.Both)) { - if (mem.ApiMember.IsIntersector != mbool) { - mem.ApiMember.IsIntersector = mbool; - } - } - } - - var ghName = new GH_String(); - if (da.GetData(12, ref ghName)) { - if (GH_Convert.ToString(ghName, out string name, GH_Conversion.Both)) { - mem.ApiMember.Name = name; - } - } - - var ghColour = new GH_Colour(); - if (da.GetData(13, ref ghColour)) { - if (GH_Convert.ToColor(ghColour, out Color col, GH_Conversion.Both)) { - mem.ApiMember.Colour = col; - } - } - - var ghDummy = new GH_Boolean(); - if (da.GetData(14, ref ghDummy)) { - if (GH_Convert.ToBoolean(ghDummy, out bool dum, GH_Conversion.Both)) { - mem.ApiMember.IsDummy = dum; - } - } - - da.SetData(0, new GsaMember2dGoo(mem)); - da.SetData(1, mem.Id); - da.SetData(2, mem.Brep); - da.SetDataList(3, mem.InclusionPoints); - da.SetDataList(4, mem.InclusionLines); - - da.SetData(5, new GsaProperty2dGoo(mem.Prop2d)); - da.SetData(6, mem.ApiMember.Group); - - da.SetData(7, Mappings.memberTypeMapping.FirstOrDefault(x => x.Value == mem.ApiMember.Type).Key); - da.SetData(8, Mappings.analysisOrderMapping.FirstOrDefault(x => x.Value == mem.ApiMember.Type2D).Key); - - da.SetData(9, new GsaOffsetGoo(mem.Offset)); - - da.SetData(10, - new GH_UnitNumber(new Length(mem.ApiMember.MeshSize, LengthUnit.Meter).ToUnit(_lengthUnit))); - da.SetData(11, mem.ApiMember.IsIntersector); - - da.SetData(12, mem.ApiMember.Name); - da.SetData(13, mem.ApiMember.Colour); - da.SetData(14, mem.ApiMember.IsDummy); - da.SetData(15, mem.ApiMember.Topology); - } - - private void Update(string unit) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), unit); - Message = unit; - ExpireSolution(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditMember3d_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditMember3d_OBSOLETE.cs deleted file mode 100644 index b2ac87572..000000000 --- a/GsaGH/Components/GraveyardComp/EditMember3d_OBSOLETE.cs +++ /dev/null @@ -1,229 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; -using Rhino.Geometry; - -namespace GsaGH.Components { - /// - /// Component to edit a 3D Member - /// - // ReSharper disable once InconsistentNaming - public class EditMember3d_OBSOLETE : GH_OasysComponent, IGH_PreviewObject { - public override Guid ComponentGuid => new Guid("955e573d-7608-4ac6-b436-54135f7714f6"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit3dMember; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - - public EditMember3d_OBSOLETE() : base("Edit 3D Member", "Mem3dEdit", "Modify GSA 3D Member", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - - var unitsMenu = new ToolStripMenuItem("Select unit", Resources.ModelUnits) { - Enabled = true, - ImageScaling = ToolStripItemImageScaling.SizeToFit, - }; - foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => Update(unit)) { - Checked = unit == Length.GetAbbreviation(_lengthUnit), - Enabled = true, - }; - unitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - menu.Items.Add(unitsMenu); - - Menu_AppendSeparator(menu); - } - - public override bool Read(GH_IReader reader) { - if (reader.ItemExists("LengthUnit")) { - _lengthUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("LengthUnit")); - return base.Read(reader) || Params.ReadAllParameterData(reader); - } - - _lengthUnit = DefaultUnits.LengthUnitGeometry; - return base.Read(reader); - } - - public override bool Write(GH_IWriter writer) { - writer.SetString("LengthUnit", _lengthUnit.ToString()); - return base.Write(writer); - } - - protected override void BeforeSolveInstance() { - Message = Length.GetAbbreviation(_lengthUnit); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaMember3dParameter(), GsaMember3dGoo.Name, - GsaMember3dGoo.NickName, - GsaMember3dGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaMember3dGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Member3d Number", "ID", - "Set Member Number. If ID is set it will replace any existing 3d Member in the model", - GH_ParamAccess.item); - pManager.AddGeometryParameter("Solid", "S", "Reposition Solid Geometry - Closed Brep or Mesh", - GH_ParamAccess.item); - pManager.AddParameter(new GsaProperty3dParameter(), "3D Property", "PV", "Set new 3D Property.", - GH_ParamAccess.item); - pManager.AddGenericParameter("Mesh Size [" + Length.GetAbbreviation(_lengthUnit) + "]", "Ms", - "Set Member Mesh Size", GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Mesh with others?", - GH_ParamAccess.item); - pManager.AddTextParameter("Member3d Name", "Na", "Set Name of Member3d", GH_ParamAccess.item); - pManager.AddIntegerParameter("Member3d Group", "Gr", "Set Member 3d Group", - GH_ParamAccess.item); - pManager.AddColourParameter("Member3d Colour", "Co", "Set Member 3d Colour", - GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Set Member to Dummy", - GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - - pManager.HideParameter(0); - pManager.HideParameter(2); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaMember3dParameter(), GsaMember3dGoo.Name, - GsaMember3dGoo.NickName, GsaMember3dGoo.Description + " with applied changes.", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Member Number", "ID", "Get Member Number", GH_ParamAccess.item); - pManager.AddMeshParameter("Solid Mesh", "M", "Member Solid Mesh", GH_ParamAccess.item); - pManager.HideParameter(2); - pManager.AddParameter(new GsaProperty3dParameter(), "3D Property", "PV", "Get 3D Property", - GH_ParamAccess.item); - pManager.AddGenericParameter("Mesh Size [" + Length.GetAbbreviation(_lengthUnit) + "]", "Ms", - "Get Targe mesh size", GH_ParamAccess.item); - pManager.AddBooleanParameter("Mesh With Others", "M/o", "Get if to mesh with others", - GH_ParamAccess.item); - pManager.AddTextParameter("Member Name", "Na", "Get Name of Member", GH_ParamAccess.item); - pManager.AddIntegerParameter("Member Group", "Gr", "Get Member Group", GH_ParamAccess.item); - pManager.AddColourParameter("Member Colour", "Co", "Get Member Colour", GH_ParamAccess.item); - pManager.AddBooleanParameter("Dummy Member", "Dm", "Get if Member is Dummy", - GH_ParamAccess.item); - pManager.AddTextParameter("Topology", "Tp", - "Get the Member's original topology list referencing node IDs in Model that Model was created from", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var mem = new GsaMember3d(); - - GsaMember3dGoo member3dGoo = null; - if (da.GetData(0, ref member3dGoo)) { - mem = new GsaMember3d(member3dGoo.Value); - } - - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - mem.Id = id; - } - } - - var ghTyp = new GH_ObjectWrapper(); - if (da.GetData(2, ref ghTyp)) { - var brep = new Brep(); - var mesh = new Mesh(); - if (GH_Convert.ToBrep(ghTyp.Value, ref brep, GH_Conversion.Both)) { - mem.UpdateGeometry(brep); - } else if (GH_Convert.ToMesh(ghTyp.Value, ref mesh, GH_Conversion.Both)) { - mem.UpdateGeometry(mesh); - } else { - this.AddRuntimeError("Unable to convert Geometry input to a 3D Member"); - return; - } - } - - GsaProperty3dGoo prop3dGoo = null; - if (da.GetData(3, ref prop3dGoo)) { - mem.Prop3d = prop3dGoo.Value; - } - - if (Params.Input[4].Sources.Count > 0) { - mem.ApiMember.MeshSize = ((Length)Input.UnitNumber(this, da, 4, _lengthUnit, true)).Meters; - } - - var ghBoolean = new GH_Boolean(); - if (da.GetData(5, ref ghBoolean)) { - if (GH_Convert.ToBoolean(ghBoolean, out bool mbool, GH_Conversion.Both)) { - if (mem.ApiMember.IsIntersector != mbool) { - mem.ApiMember.IsIntersector = mbool; - } - } - } - - var ghName = new GH_String(); - if (da.GetData(6, ref ghName)) { - if (GH_Convert.ToString(ghName, out string name, GH_Conversion.Both)) { - mem.ApiMember.Name = name; - } - } - - var ghGroup = new GH_Integer(); - if (da.GetData(7, ref ghGroup)) { - if (GH_Convert.ToInt32(ghGroup, out int grp, GH_Conversion.Both)) { - mem.ApiMember.Group = grp; - } - } - - var ghColour = new GH_Colour(); - if (da.GetData(8, ref ghColour)) { - if (GH_Convert.ToColor(ghColour, out Color col, GH_Conversion.Both)) { - mem.ApiMember.Colour = col; - } - } - - var ghDummy = new GH_Boolean(); - if (da.GetData(9, ref ghDummy)) { - if (GH_Convert.ToBoolean(ghDummy, out bool dum, GH_Conversion.Both)) { - mem.ApiMember.IsDummy = dum; - } - } - - da.SetData(0, new GsaMember3dGoo(mem)); - da.SetData(1, mem.Id); - da.SetData(2, mem.SolidMesh); - da.SetData(3, new GsaProperty3dGoo(mem.Prop3d)); - da.SetData(4, - new GH_UnitNumber(new Length(mem.ApiMember.MeshSize, LengthUnit.Meter).ToUnit(_lengthUnit))); - da.SetData(5, mem.ApiMember.IsIntersector); - da.SetData(6, mem.ApiMember.Name); - da.SetData(7, mem.ApiMember.Group); - da.SetData(8, mem.ApiMember.Colour); - da.SetData(9, mem.ApiMember.IsDummy); - da.SetData(10, mem.ApiMember.Topology); - } - - private void Update(string unit) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), unit); - Message = unit; - ExpireSolution(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditNode_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditNode_OBSOLETE.cs deleted file mode 100644 index bd0dce0ef..000000000 --- a/GsaGH/Components/GraveyardComp/EditNode_OBSOLETE.cs +++ /dev/null @@ -1,234 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Parameters; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using Rhino.Geometry; - -namespace GsaGH.Components { - /// - /// Component to edit a Node - /// - // ReSharper disable once InconsistentNaming - public class EditNode_OBSOLETE : GH_OasysComponent, IGH_VariableParameterComponent { - private enum FoldMode { - GetConnected, - DoNotGetConnected, - } - - public override Guid ComponentGuid => new Guid("de176ec0-0516-4634-8f04-82017e502e1e"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.EditNode; - private FoldMode _mode = FoldMode.DoNotGetConnected; - - public EditNode_OBSOLETE() : base("Edit Node", "NodeEdit", "Modify GSA Node", - CategoryName.Name(), SubCategoryName.Cat2()) { } - - 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 override bool Read(GH_IReader reader) { - _mode = (FoldMode)reader.GetInt32("Mode"); - return base.Read(reader); - } - - public void VariableParameterMaintenance() { - if (_mode != FoldMode.GetConnected) { - return; - } - - 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; - } - - public override bool Write(GH_IWriter writer) { - writer.SetInt32("Mode", (int)_mode); - return base.Write(writer); - } - - protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu) { - Menu_AppendItem(menu, "Try get connected Element & Members", FlipMode, true, - _mode == FoldMode.GetConnected); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaNodeParameter(), GsaNodeGoo.Name, GsaNodeGoo.NickName, - GsaNodeGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaNodeGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Node number", "ID", - "Set Node number (ID) - if Node ID is set it will replace any existing nodes in the model", - GH_ParamAccess.item); - 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.AddTextParameter("Node Name", "Na", "Set Name of Node", GH_ParamAccess.item); - pManager.AddColourParameter("Node Colour", "Co", "Set colour of node", GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - - pManager.HideParameter(0); - pManager.HideParameter(2); - pManager.HideParameter(3); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaNodeParameter(), GsaNodeGoo.Name, GsaNodeGoo.NickName, - GsaNodeGoo.Description + " with applied changes.", GH_ParamAccess.item); - pManager.AddIntegerParameter("Node number", "ID", - "Original Node number (ID) if Node ever belonged to a GSA Model", GH_ParamAccess.item); - pManager.AddPointParameter("Node Position", "Pt", - "Position (x, y, z) of Node. Setting a new position will clear any existing ID", - GH_ParamAccess.item); - pManager.HideParameter(2); - 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.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) { - return; - } - - pManager.AddIntegerParameter("Connected Elements", "El", - "Connected Element IDs in Model that Node once belonged to", GH_ParamAccess.list); - pManager.AddIntegerParameter("Connected Members", "Me", - "Connected Member IDs in Model that Node once belonged to", GH_ParamAccess.list); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var node = new GsaNode(); - - GsaNodeGoo nodeGoo = null; - if (da.GetData(0, ref nodeGoo)) { - node = new GsaNode(nodeGoo.Value); - } else { - node.Point = new Point3d(0, 0, 0); - if (Params.Input[2].SourceCount == 0) { - this.AddRuntimeRemark("New node created at {0, 0, 0}"); - } - } - - var ghPoint = new GH_Point(); - if (da.GetData(2, ref ghPoint)) { - var pt = new Point3d(); - if (GH_Convert.ToPoint3d(ghPoint, ref pt, GH_Conversion.Both)) { - node.Point = pt; - } - } - - var ghInt = new GH_Integer(); - if (da.GetData(1, ref ghInt)) { - if (GH_Convert.ToInt32(ghInt, out int id, GH_Conversion.Both)) { - node.Id = id; - } - } - - var ghPlane = new GH_Plane(); - if (da.GetData(3, ref ghPlane)) { - var pln = new Plane(); - if (GH_Convert.ToPlane(ghPlane, ref pln, GH_Conversion.Both)) { - pln.Origin = node.Point; - node.LocalAxis = pln; - } - } - - GsaBool6Goo restraintGoo = null; - if (da.GetData(4, ref restraintGoo)) { - node.Restraint = restraintGoo.Value; - } - - var ghName = new GH_String(); - if (da.GetData(5, ref ghName)) { - if (GH_Convert.ToString(ghName, out string name, GH_Conversion.Both)) { - node.ApiNode.Name = name; - } - } - - var ghColour = new GH_Colour(); - if (da.GetData(6, ref ghColour)) { - if (GH_Convert.ToColor(ghColour, out Color col, GH_Conversion.Both)) { - node.ApiNode.Colour = col; - } - } - - da.SetData(0, new GsaNodeGoo(node)); - da.SetData(1, node.Id); - 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); - da.SetData(6, node.ApiNode.Colour); - - if (_mode != FoldMode.GetConnected) { - return; - } - - try { - da.SetDataList(7, node.ApiNode?.ConnectedElements); - } catch (Exception) { - // ignored - } - - try { - da.SetDataList(8, node.ApiNode?.ConnectedMembers); - } catch (Exception) { - // ignored - } - } - - private void FlipMode(object sender, EventArgs e) { - RecordUndoEvent("GetConnected Parameters"); - if (_mode == FoldMode.GetConnected) { - _mode = FoldMode.DoNotGetConnected; - - while (Params.Output.Count > 8) { - Params.UnregisterOutputParameter(Params.Output[8], true); - } - } else { - _mode = FoldMode.GetConnected; - - Params.RegisterOutputParam(new Param_Integer()); - Params.RegisterOutputParam(new Param_Integer()); - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - } - - Params.OnParametersChanged(); - ExpireSolution(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditOffset_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditOffset_OBSOLETE.cs deleted file mode 100644 index 3835ccb12..000000000 --- a/GsaGH/Components/GraveyardComp/EditOffset_OBSOLETE.cs +++ /dev/null @@ -1,155 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; - -namespace GsaGH.Components { - /// - /// Component to edit an Offset and ouput the information - /// - // ReSharper disable once InconsistentNaming - public class EditOffset_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("1e094fcd-8f5f-4047-983c-e0e57a83ae52"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.EditOffset; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitSection; - - public EditOffset_OBSOLETE() : base("Edit Offset", "OffsetEdit", - "Modify GSA Offset or just get information about existing", CategoryName.Name(), - SubCategoryName.Cat1()) { - Hidden = true; - } - - public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - - var unitsMenu = new ToolStripMenuItem("Select unit", Resources.ModelUnits) { - Enabled = true, - ImageScaling = ToolStripItemImageScaling.SizeToFit, - }; - foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => Update(unit)) { - Checked = unit == Length.GetAbbreviation(_lengthUnit), - Enabled = true, - }; - unitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - menu.Items.Add(unitsMenu); - - Menu_AppendSeparator(menu); - } - - public override bool Read(GH_IReader reader) { - if (reader.ItemExists("LengthUnit")) { - _lengthUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("LengthUnit")); - bool flag = base.Read(reader); - return flag & Params.ReadAllParameterData(reader); - } else { - _lengthUnit = DefaultUnits.LengthUnitSection; - return base.Read(reader); - } - } - - public override bool Write(GH_IWriter writer) { - writer.SetString("LengthUnit", _lengthUnit.ToString()); - return base.Write(writer); - } - - protected override void BeforeSolveInstance() { - Message = Length.GetAbbreviation(_lengthUnit); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - string unitAbbreviation = Length.GetAbbreviation(_lengthUnit); - - pManager.AddParameter(new GsaOffsetParameter(), GsaOffsetGoo.Name, GsaOffsetGoo.NickName, - GsaOffsetGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaOffsetGoo.Name, GH_ParamAccess.item); - pManager.AddGenericParameter("Offset X1 [" + unitAbbreviation + "]", "X1", - "X1 - Start axial offset", GH_ParamAccess.item); - pManager.AddGenericParameter("Offset X2 [" + unitAbbreviation + "]", "X2", - "X2 - End axial offset", GH_ParamAccess.item); - pManager.AddGenericParameter("Offset Y [" + unitAbbreviation + "]", "Y", "Y Offset", - GH_ParamAccess.item); - pManager.AddGenericParameter("Offset Z [" + unitAbbreviation + "]", "Z", "Z Offset", - GH_ParamAccess.item); - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - string unitAbbreviation = Length.GetAbbreviation(_lengthUnit); - - pManager.AddParameter(new GsaOffsetParameter(), GsaOffsetGoo.Name, GsaOffsetGoo.NickName, - GsaOffsetGoo.Description + " with applied changes.", GH_ParamAccess.item); - pManager.AddGenericParameter("Offset X1 [" + unitAbbreviation + "]", "X1", - "X1 - Start axial offset", GH_ParamAccess.item); - pManager.AddGenericParameter("Offset X2 [" + unitAbbreviation + "]", "X2", - "X2 - End axial offset", GH_ParamAccess.item); - pManager.AddGenericParameter("Offset Y [" + unitAbbreviation + "]", "Y", "Y Offset", - GH_ParamAccess.item); - pManager.AddGenericParameter("Offset Z [" + unitAbbreviation + "]", "Z", "Z Offset", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var offset = new GsaOffset(); - - GsaOffsetGoo offsetGoo = null; - if (da.GetData(0, ref offsetGoo)) { - offset = offsetGoo.Value.Duplicate(); - } - - int inp = 1; - if (Params.Input[inp].SourceCount != 0) { - offset.X1 = (Length)Input.UnitNumber(this, da, inp++, _lengthUnit, true); - } - - if (Params.Input[inp].SourceCount != 0) { - offset.X2 = (Length)Input.UnitNumber(this, da, inp++, _lengthUnit, true); - } - - if (Params.Input[inp].SourceCount != 0) { - offset.Y = (Length)Input.UnitNumber(this, da, inp++, _lengthUnit, true); - } - - if (Params.Input[inp].SourceCount != 0) { - offset.Z = (Length)Input.UnitNumber(this, da, inp, _lengthUnit, true); - } - - int outp = 0; - da.SetData(outp++, new GsaOffsetGoo(offset)); - - da.SetData(outp++, new GH_UnitNumber(offset.X1.ToUnit(_lengthUnit))); - da.SetData(outp++, new GH_UnitNumber(offset.X2.ToUnit(_lengthUnit))); - da.SetData(outp++, new GH_UnitNumber(offset.Y.ToUnit(_lengthUnit))); - da.SetData(outp, new GH_UnitNumber(offset.Z.ToUnit(_lengthUnit))); - } - - private void Update(string unit) { - _lengthUnit = Length.ParseUnit(unit); - Message = unit; - ExpireSolution(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditProp2d2_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditProp2d2_OBSOLETE.cs deleted file mode 100644 index 825dcfd2c..000000000 --- a/GsaGH/Components/GraveyardComp/EditProp2d2_OBSOLETE.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System; -using System.Drawing; -using System.Linq; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysUnits; - -namespace GsaGH.Components { - /// - /// Component to edit a Prop2d and ouput the information - /// - // ReSharper disable once InconsistentNaming - public class EditProp2d2_OBSOLETE : GH_OasysComponent, IGH_PreviewObject { - public override Guid ComponentGuid => new Guid("4cfdee19-451b-4ee3-878b-93a86767ffef"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit2dProperty; - - public EditProp2d2_OBSOLETE() : base("Edit 2D Property", "Prop2dEdit", "Modify GSA 2D Property", - CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - IQuantity quantity = new Length(0, DefaultUnits.LengthUnitSection); - string unitAbbreviation = string.Concat(quantity.ToString().Where(char.IsLetter)); - - pManager.AddGenericParameter("2D Property", "PA", - "GSA 2D Property to get or set information for", GH_ParamAccess.item); - pManager.AddIntegerParameter("Prop2d Number", "ID", - "Set 2D Property Number. If ID is set it will replace any existing 2D Property in the model", - GH_ParamAccess.item); - pManager.AddGenericParameter("Material", "Ma", - "Set GSA Material or reference existing material by ID", GH_ParamAccess.item); - pManager.AddGenericParameter("Thickness [" + unitAbbreviation + "]", "Th", - "Set Property Thickness", GH_ParamAccess.item); - pManager.AddIntegerParameter("Axis", "Ax", - "Set Axis as integer: Global (0) or Topological (1)", GH_ParamAccess.item); - pManager.AddTextParameter("Prop2d Name", "Na", "Set Name of 2D Proerty", GH_ParamAccess.item); - pManager.AddColourParameter("Prop2d Colour", "Co", "Set 2D Property Colour", - GH_ParamAccess.item); - for (int i = 1; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddGenericParameter("2D Property", "PA", "GSA 2D Property with changes", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Prop2d Number", "ID", "2D Property Number", - GH_ParamAccess.item); - pManager.AddGenericParameter("Material", "Ma", "Get GSA Material", GH_ParamAccess.item); - pManager.AddGenericParameter("Thickness", "Th", "Get Property Thickness", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Axis", "Ax", "Get Axis: Global (0) or Topological (1)", - GH_ParamAccess.item); - pManager.AddTextParameter("Prop2d Name", "Na", "Name of 2D Proerty", GH_ParamAccess.item); - pManager.AddColourParameter("Prop2d Colour", "Co", "2D Property Colour", GH_ParamAccess.item); - pManager.AddGenericParameter("Type", "Ty", "2D Property Type", GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var prop = new GsaProperty2d(); - - GsaProperty2dGoo prop2dGoo = null; - if (da.GetData(0, ref prop2dGoo)) { - prop = new GsaProperty2d(prop2dGoo.Value); - } - - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - prop.Id = id; - } - } - - GsaMaterialGoo materialGoo = null; - if (da.GetData(2, ref materialGoo)) { - prop.Material = materialGoo.Value; - } - - if (Params.Input[3].SourceCount > 0) { - prop.Thickness - = (Length)Input.UnitNumber(this, da, 3, DefaultUnits.LengthUnitSection, true); - } - - var ghAxis = new GH_Integer(); - if (da.GetData(4, ref ghAxis)) { - if (GH_Convert.ToInt32(ghAxis, out int axis, GH_Conversion.Both)) { - prop.ApiProp2d.AxisProperty = axis; - } - } - - var ghString = new GH_String(); - if (da.GetData(5, ref ghString)) { - if (GH_Convert.ToString(ghString, out string name, GH_Conversion.Both)) { - prop.ApiProp2d.Name = name; - } - } - - var ghColour = new GH_Colour(); - if (da.GetData(6, ref ghColour)) { - if (GH_Convert.ToColor(ghColour, out Color col, GH_Conversion.Both)) { - prop.ApiProp2d.Colour = col; - } - } - - int ax = (prop.ApiProp2d == null) ? 0 : prop.ApiProp2d.AxisProperty; - string nm = (prop.ApiProp2d == null) ? "--" : prop.ApiProp2d.Name; - ValueType colour = prop.ApiProp2d?.Colour; - - da.SetData(0, new GsaProperty2dGoo(prop)); - da.SetData(1, prop.Id); - da.SetData(2, new GsaMaterialGoo(prop.Material)); - da.SetData(3, - prop.ApiProp2d?.Description == string.Empty ? new GH_UnitNumber(Length.Zero) : - new GH_UnitNumber(prop.Thickness)); - da.SetData(4, ax); - da.SetData(5, nm); - da.SetData(6, colour); - - string str = (prop.ApiProp2d == null) ? "--" : prop.ApiProp2d.Type.ToString(); - if (prop.ApiProp2d == null) { - str = char.ToUpper(str[0]) + str.Substring(1).ToLower().Replace("_", " "); - } - - da.SetData(7, str); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditProp2d3_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditProp2d3_OBSOLETE.cs deleted file mode 100644 index bedc8fc48..000000000 --- a/GsaGH/Components/GraveyardComp/EditProp2d3_OBSOLETE.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Drawing; -using System.Linq; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.GsaApi; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to edit a Prop2d and ouput the information - /// - [SuppressMessage("ReSharper", "InconsistentNaming")] - public class EditProp2d3_OBSOLETE : GH_OasysComponent, IGH_VariableParameterComponent { - public override Guid ComponentGuid => new Guid("6f18fffc-e03c-45cd-9d4c-b02bb6e2d10a"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit2dProperty; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitSection; - - public EditProp2d3_OBSOLETE() : base("Edit 2D Property", "Prop2dEdit", "Modify GSA 2D Property", - CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - - var unitsMenu = new ToolStripMenuItem("Select unit", Resources.ModelUnits) { - Enabled = true, - ImageScaling = ToolStripItemImageScaling.SizeToFit, - }; - foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => Update(unit)) { - Enabled = true, - Checked = unit == Length.GetAbbreviation(_lengthUnit), - }; - unitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - menu.Items.Add(unitsMenu); - - Menu_AppendSeparator(menu); - } - - bool IGH_VariableParameterComponent.CanInsertParameter(GH_ParameterSide side, int index) { - return false; - } - - bool IGH_VariableParameterComponent.CanRemoveParameter(GH_ParameterSide side, int index) { - return false; - } - - IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index) { - return null; - } - - bool IGH_VariableParameterComponent.DestroyParameter(GH_ParameterSide side, int index) { - return false; - } - - public override bool Read(GH_IReader reader) { - _lengthUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("LengthUnit")); - return base.Read(reader); - } - - public virtual void VariableParameterMaintenance() { - Params.Input[3].Name = "Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]"; - Params.Output[3].Name = "Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]"; - } - - public override bool Write(GH_IWriter writer) { - writer.SetString("LengthUnit", _lengthUnit.ToString()); - return base.Write(writer); - } - - protected override void BeforeSolveInstance() { - Message = Length.GetAbbreviation(_lengthUnit); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaProperty2dParameter(), GsaProperty2dGoo.Name, GsaProperty2dGoo.NickName, - GsaProperty2dGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaProperty2dGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Prop2d Number", "ID", - "Set 2D Property Number. If ID is set it will replace any existing 2D Property in the model", - GH_ParamAccess.item); - pManager.AddParameter(new GsaMaterialParameter()); - pManager.AddGenericParameter("Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]", "Th", - "Set Property Thickness", GH_ParamAccess.item); - pManager.AddIntegerParameter("Axis", "Ax", - "Set Axis as integer: Global (0) or Topological (-1)", GH_ParamAccess.item); - pManager.AddTextParameter("Prop2d Name", "Na", "Set Name of 2D Proerty", GH_ParamAccess.item); - pManager.AddColourParameter("Prop2d Colour", "Co", "Set 2D Property Colour", - GH_ParamAccess.item); - pManager.AddTextParameter("Type", "Ty", - "Set 2D Property Type." + Environment.NewLine + "Input either text string or integer:" - + Environment.NewLine + "Plane Stress : 1" + Environment.NewLine + "Plane Strain : 2" - + Environment.NewLine + "Axis Symmetric : 3" + Environment.NewLine + "Fabric : 4" - + Environment.NewLine + "Plate : 5" + Environment.NewLine + "Shell : 6" - + Environment.NewLine + "Curved Shell : 7" + Environment.NewLine + "Torsion : 8" - + Environment.NewLine + "Wall : 9" + Environment.NewLine + "Load : 10", - GH_ParamAccess.item); - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaProperty2dParameter(), GsaProperty2dGoo.Name, GsaProperty2dGoo.NickName, - GsaProperty2dGoo.Description + " with applied changes.", GH_ParamAccess.item); - pManager.AddIntegerParameter("Prop2d Number", "ID", "2D Property Number", - GH_ParamAccess.item); - pManager.AddParameter(new GsaMaterialParameter()); - pManager.AddGenericParameter("Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]", "Th", - "Get Property Thickness", GH_ParamAccess.item); - pManager.AddIntegerParameter("Axis", "Ax", "Get Axis: Global (0) or Topological (1)", - GH_ParamAccess.item); - pManager.AddTextParameter("Prop2d Name", "Na", "Name of 2D Proerty", GH_ParamAccess.item); - pManager.AddColourParameter("Prop2d Colour", "Co", "2D Property Colour", GH_ParamAccess.item); - pManager.AddTextParameter("Type", "Ty", "2D Property Type", GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var prop = new GsaProperty2d(); - - GsaProperty2dGoo prop2dGoo = null; - if (da.GetData(0, ref prop2dGoo)) { - prop = new GsaProperty2d(prop2dGoo.Value); - } - - if (prop != null) { - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - prop.Id = id; - } - } - - GsaMaterialGoo materialGoo = null; - if (da.GetData(2, ref materialGoo)) { - prop.Material = materialGoo.Value; - } - - if (Params.Input[3].SourceCount > 0) { - prop.Thickness = (Length)Input.UnitNumber(this, da, 3, _lengthUnit, true); - } - - var ghAxis = new GH_Integer(); - if (da.GetData(4, ref ghAxis)) { - if (GH_Convert.ToInt32(ghAxis, out int axis, GH_Conversion.Both)) { - prop.ApiProp2d.AxisProperty = axis; - } - } - - var ghName = new GH_String(); - if (da.GetData(5, ref ghName)) { - if (GH_Convert.ToString(ghName, out string name, GH_Conversion.Both)) { - prop.ApiProp2d.Name = name; - } - } - - var ghColour = new GH_Colour(); - if (da.GetData(6, ref ghColour)) { - if (GH_Convert.ToColor(ghColour, out Color col, GH_Conversion.Both)) { - prop.ApiProp2d.Colour = col; - } - } - - var ghType = new GH_ObjectWrapper(); - if (da.GetData(7, ref ghType)) { - if (GH_Convert.ToInt32(ghType, out int number, GH_Conversion.Both)) { - prop.ApiProp2d.Type = (Property2D_Type)number; - } else if (GH_Convert.ToString(ghType, out string type, GH_Conversion.Both)) { - prop.ApiProp2d.Type = GsaProperty2d.PropTypeFromString(type); - } - } - - int ax = (prop.ApiProp2d == null) ? 0 : prop.ApiProp2d.AxisProperty; - string nm = (prop.ApiProp2d == null) ? "--" : prop.ApiProp2d.Name; - ValueType colour = prop.ApiProp2d?.Colour; - - da.SetData(0, new GsaProperty2dGoo(prop)); - da.SetData(1, prop.Id); - da.SetData(2, new GsaMaterialGoo(prop.Material)); - da.SetData(3, - prop.ApiProp2d?.Description == string.Empty ? new GH_UnitNumber(Length.Zero) : - new GH_UnitNumber(prop.Thickness.ToUnit(_lengthUnit))); - da.SetData(4, ax); - da.SetData(5, nm); - da.SetData(6, colour); - - da.SetData(7, Mappings.prop2dTypeMapping.FirstOrDefault(x => x.Value == prop.ApiProp2d.Type).Key); - } else { - this.AddRuntimeError("Prop2d is Null"); - } - } - - private void Update(string unit) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), unit); - Message = unit; - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - ExpireSolution(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditProp2d4_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditProp2d4_OBSOLETE.cs deleted file mode 100644 index 470756256..000000000 --- a/GsaGH/Components/GraveyardComp/EditProp2d4_OBSOLETE.cs +++ /dev/null @@ -1,234 +0,0 @@ -using System; -using System.Drawing; -using System.Linq; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.GsaApi; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using Rhino.Geometry; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components.GraveyardComp { - // ReSharper disable once InconsistentNaming - public class EditProp2d4_OBSOLETE : GH_OasysComponent, IGH_VariableParameterComponent { - public override Guid ComponentGuid => new Guid("dfb17a0f-a856-4a54-ae5c-d794961f3c52"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit2dProperty; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitSection; - - public EditProp2d4_OBSOLETE() : base("Edit 2D Property", "Prop2dEdit", "Modify GSA 2D Property", - CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - - var unitsMenu = new ToolStripMenuItem("Select unit", Resources.ModelUnits) { - Enabled = true, - ImageScaling = ToolStripItemImageScaling.SizeToFit, - }; - foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => Update(unit)) { - Checked = unit == Length.GetAbbreviation(_lengthUnit), - Enabled = true, - }; - unitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - menu.Items.Add(unitsMenu); - - Menu_AppendSeparator(menu); - } - - bool IGH_VariableParameterComponent.CanInsertParameter(GH_ParameterSide side, int index) { - return false; - } - - bool IGH_VariableParameterComponent.CanRemoveParameter(GH_ParameterSide side, int index) { - return false; - } - - IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index) { - return null; - } - - bool IGH_VariableParameterComponent.DestroyParameter(GH_ParameterSide side, int index) { - return false; - } - - public override bool Read(GH_IReader reader) { - _lengthUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("LengthUnit")); - return base.Read(reader); - } - - public virtual void VariableParameterMaintenance() { - Params.Input[3].Name = "Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]"; - Params.Output[3].Name = "Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]"; - } - - public override bool Write(GH_IWriter writer) { - writer.SetString("LengthUnit", _lengthUnit.ToString()); - return base.Write(writer); - } - - protected override void BeforeSolveInstance() { - Message = Length.GetAbbreviation(_lengthUnit); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaProperty2dParameter(), GsaProperty2dGoo.Name, GsaProperty2dGoo.NickName, - GsaProperty2dGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaProperty2dGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Prop2d Number", "ID", - "Set 2D Property Number. If ID is set it will replace any existing 2D Property in the model", - GH_ParamAccess.item); - pManager.AddParameter(new GsaMaterialParameter()); - pManager.AddGenericParameter("Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]", "Th", - "Set Property Thickness", GH_ParamAccess.item); - pManager.AddGenericParameter("Axis", "Ax", - "Input a Plane to set a custom Axis or input an integer (Global (0) or Topological (-1)) to reference a predefined Axis in the model", - GH_ParamAccess.item); - pManager.AddTextParameter("Prop2d Name", "Na", "Set Name of 2D Proerty", GH_ParamAccess.item); - pManager.AddColourParameter("Prop2d Colour", "Co", "Set 2D Property Colour", - GH_ParamAccess.item); - pManager.AddTextParameter("Type", "Ty", - "Set 2D Property Type." + Environment.NewLine + "Input either text string or integer:" - + Environment.NewLine + "Plane Stress : 1" + Environment.NewLine + "Plane Strain : 2" - + Environment.NewLine + "Axis Symmetric : 3" + Environment.NewLine + "Fabric : 4" - + Environment.NewLine + "Plate : 5" + Environment.NewLine + "Shell : 6" - + Environment.NewLine + "Curved Shell : 7" + Environment.NewLine + "Torsion : 8" - + Environment.NewLine + "Wall : 9" + Environment.NewLine + "Load : 10", - GH_ParamAccess.item); - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaProperty2dParameter(), GsaProperty2dGoo.Name, GsaProperty2dGoo.NickName, - GsaProperty2dGoo.Description + " with applied changes.", GH_ParamAccess.item); - pManager.AddIntegerParameter("Prop2d Number", "ID", "2D Property Number", - GH_ParamAccess.item); - pManager.AddParameter(new GsaMaterialParameter()); - pManager.AddGenericParameter("Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]", "Th", - "Get Property Thickness", GH_ParamAccess.item); - pManager.AddGenericParameter("Axis", "Ax", - "Get Local Axis either as Plane for custom or an integer (Global (0) or Topological (1)) for referenced Axis.", - GH_ParamAccess.item); - pManager.AddTextParameter("Prop2d Name", "Na", "Name of 2D Proerty", GH_ParamAccess.item); - pManager.AddColourParameter("Prop2d Colour", "Co", "2D Property Colour", GH_ParamAccess.item); - pManager.AddTextParameter("Type", "Ty", "2D Property Type", GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var prop = new GsaProperty2d(); - - GsaProperty2dGoo prop2dGoo = null; - if (da.GetData(0, ref prop2dGoo)) { - prop = new GsaProperty2d(prop2dGoo.Value); - } - - if (prop != null) { - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - prop.Id = id; - } - } - - GsaMaterialGoo materialGoo = null; - if (da.GetData(2, ref materialGoo)) { - prop.Material = materialGoo.Value; - } - - if (Params.Input[3].SourceCount > 0) { - prop.Thickness = (Length)Input.UnitNumber(this, da, 3, _lengthUnit, true); - } - - var ghObjectWrapper = new GH_ObjectWrapper(); - if (da.GetData(4, ref ghObjectWrapper)) { - var pln = new Plane(); - if (ghObjectWrapper.Value.GetType() == typeof(GH_Plane)) { - if (GH_Convert.ToPlane(ghObjectWrapper.Value, ref pln, GH_Conversion.Both)) { - prop.LocalAxis = pln; - } - } else if (GH_Convert.ToInt32(ghObjectWrapper.Value, out int axis, GH_Conversion.Both)) { - prop.ApiProp2d.AxisProperty = axis; - } - } - - var ghString = new GH_String(); - if (da.GetData(5, ref ghString)) { - if (GH_Convert.ToString(ghString, out string name, GH_Conversion.Both)) { - prop.ApiProp2d.Name = name; - } - } - - var ghColour = new GH_Colour(); - if (da.GetData(6, ref ghColour)) { - if (GH_Convert.ToColor(ghColour, out Color col, GH_Conversion.Both)) { - prop.ApiProp2d.Colour = col; - } - } - - var ghType = new GH_ObjectWrapper(); - if (da.GetData(7, ref ghType)) { - if (GH_Convert.ToInt32(ghType, out int number, GH_Conversion.Both)) { - prop.ApiProp2d.Type = (Property2D_Type)number; - } else if (GH_Convert.ToString(ghType, out string type, GH_Conversion.Both)) { - prop.ApiProp2d.Type = GsaProperty2d.PropTypeFromString(type); - } - } - - int ax = (prop.ApiProp2d == null) ? 0 : prop.ApiProp2d.AxisProperty; - string nm = (prop.ApiProp2d == null) ? "--" : prop.ApiProp2d.Name; - ValueType colour = prop.ApiProp2d?.Colour; - - da.SetData(0, new GsaProperty2dGoo(prop)); - da.SetData(1, prop.Id); - da.SetData(2, new GsaMaterialGoo(prop.Material)); - da.SetData(3, - prop.ApiProp2d.Description == string.Empty ? new GH_UnitNumber(Length.Zero) : - new GH_UnitNumber(prop.Thickness.ToUnit(_lengthUnit))); - if (prop.ApiProp2d.AxisProperty == -2) { - da.SetData(4, new GH_Plane(prop.LocalAxis)); - } else { - da.SetData(4, ax); - } - - da.SetData(5, nm); - da.SetData(6, colour); - - da.SetData(7, Mappings.prop2dTypeMapping.FirstOrDefault(x => x.Value == prop.ApiProp2d.Type).Key); - } else { - this.AddRuntimeError("Prop2d is Null"); - } - } - - private void Update(string unit) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), unit); - Message = unit; - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - ExpireSolution(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditProp2d5_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditProp2d5_OBSOLETE.cs deleted file mode 100644 index f9d1ee587..000000000 --- a/GsaGH/Components/GraveyardComp/EditProp2d5_OBSOLETE.cs +++ /dev/null @@ -1,288 +0,0 @@ -using System; -using System.Drawing; -using System.Linq; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.GsaApi; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using Rhino.Geometry; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to edit a Prop2d and ouput the information - /// - public class EditProp2d5_OBSOLETE : GH_OasysComponent, IGH_VariableParameterComponent { - public override Guid ComponentGuid => new Guid("8cb4eacb-5f7d-49cf-a89a-87f8456fc308"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit2dProperty; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitSection; - private int _referenceEdge; - private int _supportTypeIndex; - - public EditProp2d5_OBSOLETE() : base("Edit 2D Property", "Prop2dEdit", "Modify GSA 2D Property", - CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - - var unitsMenu = new ToolStripMenuItem("Select unit", Resources.ModelUnits) { - Enabled = true, - ImageScaling = ToolStripItemImageScaling.SizeToFit, - }; - foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => Update(unit)) { - Checked = unit == Length.GetAbbreviation(_lengthUnit), - Enabled = true, - }; - unitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - menu.Items.Add(unitsMenu); - - Menu_AppendSeparator(menu); - } - - bool IGH_VariableParameterComponent.CanInsertParameter(GH_ParameterSide side, int index) { - return false; - } - - bool IGH_VariableParameterComponent.CanRemoveParameter(GH_ParameterSide side, int index) { - return false; - } - - IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index) { - return null; - } - - bool IGH_VariableParameterComponent.DestroyParameter(GH_ParameterSide side, int index) { - return false; - } - - public override bool Read(GH_IReader reader) { - _lengthUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("LengthUnit")); - _supportTypeIndex = reader.GetInt32("SupportType"); - _referenceEdge = reader.GetInt32("ReferenceEdge"); - return base.Read(reader); - } - - public virtual void VariableParameterMaintenance() { - Params.Input[3].Name = "Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]"; - Params.Output[3].Name = "Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]"; - } - - public override bool Write(GH_IWriter writer) { - writer.SetString("LengthUnit", _lengthUnit.ToString()); - writer.SetInt32("SupportType", _supportTypeIndex); - writer.SetInt32("ReferenceEdge", _referenceEdge); - return base.Write(writer); - } - - protected override void BeforeSolveInstance() { - Message = Length.GetAbbreviation(_lengthUnit); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaProperty2dParameter(), GsaProperty2dGoo.Name, GsaProperty2dGoo.NickName, - GsaProperty2dGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaProperty2dGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Prop2d Number", "ID", - "Set 2D Property Number. If ID is set it will replace any existing 2D Property in the model", - GH_ParamAccess.item); - pManager.AddParameter(new GsaMaterialParameter()); - pManager.AddGenericParameter("Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]", "Th", - "Set Property Thickness", GH_ParamAccess.item); - pManager.AddGenericParameter("Axis", "Ax", - "Input a Plane to set a custom Axis or input an integer (Global (0) or Topological (-1)) to reference a predefined Axis in the model", - GH_ParamAccess.item); - pManager.AddGenericParameter("Support Type", "ST", - "Set Load Panel Support Type." + Environment.NewLine - + "Input either text string or integer:" + Environment.NewLine + "Auto : 1" - + Environment.NewLine + "All Edges : 2" + Environment.NewLine + "Three Edges : 3" - + Environment.NewLine + "Two Edges : 4" + Environment.NewLine + "Two Adjacent Edges : 5" - + Environment.NewLine + "One Edge : 6" + Environment.NewLine + "Cantilever : 7", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Reference Edge", "RE", - "Reference Edge for Load Panels with support type other than Auto and All Edges", - GH_ParamAccess.item); - - pManager.AddTextParameter("Prop2d Name", "Na", "Set Name of 2D Proerty", GH_ParamAccess.item); - pManager.AddColourParameter("Prop2d Colour", "Co", "Set 2D Property Colour", - GH_ParamAccess.item); - pManager.AddTextParameter("Type", "Ty", - "Set 2D Property Type." + Environment.NewLine + "Input either text string or integer:" - + Environment.NewLine + "Plane Stress : 1" + Environment.NewLine + "Plane Strain : 2" - + Environment.NewLine + "Axis Symmetric : 3" + Environment.NewLine + "Fabric : 4" - + Environment.NewLine + "Plate : 5" + Environment.NewLine + "Shell : 6" - + Environment.NewLine + "Curved Shell : 7" + Environment.NewLine + "Torsion : 8" - + Environment.NewLine + "Wall : 9" + Environment.NewLine + "Load : 10", - GH_ParamAccess.item); - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - // pManager.HideParameter(6);//hide reference edge - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaProperty2dParameter(), GsaProperty2dGoo.Name, GsaProperty2dGoo.NickName, - GsaProperty2dGoo.Description + " with applied changes.", GH_ParamAccess.item); - pManager.AddIntegerParameter("Prop2d Number", "ID", "2D Property Number", - GH_ParamAccess.item); - pManager.AddParameter(new GsaMaterialParameter()); - pManager.AddGenericParameter("Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]", "Th", - "Get Property Thickness", GH_ParamAccess.item); - pManager.AddGenericParameter("Axis", "Ax", - "Get Local Axis either as Plane for custom or an integer (Global (0) or Topological (1)) for referenced Axis.", - GH_ParamAccess.item); - pManager.AddGenericParameter("Support Type", "ST", "Support Type", GH_ParamAccess.item); - pManager.AddIntegerParameter("Reference Edge", "RE", - "Reference Edge for Load Panels with support type other than Auto and All Edges", - GH_ParamAccess.item); - pManager.AddTextParameter("Prop2d Name", "Na", "Name of 2D Proerty", GH_ParamAccess.item); - pManager.AddColourParameter("Prop2d Colour", "Co", "2D Property Colour", GH_ParamAccess.item); - pManager.AddTextParameter("Type", "Ty", "2D Property Type", GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var prop = new GsaProperty2d(); - - GsaProperty2dGoo prop2dGoo = null; - if (da.GetData(0, ref prop2dGoo)) { - prop = new GsaProperty2d(prop2dGoo.Value); - } - - if (prop != null) { - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - prop.Id = id; - } - } - - GsaMaterialGoo materialGoo = null; - if (da.GetData(2, ref materialGoo)) { - prop.Material = materialGoo.Value; - } - - if (Params.Input[3].SourceCount > 0) { - prop.Thickness = (Length)Input.UnitNumber(this, da, 3, _lengthUnit, true); - } - - var ghObjectWrapper = new GH_ObjectWrapper(); - if (da.GetData(4, ref ghObjectWrapper)) { - var pln = new Plane(); - if (ghObjectWrapper.Value.GetType() == typeof(GH_Plane)) { - if (GH_Convert.ToPlane(ghObjectWrapper.Value, ref pln, GH_Conversion.Both)) { - prop.LocalAxis = pln; - } - } else if (GH_Convert.ToInt32(ghObjectWrapper.Value, out int axis, GH_Conversion.Both)) { - prop.ApiProp2d.AxisProperty = axis; - } - } - - // first we need to set type then if load - // we can set support Type and then if not load support type - // we can set reference egde - var ghType = new GH_ObjectWrapper(); - if (da.GetData(9, ref ghType)) { - if (GH_Convert.ToInt32(ghType, out int number, GH_Conversion.Both)) { - prop.ApiProp2d.Type = (Property2D_Type)number; - } else if (GH_Convert.ToString(ghType, out string type, GH_Conversion.Both)) { - prop.ApiProp2d.Type = GsaProperty2d.PropTypeFromString(type); - } - } - - var ghSupportType = new GH_ObjectWrapper(); - if (da.GetData(5, ref ghSupportType)) { - var supportTypeIndex = new GH_Integer(); - if (ghSupportType.Value is GH_Integer) { - ghSupportType.CastTo(ref supportTypeIndex); - prop.ApiProp2d.SupportType = (SupportType)supportTypeIndex.Value; - } else if (GH_Convert.ToString(ghSupportType.Value, out string supportTypeName, - GH_Conversion.Both)) { - supportTypeName = supportTypeName.Replace(" ", string.Empty).Replace("1", "One") - .Replace("2", "Two").Replace("3", "Three"); - supportTypeName = supportTypeName.Replace("all", "All").Replace("adj", "Adj") - .Replace("auto", "Auto").Replace("edge", "Edge").Replace("cant", "Cant"); - prop.ApiProp2d.SupportType = (SupportType)Enum.Parse(typeof(SupportType), supportTypeName); - } else { - this.AddRuntimeError("Cannot convert support type"); - } - } - - var ghReferenceEdge = new GH_Integer(); - if (da.GetData(6, ref ghReferenceEdge)) { - if (GH_Convert.ToInt32(ghReferenceEdge, out int referenceEdge, GH_Conversion.Both)) { - prop.ApiProp2d.ReferenceEdge = referenceEdge; - } - } - - var ghString = new GH_String(); - if (da.GetData(7, ref ghString)) { - if (GH_Convert.ToString(ghString, out string name, GH_Conversion.Both)) { - prop.ApiProp2d.Name = name; - } - } - - var ghColour = new GH_Colour(); - if (da.GetData(8, ref ghColour)) { - if (GH_Convert.ToColor(ghColour, out Color col, GH_Conversion.Both)) { - prop.ApiProp2d.Colour = col; - } - } - - int ax = (prop.ApiProp2d == null) ? 0 : prop.ApiProp2d.AxisProperty; - string nm = (prop.ApiProp2d == null) ? "--" : prop.ApiProp2d.Name; - ValueType colour = prop.ApiProp2d?.Colour; - - da.SetData(0, new GsaProperty2dGoo(prop)); - da.SetData(1, prop.Id); - da.SetData(2, new GsaMaterialGoo(prop.Material)); - da.SetData(3, - prop.ApiProp2d.Description == string.Empty ? new GH_UnitNumber(Length.Zero) : - new GH_UnitNumber(prop.Thickness.ToUnit(_lengthUnit))); - if (prop.ApiProp2d.AxisProperty == -2) { - da.SetData(4, new GH_Plane(prop.LocalAxis)); - } else { - da.SetData(4, ax); - } - - da.SetData(5, prop.ApiProp2d.SupportType); - da.SetData(6, prop.ApiProp2d.SupportType != SupportType.Auto ? prop.ApiProp2d.ReferenceEdge : -1); - da.SetData(7, nm); - da.SetData(8, colour); - - da.SetData(9, Mappings.prop2dTypeMapping.FirstOrDefault(x => x.Value == prop.ApiProp2d.Type).Key); - } else { - this.AddRuntimeError("Prop2d is Null"); - } - } - - private void Update(string unit) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), unit); - Message = unit; - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - ExpireSolution(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditProp2d6_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditProp2d6_OBSOLETE.cs deleted file mode 100644 index 73cd7fe67..000000000 --- a/GsaGH/Components/GraveyardComp/EditProp2d6_OBSOLETE.cs +++ /dev/null @@ -1,305 +0,0 @@ -using System; -using System.Drawing; -using System.Linq; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.GsaApi; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using Rhino.Geometry; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to edit a Prop2d and ouput the information - /// - public class EditProp2d6_OBSOLETE : GH_OasysComponent, IGH_VariableParameterComponent { - public override Guid ComponentGuid => new Guid("5e7627a2-9c3c-4ace-9a08-f9c9a7106755"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit2dProperty; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitSection; - private int _referenceEdge; - private int _supportTypeIndex; - - public EditProp2d6_OBSOLETE() : base("Edit 2D Property", "Prop2dEdit", "Modify GSA 2D Property", - CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - - var unitsMenu = new ToolStripMenuItem("Select unit", Resources.ModelUnits) { - Enabled = true, - ImageScaling = ToolStripItemImageScaling.SizeToFit, - }; - foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => Update(unit)) { - Checked = unit == Length.GetAbbreviation(_lengthUnit), - Enabled = true, - }; - unitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - menu.Items.Add(unitsMenu); - - Menu_AppendSeparator(menu); - } - - bool IGH_VariableParameterComponent.CanInsertParameter(GH_ParameterSide side, int index) { - return false; - } - - bool IGH_VariableParameterComponent.CanRemoveParameter(GH_ParameterSide side, int index) { - return false; - } - - IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index) { - return null; - } - - bool IGH_VariableParameterComponent.DestroyParameter(GH_ParameterSide side, int index) { - return false; - } - - public override bool Read(GH_IReader reader) { - _lengthUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("LengthUnit")); - _supportTypeIndex = reader.GetInt32("SupportType"); - _referenceEdge = reader.GetInt32("ReferenceEdge"); - return base.Read(reader); - } - - public virtual void VariableParameterMaintenance() { - Params.Input[3].Name = "Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]"; - Params.Output[3].Name = "Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]"; - } - - public override bool Write(GH_IWriter writer) { - writer.SetString("LengthUnit", _lengthUnit.ToString()); - writer.SetInt32("SupportType", _supportTypeIndex); - writer.SetInt32("ReferenceEdge", _referenceEdge); - return base.Write(writer); - } - - protected override void BeforeSolveInstance() { - Message = Length.GetAbbreviation(_lengthUnit); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaProperty2dParameter(), GsaProperty2dGoo.Name, GsaProperty2dGoo.NickName, - GsaProperty2dGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaProperty2dGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Prop2d Number", "ID", - "Set 2D Property Number. If ID is set it will replace any existing 2D Property in the model", - GH_ParamAccess.item); - pManager.AddParameter(new GsaMaterialParameter()); - pManager.AddGenericParameter("Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]", "Th", - "Set Property Thickness", GH_ParamAccess.item); - pManager.AddGenericParameter("Axis", "Ax", - "Input a Plane to set a custom Axis or input an integer (Global (0) or Topological (-1)) to reference a predefined Axis in the model", - GH_ParamAccess.item); - pManager.AddGenericParameter("Support Type", "ST", - "Set Load Panel Support Type." + Environment.NewLine - + "Input either text string or integer:" + Environment.NewLine + "Auto : 1" - + Environment.NewLine + "All Edges : 2" + Environment.NewLine + "Three Edges : 3" - + Environment.NewLine + "Two Edges : 4" + Environment.NewLine + "Two Adjacent Edges : 5" - + Environment.NewLine + "One Edge : 6" + Environment.NewLine + "Cantilever : 7", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Reference Edge", "RE", - "Reference Edge for Load Panels with support type other than Auto and All Edges", - GH_ParamAccess.item); - - pManager.AddTextParameter("Prop2d Name", "Na", "Set Name of 2D Proerty", GH_ParamAccess.item); - pManager.AddColourParameter("Prop2d Colour", "Co", "Set 2D Property Colour", - GH_ParamAccess.item); - pManager.AddTextParameter("Type", "Ty", - "Set 2D Property Type." + Environment.NewLine + "Input either text string or integer:" - + Environment.NewLine + "Plane Stress : 1" + Environment.NewLine + "Plane Strain : 2" - + Environment.NewLine + "Axis Symmetric : 3" + Environment.NewLine + "Fabric : 4" - + Environment.NewLine + "Plate : 5" + Environment.NewLine + "Shell : 6" - + Environment.NewLine + "Curved Shell : 7" + Environment.NewLine + "Torsion : 8" - + Environment.NewLine + "Wall : 9" + Environment.NewLine + "Load : 10", - GH_ParamAccess.item); - pManager.AddGenericParameter("Reference Surface", "RS", - "Reference Surface Middle = 0, Top = 1 (default), Bottom = 2", GH_ParamAccess.item); - pManager.AddGenericParameter($"Offset [{Length.GetAbbreviation(_lengthUnit)}]", "Off", "Additional Offset", - GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - // pManager.HideParameter(6);//hide reference edge - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaProperty2dParameter(), GsaProperty2dGoo.Name, GsaProperty2dGoo.NickName, - GsaProperty2dGoo.Description + " with applied changes.", GH_ParamAccess.item); - pManager.AddIntegerParameter("Prop2d Number", "ID", "2D Property Number", - GH_ParamAccess.item); - pManager.AddParameter(new GsaMaterialParameter()); - pManager.AddGenericParameter("Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]", "Th", - "Get Property Thickness", GH_ParamAccess.item); - pManager.AddGenericParameter("Axis", "Ax", - "Get Local Axis either as Plane for custom or an integer (Global (0) or Topological (1)) for referenced Axis.", - GH_ParamAccess.item); - pManager.AddGenericParameter("Support Type", "ST", "Support Type", GH_ParamAccess.item); - pManager.AddIntegerParameter("Reference Edge", "RE", - "Reference Edge for Load Panels with support type other than Auto and All Edges", - GH_ParamAccess.item); - pManager.AddTextParameter("Prop2d Name", "Na", "Name of 2D Proerty", GH_ParamAccess.item); - pManager.AddColourParameter("Prop2d Colour", "Co", "2D Property Colour", GH_ParamAccess.item); - pManager.AddTextParameter("Type", "Ty", "2D Property Type", GH_ParamAccess.item); - pManager.AddGenericParameter("Reference Surface", "RS", - "Reference Surface Middle = 0, Top = 1 (default), Bottom = 2", GH_ParamAccess.item); - pManager.AddGenericParameter($"Offset [{Length.GetAbbreviation(_lengthUnit)}]", "Off", "Additional Offset", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var prop = new GsaProperty2d(); - - GsaProperty2dGoo prop2dGoo = null; - if (da.GetData(0, ref prop2dGoo)) { - prop = new GsaProperty2d(prop2dGoo.Value); - } - - int id = 0; - if (da.GetData(1, ref id)) { - prop.Id = id; - } - - GsaMaterialGoo materialGoo = null; - if (da.GetData(2, ref materialGoo)) { - prop.Material = materialGoo.Value; - } - - if (Params.Input[3].SourceCount > 0) { - prop.Thickness = (Length)Input.UnitNumber(this, da, 3, _lengthUnit, true); - } - - var ghPlaneOrInt = new GH_ObjectWrapper(); - if (da.GetData(4, ref ghPlaneOrInt)) { - var pln = new Plane(); - if (ghPlaneOrInt.Value.GetType() == typeof(GH_Plane)) { - if (GH_Convert.ToPlane(ghPlaneOrInt.Value, ref pln, GH_Conversion.Both)) { - prop.LocalAxis = pln; - } - } else if (GH_Convert.ToInt32(ghPlaneOrInt.Value, out int axis, GH_Conversion.Both)) { - prop.ApiProp2d.AxisProperty = axis; - } - } - - // first we need to set type then if load - // we can set support Type and then if not load support type - // we can set reference egde - GH_ObjectWrapper ghType = null; - if (da.GetData(9, ref ghType)) { - if (GH_Convert.ToInt32(ghType, out int number, GH_Conversion.Both)) { - prop.ApiProp2d.Type = (Property2D_Type)number; - } else if (GH_Convert.ToString(ghType, out string type, GH_Conversion.Both)) { - prop.ApiProp2d.Type = GsaProperty2d.PropTypeFromString(type); - } - } - - GH_ObjectWrapper ghSupportType = null; - if (da.GetData(5, ref ghSupportType)) { - if (ghSupportType.Value is GH_Integer supportTypeIndex) { - prop.ApiProp2d.SupportType = (SupportType)supportTypeIndex.Value; - } else if (GH_Convert.ToString(ghSupportType.Value, out string supportTypeName, - GH_Conversion.Both)) { - supportTypeName = supportTypeName.Replace(" ", string.Empty).Replace("1", "One") - .Replace("2", "Two").Replace("3", "Three"); - supportTypeName = supportTypeName.Replace("all", "All").Replace("adj", "Adj") - .Replace("auto", "Auto").Replace("edge", "Edge").Replace("cant", "Cant"); - prop.ApiProp2d.SupportType = (SupportType)Enum.Parse(typeof(SupportType), supportTypeName); - } else { - this.AddRuntimeError("Cannot convert support type to 'int' or 'string'"); - } - } - - int refEdge = 0; - if (da.GetData(6, ref refEdge)) { - prop.ApiProp2d.ReferenceEdge = refEdge; - } - - string name = string.Empty; - if (da.GetData(7, ref name)) { - prop.ApiProp2d.Name = name; - } - - Color colour = Color.Empty; - if (da.GetData(8, ref colour)) { - prop.ApiProp2d.Colour = colour; - } - - var ghReferenceSurface = new GH_ObjectWrapper(); - if (da.GetData("Reference Surface", ref ghReferenceSurface)) { - try { - if (GH_Convert.ToInt32(ghReferenceSurface.Value, out int reference, GH_Conversion.Both)) { - prop.ApiProp2d.ReferenceSurface = (ReferenceSurface)reference; - } else if (GH_Convert.ToString(ghReferenceSurface, out string value, GH_Conversion.Both)) { - prop.ApiProp2d.ReferenceSurface = - (ReferenceSurface)Enum.Parse(typeof(ReferenceSurface), value, ignoreCase: true); - } - } catch { - this.AddRuntimeError("Unable to convert input " + ghReferenceSurface.Value + " to a Reference Surface (Middle = 0, Top = 1, Bottom = 2)"); - return; - } - } - - var ghOffset = new GH_Number(); - if (da.GetData(11, ref ghOffset)) { - if (GH_Convert.ToDouble(ghOffset, out double offset, GH_Conversion.Both)) { - prop.AdditionalOffsetZ = new Length(offset, _lengthUnit); - } - } - - int ax = (prop.ApiProp2d == null) ? 0 : prop.ApiProp2d.AxisProperty; - string nm = (prop.ApiProp2d == null) ? "--" : prop.ApiProp2d.Name; - - da.SetData(0, new GsaProperty2dGoo(prop)); - da.SetData(1, prop.Id); - da.SetData(2, new GsaMaterialGoo(prop.Material)); - da.SetData(3, - prop.ApiProp2d.Description == string.Empty ? new GH_UnitNumber(Length.Zero) : - new GH_UnitNumber(prop.Thickness.ToUnit(_lengthUnit))); - if (prop.ApiProp2d.AxisProperty == -2) { - da.SetData(4, new GH_Plane(prop.LocalAxis)); - } else { - da.SetData(4, ax); - } - - da.SetData(5, prop.ApiProp2d.SupportType); - da.SetData(6, prop.ApiProp2d.SupportType != SupportType.Auto ? prop.ApiProp2d.ReferenceEdge : -1); - da.SetData(7, nm); - da.SetData(8, prop.ApiProp2d?.Colour); - da.SetData(9, Mappings.prop2dTypeMapping.FirstOrDefault(x => x.Value == prop.ApiProp2d.Type).Key); - da.SetData(10, prop.ApiProp2d.ReferenceSurface); - da.SetData(11, prop.AdditionalOffsetZ.ToUnit(_lengthUnit)); - } - - private void Update(string unit) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), unit); - Message = unit; - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - ExpireSolution(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditProp2d_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditProp2d_OBSOLETE.cs deleted file mode 100644 index 55bcfb533..000000000 --- a/GsaGH/Components/GraveyardComp/EditProp2d_OBSOLETE.cs +++ /dev/null @@ -1,207 +0,0 @@ -using System; -using System.Drawing; -using System.Linq; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.GsaApi; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to edit a Prop2d and ouput the information - /// - // ReSharper disable once InconsistentNaming - public class EditProp2d_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("ab8af109-7ebc-4e49-9f5d-d4cb8ee45557"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Edit2dProperty; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitSection; - - public EditProp2d_OBSOLETE() : base("Edit 2D Property", "Prop2dEdit", "Modify GSA 2D Property", - CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - - var unitsMenu = new ToolStripMenuItem("Select unit", Resources.ModelUnits) { - Enabled = true, - ImageScaling = ToolStripItemImageScaling.SizeToFit, - }; - foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => Update(unit)) { - Checked = unit == Length.GetAbbreviation(_lengthUnit), - Enabled = true, - }; - unitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - menu.Items.Add(unitsMenu); - - Menu_AppendSeparator(menu); - } - - public override bool Read(GH_IReader reader) { - if (reader.ItemExists("LengthUnit")) { - _lengthUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("LengthUnit")); - } else { - _lengthUnit = DefaultUnits.LengthUnitSection; - } - - return base.Read(reader); - } - - public override bool Write(GH_IWriter writer) { - writer.SetString("LengthUnit", _lengthUnit.ToString()); - return base.Write(writer); - } - - protected override void BeforeSolveInstance() { - Message = Length.GetAbbreviation(_lengthUnit); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaProperty2dParameter(), GsaProperty2dGoo.Name, GsaProperty2dGoo.NickName, - GsaProperty2dGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaProperty2dGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Prop2d Number", "ID", - "Set 2D Property Number. If ID is set it will replace any existing 2D Property in the model", - GH_ParamAccess.item); - pManager.AddParameter(new GsaMaterialParameter()); - pManager.AddGenericParameter("Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]", "Th", - "Set Property Thickness", GH_ParamAccess.item); - pManager.AddIntegerParameter("Axis", "Ax", - "Set Axis as integer: Global (0) or Topological (1)", GH_ParamAccess.item); - pManager.AddTextParameter("Prop2d Name", "Na", "Set Name of 2D Proerty", GH_ParamAccess.item); - pManager.AddColourParameter("Prop2d Colour", "Co", "Set 2D Property Colour", - GH_ParamAccess.item); - pManager.AddTextParameter("Type", "Ty", - "Set 2D Property Type." + Environment.NewLine + "Input either text string or integer:" - + Environment.NewLine + "Plane Stress : 1" + Environment.NewLine + "Plane Strain : 2" - + Environment.NewLine + "Axis Symmetric : 3" + Environment.NewLine + "Fabric : 4" - + Environment.NewLine + "Plate : 5" + Environment.NewLine + "Shell : 6" - + Environment.NewLine + "Curved Shell : 7" + Environment.NewLine + "Torsion : 8" - + Environment.NewLine + "Wall : 9" + Environment.NewLine + "Load : 10", - GH_ParamAccess.item); - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaProperty2dParameter(), GsaProperty2dGoo.Name, GsaProperty2dGoo.NickName, - GsaProperty2dGoo.Description + " with applied changes.", GH_ParamAccess.item); - pManager.AddIntegerParameter("Prop2d Number", "ID", "2D Property Number", - GH_ParamAccess.item); - pManager.AddParameter(new GsaMaterialParameter()); - pManager.AddGenericParameter("Thickness [" + Length.GetAbbreviation(_lengthUnit) + "]", "Th", - "Get Property Thickness", GH_ParamAccess.item); - pManager.AddIntegerParameter("Axis", "Ax", "Get Axis: Global (0) or Topological (1)", - GH_ParamAccess.item); - pManager.AddTextParameter("Prop2d Name", "Na", "Name of 2D Proerty", GH_ParamAccess.item); - pManager.AddColourParameter("Prop2d Colour", "Co", "2D Property Colour", GH_ParamAccess.item); - pManager.AddTextParameter("Type", "Ty", "2D Property Type", GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var prop = new GsaProperty2d(); - - GsaProperty2dGoo prop2dGoo = null; - if (da.GetData(0, ref prop2dGoo)) { - prop = new GsaProperty2d(prop2dGoo.Value); - } - - if (prop != null) { - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - prop.Id = id; - } - } - - GsaMaterialGoo materialGoo = null; - if (da.GetData(2, ref materialGoo)) { - prop.Material = materialGoo.Value; - } - - if (Params.Input[3].SourceCount > 0) { - prop.Thickness = (Length)Input.UnitNumber(this, da, 3, _lengthUnit, true); - } - - var ghAxis = new GH_Integer(); - if (da.GetData(4, ref ghAxis)) { - if (GH_Convert.ToInt32(ghAxis, out int axis, GH_Conversion.Both)) { - prop.ApiProp2d.AxisProperty = axis; - } - } - - var ghName = new GH_String(); - if (da.GetData(5, ref ghName)) { - if (GH_Convert.ToString(ghName, out string name, GH_Conversion.Both)) { - prop.ApiProp2d.Name = name; - } - } - - var ghColour = new GH_Colour(); - if (da.GetData(6, ref ghColour)) { - if (GH_Convert.ToColor(ghColour, out Color col, GH_Conversion.Both)) { - prop.ApiProp2d.Colour = col; - } - } - - var ghType = new GH_ObjectWrapper(); - if (da.GetData(7, ref ghType)) { - if (GH_Convert.ToInt32(ghType, out int number, GH_Conversion.Both)) { - prop.ApiProp2d.Type = (Property2D_Type)number; - } else if (GH_Convert.ToString(ghType, out string type, GH_Conversion.Both)) { - prop.ApiProp2d.Type = GsaProperty2d.PropTypeFromString(type); - } - } - - int ax = (prop.ApiProp2d == null) ? 0 : prop.ApiProp2d.AxisProperty; - string nm = (prop.ApiProp2d == null) ? "--" : prop.ApiProp2d.Name; - ValueType colour = prop.ApiProp2d?.Colour; - - da.SetData(0, new GsaProperty2dGoo(prop)); - da.SetData(1, prop.Id); - da.SetData(2, new GsaMaterialGoo(prop.Material)); - da.SetData(3, - prop.ApiProp2d?.Description == string.Empty ? new GH_UnitNumber(Length.Zero) : - new GH_UnitNumber(prop.Thickness.ToUnit(_lengthUnit))); - da.SetData(4, ax); - da.SetData(5, nm); - da.SetData(6, colour); - - da.SetData(7, Mappings.prop2dTypeMapping.FirstOrDefault(x => x.Value == prop.ApiProp2d.Type).Key); - } else { - this.AddRuntimeError("Prop2d is Null"); - } - } - - private void Update(string unit) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), unit); - Message = unit; - ExpireSolution(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditSection2_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditSection2_OBSOLETE.cs deleted file mode 100644 index a2aa29656..000000000 --- a/GsaGH/Components/GraveyardComp/EditSection2_OBSOLETE.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System; -using System.Drawing; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; - -namespace GsaGH.Components { - /// - /// Component to edit a Section and ouput the information - /// - public class EditSection2_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("28dcadbd-4735-4110-8c30-931b37ec5f5a"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.EditSection; - - public EditSection2_OBSOLETE() : base("Edit Section", "SectionEdit", "Modify GSA Section", - CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaSectionParameter(), GsaSectionGoo.Name, GsaSectionGoo.NickName, - GsaSectionGoo.Description + " to get or set information for. Leave blank to create a new " - + GsaSectionGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Section Number", "ID", - "Set Section Number. If ID is set it will replace any existing 2D Property in the model", - GH_ParamAccess.item); - pManager.AddTextParameter("Section Profile", "Pf", - "Profile name following GSA naming convention (eg 'STD I 1000 500 15 25')", - GH_ParamAccess.item); - pManager.AddParameter(new GsaMaterialParameter(), GsaMaterialGoo.Name, - GsaMaterialGoo.NickName, "Set " + GsaMaterialGoo.Name, GH_ParamAccess.item); - pManager.AddParameter(new GsaSectionModifierParameter(), GsaSectionModifierGoo.Name, - GsaSectionModifierGoo.NickName, "Set " + GsaSectionModifierGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Section Pool", "Po", "Set Section pool", GH_ParamAccess.item); - pManager.AddTextParameter("Section Name", "Na", "Set Section name", GH_ParamAccess.item); - pManager.AddColourParameter("Section Colour", "Co", "Set Section colour", - GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaSectionParameter(), GsaSectionGoo.Name, GsaSectionGoo.NickName, - GsaSectionGoo.Description + " with applied changes.", GH_ParamAccess.item); - pManager.AddIntegerParameter("Section Number", "ID", - "Original Section number (ID) if the Section ever belonged to a GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Section Profile", "Pf", "Profile describtion", - GH_ParamAccess.item); - pManager.AddParameter(new GsaMaterialParameter(), GsaMaterialGoo.Name, - GsaMaterialGoo.NickName, "Get " + GsaMaterialGoo.Name, GH_ParamAccess.item); - pManager.AddParameter(new GsaSectionModifierParameter(), GsaSectionModifierGoo.Name, - GsaSectionModifierGoo.NickName, "Set " + GsaSectionModifierGoo.Name, GH_ParamAccess.item); - pManager.AddIntegerParameter("Section Pool", "Po", "Get Section pool", GH_ParamAccess.item); - pManager.AddTextParameter("Section Name", "Na", "Get Section name", GH_ParamAccess.item); - pManager.AddColourParameter("Section Colour", "Co", "Get Section colour", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var section = new GsaSection(); - - GsaSectionGoo sectionGoo = null; - if (da.GetData(0, ref sectionGoo)) { - section = new GsaSection(sectionGoo.Value); - } - - if (section != null) { - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - section.Id = id; - } - } - - string profile = string.Empty; - if (da.GetData(2, ref profile)) { - section.ApiSection.Profile = profile; - } - - GsaMaterialGoo materialGoo = null; - if (da.GetData(3, ref materialGoo)) { - section.Material = materialGoo.Value; - } - - GsaSectionModifierGoo modifierGoo = null; - if (da.GetData(4, ref modifierGoo)) { - section.Modifier = modifierGoo.Value; - } - - int pool = 0; - if (da.GetData(5, ref pool)) { - section.ApiSection.Pool = pool; - } - - var ghString = new GH_String(); - if (da.GetData(6, ref ghString)) { - if (GH_Convert.ToString(ghString, out string name, GH_Conversion.Both)) { - section.ApiSection.Name = name; - } - } - - var ghColour = new GH_Colour(); - if (da.GetData(7, ref ghColour)) { - if (GH_Convert.ToColor(ghColour, out Color col, GH_Conversion.Both)) { - section.ApiSection.Colour = col; - } - } - - string prof = (section.ApiSection == null) ? "--" : section.ApiSection.Profile; - int poo = (section.ApiSection == null) ? 0 : section.ApiSection.Pool; - string nm = (section.ApiSection == null) ? "--" : section.ApiSection.Name; - ValueType colour = section.ApiSection?.Colour; - - da.SetData(0, new GsaSectionGoo(section)); - da.SetData(1, section.Id); - da.SetData(2, prof); - da.SetData(3, new GsaMaterialGoo(section.Material)); - da.SetData(4, new GsaSectionModifierGoo(section.Modifier)); - da.SetData(5, poo); - da.SetData(6, nm); - da.SetData(7, colour); - } else { - this.AddRuntimeError("Section is Null"); - } - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditSectionModifier2_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditSectionModifier2_OBSOLETE.cs deleted file mode 100644 index 4ba665ad0..000000000 --- a/GsaGH/Components/GraveyardComp/EditSectionModifier2_OBSOLETE.cs +++ /dev/null @@ -1,453 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to edit a Material and ouput the information - /// - public class EditSectionModifier2_OBSOLETE : GH_OasysComponent, IGH_VariableParameterComponent { - public override Guid ComponentGuid => new Guid("db2046cc-236d-44a5-aa88-1394dbc4558f"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.GetSectionModifier; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitSection; - private LinearDensityUnit _linearDensityUnit = DefaultUnits.LinearDensityUnit; - - public EditSectionModifier2_OBSOLETE() : base("Edit Section Modifier", "ModifierEdit", - "Modify GSA Section Modifier", CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - - var lengthUnitsMenu = new ToolStripMenuItem("Length") { - Enabled = true, - }; - foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => UpdateLength(unit)) { - Checked = unit == Length.GetAbbreviation(_lengthUnit), - Enabled = true, - }; - lengthUnitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - var densityUnitsMenu = new ToolStripMenuItem("Density") { - Enabled = true, - }; - foreach (string unit in - UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.LinearDensity)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => UpdateDensity(unit)) { - Checked = unit == LinearDensity.GetAbbreviation(_linearDensityUnit), - Enabled = true, - }; - densityUnitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - var unitsMenu = new ToolStripMenuItem("Select Units", Resources.ModelUnits); - unitsMenu.DropDownItems.AddRange(new ToolStripItem[] { - lengthUnitsMenu, - densityUnitsMenu, - }); - unitsMenu.ImageScaling = ToolStripItemImageScaling.SizeToFit; - - menu.Items.Add(unitsMenu); - - Menu_AppendSeparator(menu); - } - - bool IGH_VariableParameterComponent.CanInsertParameter(GH_ParameterSide side, int index) { - return false; - } - - bool IGH_VariableParameterComponent.CanRemoveParameter(GH_ParameterSide side, int index) { - return false; - } - - IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index) { - return null; - } - - bool IGH_VariableParameterComponent.DestroyParameter(GH_ParameterSide side, int index) { - return false; - } - - public override bool Read(GH_IReader reader) { - _lengthUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("LengthUnit")); - _linearDensityUnit = (LinearDensityUnit)UnitsHelper.Parse(typeof(LinearDensityUnit), - reader.GetString("DensityUnit")); - return base.Read(reader); - } - - public virtual void VariableParameterMaintenance() { - string unit = Length.GetAbbreviation(_lengthUnit); - string volUnit - = VolumePerLength.GetAbbreviation(UnitsHelper.GetVolumePerLengthUnit(_lengthUnit)); - Params.Output[1].Name = "Area Modifier [" + unit + "\u00B2]"; - Params.Output[2].Name = "I11 Modifier [" + unit + "\u2074]"; - Params.Output[3].Name = "I22 Modifier [" + unit + "\u2074]"; - Params.Output[7].Name = "Volume Modifier [" + volUnit + "]"; - string unitAbbreviation = LinearDensity.GetAbbreviation(_linearDensityUnit); - Params.Output[8].Name = "Additional Mass [" + unitAbbreviation + "]"; - } - - public override bool Write(GH_IWriter writer) { - writer.SetString("LengthUnit", _lengthUnit.ToString()); - writer.SetString("DensityUnit", _linearDensityUnit.ToString()); - return base.Write(writer); - } - - protected override void BeforeSolveInstance() { - UpdateMessage(); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaSectionModifierParameter(), GsaSectionModifierGoo.Name, - GsaSectionModifierGoo.NickName, - GsaSectionModifierGoo.Description - + " to get or set information for. Leave blank to create a new " - + GsaSectionModifierGoo.Name, GH_ParamAccess.item); - - pManager.AddGenericParameter("Area Modifier", "A", - "Modify the effective Area using either:" + Environment.NewLine - + "BY using a Percentage UnitNumber (tweaking the existing value BY this percentage)" - + Environment.NewLine + "TO using an Area UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("I11 Modifier", "I11", - "Modify the effective Iyy/Iuu using either:" + Environment.NewLine - + "BY using a Percentage UnitNumber (tweaking the existing value BY this percentage)" - + Environment.NewLine + "TO using an AreaMomentOfInertia UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("I22 Modifier", "I22", - "Modify the effective Izz/Ivv using either:" + Environment.NewLine - + "BY using a Percentage UnitNumber (tweaking the existing value BY this percentage)" - + Environment.NewLine + "TO using an AreaMomentOfInertia UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("J Modifier", "J", - "Modify the effective J using either:" + Environment.NewLine - + "BY using a Percentage UnitNumber (tweaking the existing value BY this percentage)" - + Environment.NewLine + "TO using an AreaMomentOfInertia UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("K11 Modifier", "K11", - "Modify the effective Kyy/Kuu using either:" + Environment.NewLine - + "BY using a Percentage UnitNumber (tweaking the existing value BY this percentage)" - + Environment.NewLine + "TO using a DecimalFraction UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("K22 Modifier", "K22", - "Modify the effective Kzz/Kvv using either:" + Environment.NewLine - + "BY using a Percentage UnitNumber (tweaking the existing value BY this percentage)" - + Environment.NewLine + "TO using a DecimalFraction UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("Volume Modifier", "V", - "Modify the effective Volume/Length using either:" + Environment.NewLine - + "BY using a Percentage UnitNumber (tweaking the existing value BY this percentage)" - + Environment.NewLine + "TO using a VolumePerLength UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("Additional Mass", "+kg", - "Additional mass per unit length using a LinearDensity UnitNumber", GH_ParamAccess.item); - - pManager.AddBooleanParameter("Principal Bending Axis", "Ax", - "[Optional] Set to 'true' to use Principal (u,v) Axis for Bending. If false (and by default), Local (y,z) Axis will be used", - GH_ParamAccess.item); - - pManager.AddBooleanParameter("Reference Point Centroid", "Ref", - "[Optional] Set to 'true' to use the Centroid as Analysis Reference Point. If false (and by default), the specified point will be used", - GH_ParamAccess.item); - - pManager.AddIntegerParameter("Stress Option Type", "Str", - "Set the Stress Option Type. Accepted inputs are:" + Environment.NewLine - + "0: No calculation" + Environment.NewLine + "1: Use modified section properties" - + Environment.NewLine + "2: Use unmodified section properties", GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaSectionModifierParameter(), GsaSectionModifierGoo.Name, - GsaSectionModifierGoo.NickName, - GsaSectionModifierGoo.Description + " with applied changes.", GH_ParamAccess.item); - - pManager.AddGenericParameter("Area Modifier", "A", - "Modified effective Area in either:" + Environment.NewLine + "BY as a Percentage UnitNumber" - + Environment.NewLine + "TO as an Area UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("I11 Modifier", "I11", - "Modify the effective Iyy/Iuu in either:" + Environment.NewLine - + "BY as a Percentage UnitNumber" + Environment.NewLine - + "TO as an AreaMomentOfInertia UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("I22 Modifier", "I22", - "Modify the effective Izz/Ivv in either:" + Environment.NewLine - + "BY as a Percentage UnitNumber" + Environment.NewLine - + "TO as an AreaMomentOfInertia UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("J Modifier", "J", - "Modify the effective J in either:" + Environment.NewLine + "BY as a Percentage UnitNumber" - + Environment.NewLine + "TO as an AreaMomentOfInertia UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("K11 Modifier", "K11", - "Modify the effective Kyy/Kuu in either:" + Environment.NewLine - + "BY as a Percentage UnitNumber" + Environment.NewLine - + "TO as a DecimalFraction UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("K22 Modifier", "K22", - "Modify the effective Kzz/Kvv in either:" + Environment.NewLine - + "BY as a Percentage UnitNumber" + Environment.NewLine - + "TO as a DecimalFraction UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("Volume Modifier", "V", - "Modify the effective Volume/Length in either:" + Environment.NewLine - + "BY as a Percentage UnitNumber" + Environment.NewLine - + "TO as a VolumePerLength UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("Additional Mass", "+kg", "Additional mass per unit length", - GH_ParamAccess.item); - - pManager.AddBooleanParameter("Principal Bending Axis", "Ax", - "If 'true' GSA will use Principal (u,v) Axis for Bending. If false, Local (y,z) Axis will be used", - GH_ParamAccess.item); - - pManager.AddBooleanParameter("Reference Point Centroid", "Ref", - "If 'true' GSA will use the Centroid as Analysis Reference Point. If false, the specified point will be used", - GH_ParamAccess.item); - - pManager.AddGenericParameter("Stress Option Type", "Str", - "Get the Stress Option Type:" + Environment.NewLine + "0: No Calculation" - + Environment.NewLine + "1: Use Modified section properties" + Environment.NewLine - + "2: Use Unmodified section properties", GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var modifier = new GsaSectionModifier(); - - GsaSectionModifierGoo modifierGoo = null; - if (da.GetData(0, ref modifierGoo)) { - modifier = new GsaSectionModifier(modifierGoo.Value); - } - - if (Params.Input[1].SourceCount > 0) { - var ghTyp = new GH_ObjectWrapper(); - da.GetData(1, ref ghTyp); - if (GH_Convert.ToString(ghTyp.Value, out string txt, GH_Conversion.Both)) { - if (Area.TryParse(txt, out Area res)) { - modifier.AreaModifier = res; - } else { - try { - modifier.AreaModifier - = Input.UnitNumberOrDoubleAsRatioToPercentage(this, da, 1, true).Value; - } catch (Exception e) { - this.AddRuntimeError(e.Message); - return; - } - } - } - } - - if (Params.Input[2].SourceCount > 0) { - var ghTyp = new GH_ObjectWrapper(); - da.GetData(2, ref ghTyp); - if (GH_Convert.ToString(ghTyp.Value, out string txt, GH_Conversion.Both)) { - if (AreaMomentOfInertia.TryParse(txt, out AreaMomentOfInertia res)) { - modifier.I11Modifier = res; - } else { - try { - modifier.I11Modifier = Input.UnitNumberOrDoubleAsRatioToPercentage(this, da, 2, true) - .Value; - } catch (Exception e) { - this.AddRuntimeError(e.Message); - return; - } - } - } - } - - if (Params.Input[3].SourceCount > 0) { - var ghTyp = new GH_ObjectWrapper(); - da.GetData(3, ref ghTyp); - if (GH_Convert.ToString(ghTyp.Value, out string txt, GH_Conversion.Both)) { - if (AreaMomentOfInertia.TryParse(txt, out AreaMomentOfInertia res)) { - modifier.I22Modifier = res; - } else { - try { - modifier.I22Modifier = Input.UnitNumberOrDoubleAsRatioToPercentage(this, da, 3, true) - .Value; - } catch (Exception e) { - this.AddRuntimeError(e.Message); - return; - } - } - } - } - - if (Params.Input[4].SourceCount > 0) { - var ghTyp = new GH_ObjectWrapper(); - da.GetData(4, ref ghTyp); - if (GH_Convert.ToString(ghTyp.Value, out string txt, GH_Conversion.Both)) { - if (AreaMomentOfInertia.TryParse(txt, out AreaMomentOfInertia res)) { - modifier.JModifier = res; - } else { - try { - modifier.JModifier = Input.UnitNumberOrDoubleAsRatioToPercentage(this, da, 4, true) - .Value; - } catch (Exception e) { - this.AddRuntimeError(e.Message); - return; - } - } - } - } - - if (Params.Input[5].SourceCount > 0) { - modifier.K11Modifier = Input.RatioInDecimalFractionToPercentage(this, da, 5); - } - - if (Params.Input[6].SourceCount > 0) { - modifier.K22Modifier = Input.RatioInDecimalFractionToPercentage(this, da, 6); - } - - if (Params.Input[7].SourceCount > 0) { - var ghTyp = new GH_ObjectWrapper(); - da.GetData(7, ref ghTyp); - if (GH_Convert.ToString(ghTyp.Value, out string txt, GH_Conversion.Both)) { - if (VolumePerLength.TryParse(txt, out VolumePerLength res)) { - modifier.VolumeModifier = res; - } else { - try { - modifier.VolumeModifier = Input - .UnitNumberOrDoubleAsRatioToPercentage(this, da, 7, true).Value; - } catch (Exception e) { - this.AddRuntimeError(e.Message); - return; - } - } - } - } - - if (Params.Input[8].SourceCount > 0) { - var ghTyp = new GH_ObjectWrapper(); - if (da.GetData(8, ref ghTyp)) { - if (ghTyp.Value is GH_UnitNumber unitNumber) { - if (unitNumber.Value.QuantityInfo.UnitType != typeof(LinearDensityUnit)) { - this.AddRuntimeError("Error in " + Params.Input[8].NickName - + " input: Wrong unit type" + Environment.NewLine + "Unit type is " - + unitNumber.Value.QuantityInfo.Name + " but must be LinearDensity"); - return; - } - - modifier.AdditionalMass = (LinearDensity)unitNumber.Value; - } else if (GH_Convert.ToDouble(ghTyp.Value, out double val, GH_Conversion.Both)) { - modifier.AdditionalMass = new LinearDensity(val, _linearDensityUnit); - } else if (GH_Convert.ToString(ghTyp.Value, out string txt, GH_Conversion.Both)) { - if (LinearDensity.TryParse(txt, out LinearDensity res)) { - modifier.AdditionalMass = res; - } else { - this.AddRuntimeError("Unable to convert " + Params.Input[8].NickName - + " to LinearDensity"); - } - } else { - this.AddRuntimeError("Unable to convert " + Params.Input[8].NickName - + " to UnitNumber"); - return; - } - } - } - - bool ax = false; - if (da.GetData(9, ref ax)) { - modifier.IsBendingAxesPrincipal = ax; - } - - bool pt = false; - if (da.GetData(10, ref pt)) { - modifier.IsReferencePointCentroid = pt; - } - - var obj = new GH_ObjectWrapper(); - if (da.GetData(11, ref obj)) { - if (GH_Convert.ToInt32(obj.Value, out int stress, GH_Conversion.Both)) { - modifier.StressOption = (StressOptionType)stress; - } - } - - da.SetData(0, new GsaSectionModifierGoo(modifier)); - da.SetData(1, - modifier.ApiSectionModifier.AreaModifier.Option == SectionModifierOptionType.BY ? - new GH_UnitNumber(modifier.AreaModifier) : - new GH_UnitNumber(modifier.AreaModifier.ToUnit(UnitsHelper.GetAreaUnit(_lengthUnit)))); - - da.SetData(2, - modifier.ApiSectionModifier.I11Modifier.Option == SectionModifierOptionType.BY ? - new GH_UnitNumber(modifier.I11Modifier) : new GH_UnitNumber( - modifier.I11Modifier.ToUnit(UnitsHelper.GetAreaMomentOfInertiaUnit(_lengthUnit)))); - - da.SetData(3, - modifier.ApiSectionModifier.I22Modifier.Option == SectionModifierOptionType.BY ? - new GH_UnitNumber(modifier.I22Modifier) : new GH_UnitNumber( - modifier.I22Modifier.ToUnit(UnitsHelper.GetAreaMomentOfInertiaUnit(_lengthUnit)))); - - da.SetData(4, - modifier.ApiSectionModifier.JModifier.Option == SectionModifierOptionType.BY ? - new GH_UnitNumber(modifier.JModifier) : new GH_UnitNumber( - modifier.JModifier.ToUnit(UnitsHelper.GetAreaMomentOfInertiaUnit(_lengthUnit)))); - - da.SetData(5, new GH_UnitNumber(modifier.K11Modifier)); - da.SetData(6, new GH_UnitNumber(modifier.K22Modifier)); - - da.SetData(7, - modifier.ApiSectionModifier.VolumeModifier.Option == SectionModifierOptionType.BY ? - new GH_UnitNumber(modifier.VolumeModifier) : new GH_UnitNumber( - modifier.VolumeModifier.ToUnit(UnitsHelper.GetVolumePerLengthUnit(_lengthUnit)))); - - da.SetData(8, new GH_UnitNumber(modifier.AdditionalMass.ToUnit(_linearDensityUnit))); - - da.SetData(9, modifier.IsBendingAxesPrincipal); - da.SetData(10, modifier.IsReferencePointCentroid); - da.SetData(11, (int)modifier.StressOption); - } - - private void Update() { - UpdateMessage(); - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - ExpireSolution(true); - } - - private void UpdateDensity(string unit) { - _linearDensityUnit = (LinearDensityUnit)UnitsHelper.Parse(typeof(LinearDensityUnit), unit); - Update(); - } - - private void UpdateLength(string unit) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), unit); - Update(); - } - - private void UpdateMessage() { - Message = Length.GetAbbreviation(_lengthUnit) + ", " - + LinearDensity.GetAbbreviation(_linearDensityUnit); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditSectionModifier_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditSectionModifier_OBSOLETE.cs deleted file mode 100644 index 1aa9a1e85..000000000 --- a/GsaGH/Components/GraveyardComp/EditSectionModifier_OBSOLETE.cs +++ /dev/null @@ -1,504 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Parameters; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to edit a Material and ouput the information - /// - // ReSharper disable once InconsistentNaming - public class EditSectionModifier_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("7c78c61b-f01c-4a0e-9399-712fc853e23b"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.GetSectionModifier; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitSection; - private LinearDensityUnit _linearDensityUnit = DefaultUnits.LinearDensityUnit; - - public EditSectionModifier_OBSOLETE() : base("Edit Section Modifier", "ModifierEdit", - "Modify GSA Section Modifier", CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - - var lengthUnitsMenu = new ToolStripMenuItem("Length") { - Enabled = true, - }; - foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => UpdateLength(unit)) { - Checked = unit == Length.GetAbbreviation(_lengthUnit), - Enabled = true, - }; - lengthUnitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - var densityUnitsMenu = new ToolStripMenuItem("Density") { - Enabled = true, - }; - foreach (string unit in - UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.LinearDensity)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => UpdateDensity(unit)) { - Checked = unit == LinearDensity.GetAbbreviation(_linearDensityUnit), - Enabled = true, - }; - densityUnitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - var unitsMenu = new ToolStripMenuItem("Select Units", Resources.ModelUnits); - unitsMenu.DropDownItems.AddRange(new ToolStripItem[] { - lengthUnitsMenu, - densityUnitsMenu, - }); - unitsMenu.ImageScaling = ToolStripItemImageScaling.SizeToFit; - - menu.Items.Add(unitsMenu); - - Menu_AppendSeparator(menu); - } - - public override bool Read(GH_IReader reader) { - if (reader.ItemExists("LengthUnit")) { - _lengthUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("LengthUnit")); - _linearDensityUnit = LinearDensity.ParseUnit(reader.GetString("DensityUnit")); - - if (reader.ItemExists("dropdown")) { - return base.Read(reader); - } - - GH_IReader attributes = reader.FindChunk("Attributes"); - Attributes.Bounds = (RectangleF)attributes.Items[0].InternalData; - Attributes.Pivot = (PointF)attributes.Items[1].InternalData; - - int num = Params.Input.Count - 1; - bool flag = true; - for (int i = 0; i <= num; i++) { - GH_IReader ghIReader = reader.FindChunk("param_input", i); - if (ghIReader == null) { - continue; - } - - GH_ParamAccess access = Params.Input[i].Access; - flag &= Params.Input[i].Read(ghIReader); - if (!(Params.Input[i] is Param_ScriptVariable)) { - Params.Input[i].Access = access; - } - } - - int num2 = Params.Output.Count - 1; - for (int j = 0; j <= num2; j++) { - GH_IReader ghIReader = reader.FindChunk("param_output", j); - if (ghIReader == null) { - reader.AddMessage("Output parameter chunk is missing. Archive is corrupt.", - GH_Message_Type.error); - continue; - } - - GH_ParamAccess access2 = Params.Output[j].Access; - flag &= Params.Output[j].Read(ghIReader); - Params.Output[j].Access = access2; - } - - return true; - } else { - _lengthUnit = DefaultUnits.LengthUnitSection; - _linearDensityUnit = DefaultUnits.LinearDensityUnit; - return base.Read(reader); - } - } - - public override bool Write(GH_IWriter writer) { - writer.SetString("LengthUnit", _lengthUnit.ToString()); - writer.SetString("DensityUnit", _linearDensityUnit.ToString()); - return base.Write(writer); - } - - protected override void BeforeSolveInstance() { - UpdateMessage(); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaSectionModifierParameter(), GsaSectionModifierGoo.Name, - GsaSectionModifierGoo.NickName, - GsaSectionModifierGoo.Description - + " to get or set information for. Leave blank to create a new " - + GsaSectionModifierGoo.Name, GH_ParamAccess.item); - - pManager.AddGenericParameter("Area Modifier", "A", - "Modify the effective Area using either:" + Environment.NewLine - + "BY using a Percentage UnitNumber (tweaking the existing value BY this percentage)" - + Environment.NewLine + "TO using an Area UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("I11 Modifier", "I11", - "Modify the effective Iyy/Iuu using either:" + Environment.NewLine - + "BY using a Percentage UnitNumber (tweaking the existing value BY this percentage)" - + Environment.NewLine + "TO using an AreaMomentOfInertia UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("I22 Modifier", "I22", - "Modify the effective Izz/Ivv using either:" + Environment.NewLine - + "BY using a Percentage UnitNumber (tweaking the existing value BY this percentage)" - + Environment.NewLine + "TO using an AreaMomentOfInertia UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("J Modifier", "J", - "Modify the effective J using either:" + Environment.NewLine - + "BY using a Percentage UnitNumber (tweaking the existing value BY this percentage)" - + Environment.NewLine + "TO using an AreaMomentOfInertia UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("K11 Modifier", "K11", - "Modify the effective Kyy/Kuu using either:" + Environment.NewLine - + "BY using a Percentage UnitNumber (tweaking the existing value BY this percentage)" - + Environment.NewLine + "TO using a DecimalFraction UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("K22 Modifier", "K22", - "Modify the effective Kzz/Kvv using either:" + Environment.NewLine - + "BY using a Percentage UnitNumber (tweaking the existing value BY this percentage)" - + Environment.NewLine + "TO using a DecimalFraction UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("Volume Modifier", "V", - "Modify the effective Volume/Length using either:" + Environment.NewLine - + "BY using a Percentage UnitNumber (tweaking the existing value BY this percentage)" - + Environment.NewLine + "TO using a VolumePerLength UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("Additional Mass", "+kg", - "Additional mass per unit length using a LinearDensity UnitNumber", GH_ParamAccess.item); - - pManager.AddBooleanParameter("Principal Bending Axis", "Ax", - "[Optional] Set to 'true' to use Principal (u,v) Axis for Bending. If false (and by default), Local (y,z) Axis will be used", - GH_ParamAccess.item); - - pManager.AddBooleanParameter("Reference Point Centroid", "Ref", - "[Optional] Set to 'true' to use the Centroid as Analysis Reference Point. If false (and by default), the specified point will be used", - GH_ParamAccess.item); - - pManager.AddIntegerParameter("Stress Option Type", "Str", - "Set the Stress Option Type. Accepted inputs are:" + Environment.NewLine - + "0: No calculation" + Environment.NewLine + "1: Use modified section properties" - + Environment.NewLine + "2: Use unmodified section properties", GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaSectionModifierParameter(), GsaSectionModifierGoo.Name, - GsaSectionModifierGoo.NickName, - GsaSectionModifierGoo.Description + " with applied changes.", GH_ParamAccess.item); - - pManager.AddGenericParameter("Area Modifier", "A", - "Modified effective Area in either:" + Environment.NewLine + "BY as a Percentage UnitNumber" - + Environment.NewLine + "TO as an Area UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("I11 Modifier", "I11", - "Modify the effective Iyy/Iuu in either:" + Environment.NewLine - + "BY as a Percentage UnitNumber" + Environment.NewLine - + "TO as an AreaMomentOfInertia UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("I22 Modifier", "I22", - "Modify the effective Izz/Ivv in either:" + Environment.NewLine - + "BY as a Percentage UnitNumber" + Environment.NewLine - + "TO as an AreaMomentOfInertia UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("J Modifier", "J", - "Modify the effective J in either:" + Environment.NewLine + "BY as a Percentage UnitNumber" - + Environment.NewLine + "TO as an AreaMomentOfInertia UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("K11 Modifier", "K11", - "Modify the effective Kyy/Kuu in either:" + Environment.NewLine - + "BY as a Percentage UnitNumber" + Environment.NewLine - + "TO as a DecimalFraction UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("K22 Modifier", "K22", - "Modify the effective Kzz/Kvv in either:" + Environment.NewLine - + "BY as a Percentage UnitNumber" + Environment.NewLine - + "TO as a DecimalFraction UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("Volume Modifier", "V", - "Modify the effective Volume/Length in either:" + Environment.NewLine - + "BY as a Percentage UnitNumber" + Environment.NewLine - + "TO as a VolumePerLength UnitNumber", GH_ParamAccess.item); - - pManager.AddGenericParameter("Additional Mass", "+kg", "Additional mass per unit length", - GH_ParamAccess.item); - - pManager.AddBooleanParameter("Principal Bending Axis", "Ax", - "If 'true' GSA will use Principal (u,v) Axis for Bending. If false, Local (y,z) Axis will be used", - GH_ParamAccess.item); - - pManager.AddBooleanParameter("Reference Point Centroid", "Ref", - "If 'true' GSA will use the Centroid as Analysis Reference Point. If false, the specified point will be used", - GH_ParamAccess.item); - - pManager.AddGenericParameter("Stress Option Type", "Str", - "Get the Stress Option Type:" + Environment.NewLine + "0: No Calculation" - + Environment.NewLine + "1: Use Modified section properties" + Environment.NewLine - + "2: Use Unmodified section properties", GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var modifier = new GsaSectionModifier(); - - GsaSectionModifierGoo modifierGoo = null; - if (da.GetData(0, ref modifierGoo)) { - modifier = new GsaSectionModifier(modifierGoo.Value); - } - - if (Params.Input[1].SourceCount > 0) { - var ghTyp = new GH_ObjectWrapper(); - da.GetData(1, ref ghTyp); - if (GH_Convert.ToString(ghTyp.Value, out string txt, GH_Conversion.Both)) { - if (Area.TryParse(txt, out Area res)) { - modifier.AreaModifier = res; - } else { - try { - modifier.AreaModifier = Input.UnitNumberOrDoubleAsRatioToPercentage(this, da, 1, true) - .Value; - } catch (Exception e) { - this.AddRuntimeError(e.Message); - return; - } - } - } - } - - if (Params.Input[2].SourceCount > 0) { - var ghTyp = new GH_ObjectWrapper(); - da.GetData(2, ref ghTyp); - if (GH_Convert.ToString(ghTyp.Value, out string txt, GH_Conversion.Both)) { - if (AreaMomentOfInertia.TryParse(txt, out AreaMomentOfInertia res)) { - modifier.I11Modifier = res; - } else { - try { - modifier.I11Modifier = Input.UnitNumberOrDoubleAsRatioToPercentage(this, da, 2, true) - .Value; - } catch (Exception e) { - this.AddRuntimeError(e.Message); - return; - } - } - } - } - - if (Params.Input[3].SourceCount > 0) { - var ghTyp = new GH_ObjectWrapper(); - da.GetData(3, ref ghTyp); - if (GH_Convert.ToString(ghTyp.Value, out string txt, GH_Conversion.Both)) { - if (AreaMomentOfInertia.TryParse(txt, out AreaMomentOfInertia res)) { - modifier.I22Modifier = res; - } else { - try { - modifier.I22Modifier = Input.UnitNumberOrDoubleAsRatioToPercentage(this, da, 3, true) - .Value; - } catch (Exception e) { - this.AddRuntimeError(e.Message); - return; - } - } - } - } - - if (Params.Input[4].SourceCount > 0) { - var ghTyp = new GH_ObjectWrapper(); - da.GetData(4, ref ghTyp); - if (GH_Convert.ToString(ghTyp.Value, out string txt, GH_Conversion.Both)) { - if (AreaMomentOfInertia.TryParse(txt, out AreaMomentOfInertia res)) { - modifier.JModifier = res; - } else { - try { - modifier.JModifier = Input.UnitNumberOrDoubleAsRatioToPercentage(this, da, 4, true) - .Value; - } catch (Exception e) { - this.AddRuntimeError(e.Message); - return; - } - } - } - } - - if (Params.Input[5].SourceCount > 0) { - modifier.K11Modifier = Input.RatioInDecimalFractionToPercentage(this, da, 5); - } - - if (Params.Input[6].SourceCount > 0) { - modifier.K22Modifier = Input.RatioInDecimalFractionToPercentage(this, da, 6); - } - - if (Params.Input[7].SourceCount > 0) { - var ghTyp = new GH_ObjectWrapper(); - da.GetData(7, ref ghTyp); - if (GH_Convert.ToString(ghTyp.Value, out string txt, GH_Conversion.Both)) { - if (VolumePerLength.TryParse(txt, out VolumePerLength res)) { - modifier.VolumeModifier = res; - } else { - try { - modifier.VolumeModifier = Input - .UnitNumberOrDoubleAsRatioToPercentage(this, da, 7, true).Value; - } catch (Exception e) { - this.AddRuntimeError(e.Message); - return; - } - } - } - } - - if (Params.Input[8].SourceCount > 0) { - var ghTyp = new GH_ObjectWrapper(); - if (da.GetData(8, ref ghTyp)) { - if (ghTyp.Value is GH_UnitNumber unitNumber) { - if (unitNumber.Value.QuantityInfo.UnitType != typeof(LinearDensityUnit)) { - this.AddRuntimeError("Error in " + Params.Input[8].NickName - + " input: Wrong unit type" + Environment.NewLine + "Unit type is " - + unitNumber.Value.QuantityInfo.Name + " but must be LinearDensity"); - return; - } - - modifier.AdditionalMass = (LinearDensity)unitNumber.Value; - } else if (GH_Convert.ToString(ghTyp.Value, out string txt, GH_Conversion.Both)) { - if (LinearDensity.TryParse(txt, out LinearDensity res)) { - modifier.AdditionalMass = res; - } else { - this.AddRuntimeError("Unable to convert " + Params.Input[8].NickName - + " to LinearDensity"); - } - } else if (GH_Convert.ToDouble(ghTyp.Value, out double val, GH_Conversion.Both)) { - modifier.AdditionalMass = new LinearDensity(val, _linearDensityUnit); - } else { - this.AddRuntimeError("Unable to convert " + Params.Input[8].NickName - + " to UnitNumber"); - return; - } - } - } - - bool ax = false; - if (da.GetData(9, ref ax)) { - modifier.IsBendingAxesPrincipal = ax; - } - - bool pt = false; - if (da.GetData(10, ref pt)) { - modifier.IsReferencePointCentroid = pt; - } - - var obj = new GH_ObjectWrapper(); - if (da.GetData(11, ref obj)) { - if (GH_Convert.ToInt32(obj, out int stress, GH_Conversion.Both)) { - switch (stress) { - case 0: - modifier.StressOption = StressOptionType.NoCalculation; - break; - - case 1: - modifier.StressOption = StressOptionType.UseModified; - break; - - case 2: - modifier.StressOption = StressOptionType.UseUnmodified; - break; - - default: - this.AddRuntimeError("Error in " + Params.Input[11].NickName - + " input: Must be either 0, 1 or 2 but is " + stress); - return; - } - } else if (GH_Convert.ToString(obj, out string stressString, GH_Conversion.Both)) { - if (stressString.ToLower().Contains("no")) { - modifier.StressOption = StressOptionType.NoCalculation; - } else if (stressString.ToLower().Replace(" ", string.Empty).Contains("unmod")) { - modifier.StressOption = StressOptionType.UseUnmodified; - } else if (stressString.ToLower().Replace(" ", string.Empty).Contains("mod")) { - modifier.StressOption = StressOptionType.UseModified; - } else { - this.AddRuntimeError("Error in " + Params.Input[11].NickName - + " input: Must contain the one of the following phrases 'no', 'unmod' or 'mod' (case insensitive), but input is '" - + stress + "'"); - return; - } - } else { - this.AddRuntimeError("Error in " + Params.Input[11].NickName - + " input: Must be either 0, 1 or 2 or contain the one of the following phrases 'no', 'unmod' or mod' (case insensitive), but input is " - + stress + "'"); - return; - } - } - - da.SetData(0, new GsaSectionModifierGoo(modifier)); - da.SetData(1, - modifier.ApiSectionModifier.AreaModifier.Option == SectionModifierOptionType.BY ? - new GH_UnitNumber(modifier.AreaModifier) : - new GH_UnitNumber(modifier.AreaModifier.ToUnit(UnitsHelper.GetAreaUnit(_lengthUnit)))); - - da.SetData(2, - modifier.ApiSectionModifier.I11Modifier.Option == SectionModifierOptionType.BY ? - new GH_UnitNumber(modifier.I11Modifier) : new GH_UnitNumber( - modifier.I11Modifier.ToUnit(UnitsHelper.GetAreaMomentOfInertiaUnit(_lengthUnit)))); - - da.SetData(3, - modifier.ApiSectionModifier.I22Modifier.Option == SectionModifierOptionType.BY ? - new GH_UnitNumber(modifier.I22Modifier) : new GH_UnitNumber( - modifier.I22Modifier.ToUnit(UnitsHelper.GetAreaMomentOfInertiaUnit(_lengthUnit)))); - - da.SetData(4, - modifier.ApiSectionModifier.JModifier.Option == SectionModifierOptionType.BY ? - new GH_UnitNumber(modifier.JModifier) : new GH_UnitNumber( - modifier.JModifier.ToUnit(UnitsHelper.GetAreaMomentOfInertiaUnit(_lengthUnit)))); - - da.SetData(5, new GH_UnitNumber(modifier.K11Modifier)); - da.SetData(6, new GH_UnitNumber(modifier.K22Modifier)); - - da.SetData(7, - modifier.ApiSectionModifier.VolumeModifier.Option == SectionModifierOptionType.BY ? - new GH_UnitNumber(modifier.VolumeModifier) : new GH_UnitNumber( - modifier.VolumeModifier.ToUnit(UnitsHelper.GetVolumePerLengthUnit(_lengthUnit)))); - - da.SetData(8, new GH_UnitNumber(modifier.AdditionalMass.ToUnit(_linearDensityUnit))); - - da.SetData(9, modifier.IsBendingAxesPrincipal); - da.SetData(10, modifier.IsReferencePointCentroid); - da.SetData(11, (int)modifier.StressOption); - } - - private void Update() { - UpdateMessage(); - ExpireSolution(true); - } - - private void UpdateDensity(string unit) { - _linearDensityUnit = LinearDensity.ParseUnit(unit); - Update(); - } - - private void UpdateLength(string unit) { - _lengthUnit = Length.ParseUnit(unit); - Update(); - } - - private void UpdateMessage() { - Message = Length.GetAbbreviation(_lengthUnit) + ", " - + LinearDensity.GetAbbreviation(_linearDensityUnit); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/EditSection_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/EditSection_OBSOLETE.cs deleted file mode 100644 index 10955c866..000000000 --- a/GsaGH/Components/GraveyardComp/EditSection_OBSOLETE.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System; -using System.Drawing; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; - -namespace GsaGH.Components { - /// - /// Component to edit a Section and ouput the information - /// - // ReSharper disable once InconsistentNaming - public class EditSection_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("27dcadbd-4735-4110-8c30-931b37ec5f5a"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.EditSection; - - public EditSection_OBSOLETE() : base("Edit Section", "SectionEdit", "Modify GSA Section", - CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddGenericParameter("Section", "PB", "GSA Section to get or set information for", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Section Number", "ID", - "Set Section Number. If ID is set it will replace any existing 2D Property in the model", - GH_ParamAccess.item); - pManager.AddTextParameter("Section Profile", "Pf", - "Profile name following GSA naming convention (eg 'STD I 1000 500 15 25')", - GH_ParamAccess.item); - pManager.AddGenericParameter("Material", "Ma", - "Set GSA Material or reference existing material by ID", GH_ParamAccess.item); - pManager.AddIntegerParameter("Section Pool", "Po", "Set Section pool", GH_ParamAccess.item); - pManager.AddTextParameter("Section Name", "Na", "Set Section name", GH_ParamAccess.item); - pManager.AddColourParameter("Section Colour", "Co", "Set Section colour", - GH_ParamAccess.item); - - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddGenericParameter("Section", "PB", "GSA Section with changes", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Section Number", "ID", - "Original Section number (ID) if Section ever belonged to a GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Section Profile", "Pf", "Profile describtion", - GH_ParamAccess.item); - pManager.AddGenericParameter("Material", "Ma", "GSA Material", GH_ParamAccess.item); - pManager.AddIntegerParameter("Section Pool", "Po", "Section pool", GH_ParamAccess.item); - pManager.AddTextParameter("Section Name", "Na", "Section name", GH_ParamAccess.item); - pManager.AddColourParameter("Section Colour", "Co", "Section colour", GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var section = new GsaSection(); - - GsaSectionGoo sectionGoo = null; - if (da.GetData(0, ref sectionGoo)) { - section = new GsaSection(sectionGoo.Value); - } - - var ghId = new GH_Integer(); - if (da.GetData(1, ref ghId)) { - if (GH_Convert.ToInt32(ghId, out int id, GH_Conversion.Both)) { - section.Id = id; - } - } - - string profile = string.Empty; - if (da.GetData(2, ref profile)) { - section.ApiSection.Profile = profile; - } - - GsaMaterialGoo materialGoo = null; - if (da.GetData(3, ref materialGoo)) { - section.Material = materialGoo.Value; - } - - int pool = 0; - if (da.GetData(4, ref pool)) { - section.ApiSection.Pool = pool; - } - - var ghString = new GH_String(); - if (da.GetData(5, ref ghString)) { - if (GH_Convert.ToString(ghString, out string name, GH_Conversion.Both)) { - section.ApiSection.Name = name; - } - } - - var ghColour = new GH_Colour(); - if (da.GetData(6, ref ghColour)) { - if (GH_Convert.ToColor(ghColour, out Color col, GH_Conversion.Both)) { - section.ApiSection.Colour = col; - } - } - - string prof = (section.ApiSection == null) ? "--" : section.ApiSection.Profile; - int poo = (section.ApiSection == null) ? 0 : section.ApiSection.Pool; - string nm = (section.ApiSection == null) ? "--" : section.ApiSection.Name; - ValueType colour = section.ApiSection?.Colour; - - da.SetData(0, new GsaSectionGoo(section)); - da.SetData(1, section.Id); - da.SetData(2, prof); - da.SetData(3, new GsaMaterialGoo(section.Material)); - da.SetData(4, poo); - da.SetData(5, nm); - da.SetData(6, colour); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/Elem1dContourResults_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/Elem1dContourResults_OBSOLETE.cs deleted file mode 100644 index 6728e0a70..000000000 --- a/GsaGH/Components/GraveyardComp/Elem1dContourResults_OBSOLETE.cs +++ /dev/null @@ -1,893 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper; -using Grasshopper.GUI.Gradient; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Data; -using Grasshopper.Kernel.Special; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.Graphics; -using GsaGH.Helpers.GsaApi; -using GsaGH.Helpers.Import; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Parameters; -using OasysGH.UI; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using Rhino.Display; -using Rhino.Geometry; -using AngleUnit = OasysUnits.Units.AngleUnit; -using EnergyUnit = OasysUnits.Units.EnergyUnit; -using LengthUnit = OasysUnits.Units.LengthUnit; -using Line = Rhino.Geometry.Line; - -namespace GsaGH.Components { - /// - /// Component to get Element1D results - /// - // ReSharper disable once InconsistentNaming - public class Elem1dContourResults_OBSOLETE : GH_OasysDropDownComponent { - private enum DisplayValue { - X, - Y, - Z, - ResXyz, - Xx, - Yy, - Zz, - ResXxyyzz, - } - - private enum FoldMode { - Displacement, - Force, - StrainEnergy, - } - - public override Guid ComponentGuid => new Guid("dee5c513-197e-4659-998f-09225df9beaa"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Contour1dResults; - private readonly List _displacement = new List(new[] { - "Translation Ux", - "Translation Uy", - "Translation Uz", - "Resolved |U|", - "Rotation Rxx", - "Rotation Ryy", - "Rotation Rzz", - "Resolved |R|", - }); - private readonly List _force = new List(new[] { - "Axial Force Fx", - "Shear Force Fy", - "Shear Force Fz", - "Res. Shear |Fyz|", - "Torsion Mxx", - "Moment Myy", - "Moment Mzz", - "Res. Moment |Myz|", - }); - private readonly List _strainenergy = new List(new[] { - "Intermediate Pts", - "Average", - }); - private readonly List _type = new List(new[] { - "Displacement", - "Force", - "Strain Energy", - }); - private string _case = string.Empty; - private double _defScale = 250; - private DisplayValue _disp = DisplayValue.ResXyz; - private EnergyUnit _energyResultUnit = DefaultUnits.EnergyUnit; - private Bitmap _legend = new Bitmap(15, 120); - private List _legendValues; - private List _legendValuesPosY; - private LengthUnit _lengthResultUnit = DefaultUnits.LengthUnitResult; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - private double _maxValue = 1000; - private double _minValue; - private FoldMode _mode = FoldMode.Displacement; - private int _noDigits; - private string _resType; - private bool _showLegend = true; - private bool _slider = true; - - public Elem1dContourResults_OBSOLETE() : base("1D Contour Results", "ContourElem1d", - "Displays GSA 1D Element Results as Contour", CategoryName.Name(), SubCategoryName.Cat5()) { } - - public override void CreateAttributes() { - if (!_isInitialised) { - InitialiseDropdowns(); - } - - m_attributes = new DropDownSliderComponentAttributes(this, SetSelected, _dropDownItems, - _selectedItems, _slider, SetVal, SetMaxMin, _defScale, _maxValue, _minValue, _noDigits, - _spacerDescriptions); - } - - public override void DrawViewportWires(IGH_PreviewArgs args) { - base.DrawViewportWires(args); - if (!(_legendValues != null & _showLegend)) { - return; - } - - args.Display.DrawBitmap(new DisplayBitmap(_legend), args.Viewport.Bounds.Right - 110, 20); - for (int i = 0; i < _legendValues.Count; i++) { - args.Display.Draw2dText(_legendValues[i], Color.Black, - new Point2d(args.Viewport.Bounds.Right - 85, _legendValuesPosY[i]), false); - } - - args.Display.Draw2dText(_resType, Color.Black, - new Point2d(args.Viewport.Bounds.Right - 110, 7), false); - args.Display.Draw2dText(_case, Color.Black, - new Point2d(args.Viewport.Bounds.Right - 110, 145), false); - } - - public override bool Read(GH_IReader reader) { - _mode = (FoldMode)reader.GetInt32("Mode"); - _disp = (DisplayValue)reader.GetInt32("Display"); - _slider = reader.GetBoolean("slider"); - _showLegend = reader.GetBoolean("legend"); - _noDigits = reader.GetInt32("noDec"); - _maxValue = reader.GetDouble("valMax"); - _minValue = reader.GetDouble("valMin"); - _defScale = reader.GetDouble("val"); - return base.Read(reader); - } - - public void SetMaxMin(double max, double min) { - _maxValue = max; - _minValue = min; - } - - public override void SetSelected(int dropdownlistidd, int selectedidd) { - switch (dropdownlistidd) { - case 0: { - switch (selectedidd) { - case 0: { - if (_dropDownItems[1] != _displacement) { - _dropDownItems[1] = _displacement; - - _selectedItems[0] = _dropDownItems[0][0]; - _selectedItems[1] = _dropDownItems[1][3]; - - _disp = DisplayValue.ResXyz; - Mode1Clicked(); - } - - break; - } - case 1: { - if (_dropDownItems[1] != _force) { - _dropDownItems[1] = _force; - - _selectedItems[0] = _dropDownItems[0][1]; - _selectedItems[1] = _dropDownItems[1][5]; // set Myy as default - - _disp = DisplayValue.Yy; - Mode2Clicked(); - } - - break; - } - case 2: { - if (_dropDownItems[1] != _strainenergy) { - _dropDownItems[1] = _strainenergy; - - _selectedItems[0] = _dropDownItems[0][2]; - _selectedItems[1] = _dropDownItems[1][1]; // set average as default - - _disp = DisplayValue.Y; - Mode3Clicked(); - } - - break; - } - } - - break; - } - case 1: { - bool redraw = false; - - if (selectedidd < 4) { - if ((int)_disp > 3) // check if we are coming from other half of display modes - { - if (_mode == FoldMode.Displacement) { - redraw = true; - _slider = true; - } - } - } else { - if ((int)_disp < 4) // check if we are coming from other half of display modes - { - if (_mode == FoldMode.Displacement) { - redraw = true; - _slider = false; - } - } - } - - _disp = (DisplayValue)selectedidd; - - _selectedItems[1] = _dropDownItems[1][selectedidd]; - - if (redraw) { - ReDrawComponent(); - } - - break; - } - default: - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[2]); - break; - } - - base.UpdateUI(); - } - - public void SetVal(double value) { - _defScale = value; - } - - public override void VariableParameterMaintenance() { - if (_mode == FoldMode.Displacement) { - Params.Output[2].Name = (int)_disp < 4 ? - "Values [" + Length.GetAbbreviation(_lengthUnit) + "]" : "Values [rad]"; - } - - if (_mode != FoldMode.Force) { - return; - } - - Params.Output[2].Name = (int)_disp < 4 ? - "Legend Values [" + Force.GetAbbreviation(DefaultUnits.ForceUnit) + "]" : "Legend Values [" - + Moment.GetAbbreviation(DefaultUnits.MomentUnit) + "]"; - } - - public override bool Write(GH_IWriter writer) { - writer.SetInt32("Mode", (int)_mode); - writer.SetInt32("Display", (int)_disp); - writer.SetBoolean("slider", _slider); - writer.SetBoolean("legend", _showLegend); - writer.SetInt32("noDec", _noDigits); - writer.SetDouble("valMax", _maxValue); - writer.SetDouble("valMin", _minValue); - writer.SetDouble("val", _defScale); - return base.Write(writer); - } - - protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - Menu_AppendItem(menu, "Show Legend", ShowLegend, true, _showLegend); - - var gradient = new GH_GradientControl(); - gradient.CreateAttributes(); - var extract = new ToolStripMenuItem("Extract Default Gradient", gradient.Icon_24x24, - (s, e) => CreateGradient()); - menu.Items.Add(extract); - Menu_AppendSeparator(menu); - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Result Type", - "Component", - "Geometry Unit", - "Deform Shape", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(_type); - _selectedItems.Add(_dropDownItems[0][0]); - - _dropDownItems.Add(_displacement); - _selectedItems.Add(_dropDownItems[1][3]); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaResultParameter(), "Result", "Res", "GSA Result", - GH_ParamAccess.item); - pManager.AddTextParameter("Element filter list", "El", - "Filter import by list." + Environment.NewLine + "Element list should take the form:" - + Environment.NewLine - + " 1 11 to 20 step 2 P1 not (G1 to G6 step 3) P11 not (PA PB1 PS2 PM3 PA4 M1)" - + Environment.NewLine - + "Refer to GSA help file for definition of lists and full vocabulary.", - GH_ParamAccess.item, "All"); - pManager.AddIntegerParameter("Intermediate Points", "nP", - "Number of intermediate equidistant points (default 10)", GH_ParamAccess.item, 10); - pManager.AddColourParameter("Colour", "Co", - "[Optional] List of colours to override default colours" + Environment.NewLine - + "A new gradient will be created from the input list of colours", GH_ParamAccess.list); - pManager.AddNumberParameter("Scale", "x:X", "Scale the result display size", - GH_ParamAccess.item, 10); - pManager[1].Optional = true; - pManager[2].Optional = true; - pManager[3].Optional = true; - pManager[4].Optional = true; - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - IQuantity length = new Length(0, _lengthResultUnit); - string lengthunitAbbreviation = string.Concat(length.ToString().Where(char.IsLetter)); - - pManager.AddGenericParameter("Line", "L", "Contoured Line segments with result values", - GH_ParamAccess.tree); - pManager.AddGenericParameter("Colours", "LC", "Legend Colours", GH_ParamAccess.list); - pManager.AddGenericParameter("Values [" + lengthunitAbbreviation + "]", "LT", "Legend Values", - GH_ParamAccess.list); - } - - protected override void SolveInternal(IGH_DataAccess da) { - var result = new GsaResult(); - var ghTyp = new GH_ObjectWrapper(); - if (!da.GetData(0, ref ghTyp)) { - return; - } - - #region Inputs - - if (ghTyp.Value is GsaResultGoo goo) { - result = goo.Value; - switch (result.Type) { - case CaseType.CombinationCase when result.SelectedPermutationIds.Count > 1: - this.AddRuntimeWarning("Combination case contains " - + result.SelectedPermutationIds.Count - + " - only one permutation can be displayed at a time." + Environment.NewLine - + "Displaying first permutation; please use the 'Select Results' to select other single permutations"); - _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; - break; - - case CaseType.CombinationCase: - _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; - break; - - case CaseType.AnalysisCase: - _case = "Case A" + result.CaseId + Environment.NewLine + result.CaseName; - break; - } - } else { - this.AddRuntimeError("Error converting input to GSA Result"); - return; - } - - string elementlist = "All"; - var ghType = new GH_String(); - if (da.GetData(1, ref ghType)) { - GH_Convert.ToString(ghType, out elementlist, GH_Conversion.Both); - } - - var ghDiv = new GH_Integer(); - da.GetData(2, ref ghDiv); - GH_Convert.ToInt32(ghDiv, out int positionsCount, GH_Conversion.Both); - positionsCount = Math.Abs(positionsCount) + 2; // taken absolute value and add 2 end points. - - var ghColours = new List(); - var colors = new List(); - if (da.GetDataList(3, ghColours)) { - foreach (GH_Colour t in ghColours) { - GH_Convert.ToColor(t, out Color color, GH_Conversion.Both); - colors.Add(color); - } - } - - GH_Gradient ghGradient = Colours.Stress_Gradient(colors); - - var ghScale = new GH_Number(); - da.GetData(4, ref ghScale); - GH_Convert.ToDouble(ghScale, out double scale, GH_Conversion.Both); - - #endregion - - var res = new GsaResultsValues(); - - switch (_mode) { - case FoldMode.Displacement: - res = result.Element1DDisplacementValues(elementlist, positionsCount, 0, _lengthUnit)[0]; - - break; - - case FoldMode.Force: - res = result.Element1DForceValues(elementlist, positionsCount, 0, DefaultUnits.ForceUnit, - DefaultUnits.MomentUnit)[0]; - break; - - case FoldMode.StrainEnergy: - res = _disp == DisplayValue.X ? - result.Element1DStrainEnergyDensityValues(elementlist, positionsCount, 0, - _energyResultUnit)[0] : - result.Element1DAverageStrainEnergyDensityValues(elementlist, 0, _energyResultUnit)[0]; - break; - } - - var elementIDs = new List(); - elementIDs = result.Type == CaseType.AnalysisCase ? - result.ACaseElement1DResults.Values.First().Select(x => x.Key).ToList() : - result.ComboElement1DResults.Values.First().Select(x => x.Key).ToList(); - if (elementlist.ToLower() == "all") { - elementlist = string.Join(" ", elementIDs); - } - - var elems = new ConcurrentDictionary(result.Model.Model.Elements(elementlist)); - var nodes = new ConcurrentDictionary(result.Model.Model.Nodes()); - - ConcurrentDictionary> xyzResults - = res.XyzResults; - ConcurrentDictionary> xxyyzzResults - = res.XxyyzzResults; - - Enum xyzunit = _lengthUnit; - Enum xxyyzzunit = AngleUnit.Radian; - switch (_mode) { - case FoldMode.Force: - xyzunit = DefaultUnits.ForceUnit; - xxyyzzunit = DefaultUnits.MomentUnit; - break; - - case FoldMode.StrainEnergy: - xyzunit = DefaultUnits.EnergyUnit; - break; - } - - double dmaxX = res.DmaxX.As(xyzunit); - double dmaxY = _mode == FoldMode.StrainEnergy ? 0 : res.DmaxY.As(xyzunit); - double dmaxZ = _mode == FoldMode.StrainEnergy ? 0 : res.DmaxZ.As(xyzunit); - double dmaxXyz = _mode == FoldMode.StrainEnergy ? 0 : res.DmaxXyz.As(xyzunit); - double dminX = _mode == FoldMode.StrainEnergy ? 0 : res.DminX.As(xyzunit); - double dminY = _mode == FoldMode.StrainEnergy ? 0 : res.DminY.As(xyzunit); - double dminZ = _mode == FoldMode.StrainEnergy ? 0 : res.DminZ.As(xyzunit); - double dminXyz = _mode == FoldMode.StrainEnergy ? 0 : res.DminXyz.As(xyzunit); - double dmaxXx = _mode == FoldMode.StrainEnergy ? 0 : res.DmaxXx.As(xxyyzzunit); - double dmaxYy = _mode == FoldMode.StrainEnergy ? 0 : res.DmaxYy.As(xxyyzzunit); - double dmaxZz = _mode == FoldMode.StrainEnergy ? 0 : res.DmaxZz.As(xxyyzzunit); - double dmaxXxyyzz = _mode == FoldMode.StrainEnergy ? 0 : res.DmaxXxyyzz.As(xxyyzzunit); - double dminXx = _mode == FoldMode.StrainEnergy ? 0 : res.DminXx.As(xxyyzzunit); - double dminYy = _mode == FoldMode.StrainEnergy ? 0 : res.DminYy.As(xxyyzzunit); - double dminZz = _mode == FoldMode.StrainEnergy ? 0 : res.DminZz.As(xxyyzzunit); - double dminXxyyzz = _mode == FoldMode.StrainEnergy ? 0 : res.DminXxyyzz.As(xxyyzzunit); - - #region Result line values - - double dmax = 0; - double dmin = 0; - if (_mode == FoldMode.StrainEnergy) { - dmax = dmaxX; - dmin = dminX; - if (_disp == DisplayValue.X) { - _resType = "Strain Energy Density"; - } else { - positionsCount = 2; - _resType = "Average Strain E Dens."; - } - } else { - switch (_disp) { - case DisplayValue.X: - dmax = dmaxX; - dmin = dminX; - _resType = _mode == FoldMode.Displacement ? "Elem. Trans., Ux" : "Axial Force, Fx"; - break; - - case DisplayValue.Y: - dmax = dmaxY; - dmin = dminY; - _resType = _mode == FoldMode.Displacement ? "Elem. Trans., Uy" : "Shear Force, Fy"; - break; - - case DisplayValue.Z: - dmax = dmaxZ; - dmin = dminZ; - _resType = _mode == FoldMode.Displacement ? "Elem. Trans., Uz" : "Shear Force, Fz"; - break; - - case DisplayValue.ResXyz: - dmax = dmaxXyz; - dmin = dminXyz; - _resType = _mode == FoldMode.Displacement ? "Res. Trans., |U|" : "Res. Shear, |Fyz|"; - break; - - case DisplayValue.Xx: - dmax = dmaxXx; - dmin = dminXx; - _resType = _mode == FoldMode.Displacement ? "Elem. Rot., Rxx" : "Torsion, Mxx"; - break; - - case DisplayValue.Yy: - dmax = dmaxYy; - dmin = dminYy; - _resType = _mode == FoldMode.Displacement ? "Elem. Rot., Ryy" : "Moment, Myy"; - break; - - case DisplayValue.Zz: - dmax = dmaxZz; - dmin = dminZz; - _resType = _mode == FoldMode.Displacement ? "Elem. Rot., Rzz" : "Moment, Mzz"; - break; - - case DisplayValue.ResXxyyzz: - dmax = dmaxXxyyzz; - dmin = dminXxyyzz; - _resType = _mode == FoldMode.Displacement ? "Res. Rot., |U|" : "Res. Moment, |Myz|"; - break; - } - } - - List rounded = ResultHelper.SmartRounder(dmax, dmin); - dmax = rounded[0]; - dmin = rounded[1]; - int significantDigits = (int)rounded[2]; - - var resultLines = new DataTree(); - - Parallel.ForEach(elems, element => { - if (element.Value.IsDummy) { - return; - } - - if (element.Value.Type == ElementType.LINK) { - return; - } - - if (element.Value.Topology.Count > 2) { - return; - } - - var ln = new Line( - Nodes.Point3dFromNode(nodes[element.Value.Topology[0]], _lengthUnit), // start point - Nodes.Point3dFromNode(nodes[element.Value.Topology[1]], _lengthUnit)); // end point - - int key = element.Key; - - for (int i = 0; i < positionsCount - 1; i++) { - if (dmin == 0 & dmax == 0) { - continue; - } - - var startTranslation = new Vector3d(0, 0, 0); - var endTranslation = new Vector3d(0, 0, 0); - - IQuantity t1 = null; - IQuantity t2 = null; - - var start = new Point3d(ln.PointAt((double)i / (positionsCount - 1))); - var end = new Point3d(ln.PointAt((double)(i + 1) / (positionsCount - 1))); - - switch (_mode) { - case FoldMode.Displacement: - switch (_disp) { - case DisplayValue.X: - t1 = xyzResults[key][i].X.ToUnit(_lengthUnit); - t2 = xyzResults[key][i + 1].X.ToUnit(_lengthUnit); - startTranslation.X = t1.Value * _defScale; - endTranslation.X = t2.Value * _defScale; - break; - - case DisplayValue.Y: - t1 = xyzResults[key][i].Y.ToUnit(_lengthUnit); - t2 = xyzResults[key][i + 1].Y.ToUnit(_lengthUnit); - startTranslation.Y = t1.Value * _defScale; - endTranslation.Y = t2.Value * _defScale; - break; - - case DisplayValue.Z: - t1 = xyzResults[key][i].Z.ToUnit(_lengthUnit); - t2 = xyzResults[key][i + 1].Z.ToUnit(_lengthUnit); - startTranslation.Z = t1.Value * _defScale; - endTranslation.Z = t2.Value * _defScale; - break; - - case DisplayValue.ResXyz: - t1 = xyzResults[key][i].Xyz.ToUnit(_lengthUnit); - t2 = xyzResults[key][i + 1].Xyz.ToUnit(_lengthUnit); - startTranslation.X = xyzResults[key][i].X.As(_lengthUnit) * _defScale; - startTranslation.Y = xyzResults[key][i].Y.As(_lengthUnit) * _defScale; - startTranslation.Z = xyzResults[key][i].Z.As(_lengthUnit) * _defScale; - endTranslation.X = xyzResults[key][i + 1].X.As(_lengthUnit) * _defScale; - endTranslation.Y = xyzResults[key][i + 1].Y.As(_lengthUnit) * _defScale; - endTranslation.Z = xyzResults[key][i + 1].Z.As(_lengthUnit) * _defScale; - break; - - case DisplayValue.Xx: - t1 = xxyyzzResults[key][i].X.ToUnit(AngleUnit.Radian); - t2 = xxyyzzResults[key][i + 1].X.ToUnit(AngleUnit.Radian); - break; - - case DisplayValue.Yy: - t1 = xxyyzzResults[key][i].Y.ToUnit(AngleUnit.Radian); - t2 = xxyyzzResults[key][i + 1].Y.ToUnit(AngleUnit.Radian); - break; - - case DisplayValue.Zz: - t1 = xxyyzzResults[key][i].Z.ToUnit(AngleUnit.Radian); - t2 = xxyyzzResults[key][i + 1].Z.ToUnit(AngleUnit.Radian); - break; - - case DisplayValue.ResXxyyzz: - t1 = xxyyzzResults[key][i].Xyz.ToUnit(AngleUnit.Radian); - t2 = xxyyzzResults[key][i + 1].Xyz.ToUnit(AngleUnit.Radian); - break; - } - - start.Transform(Transform.Translation(startTranslation)); - end.Transform(Transform.Translation(endTranslation)); - break; - - case FoldMode.Force: - switch (_disp) { - case DisplayValue.X: - t1 = xyzResults[key][i].X.ToUnit(DefaultUnits.ForceUnit); - t2 = xyzResults[key][i + 1].X.ToUnit(DefaultUnits.ForceUnit); - break; - - case DisplayValue.Y: - t1 = xyzResults[key][i].Y.ToUnit(DefaultUnits.ForceUnit); - t2 = xyzResults[key][i + 1].Y.ToUnit(DefaultUnits.ForceUnit); - break; - - case DisplayValue.Z: - t1 = xyzResults[key][i].Z.ToUnit(DefaultUnits.ForceUnit); - t2 = xyzResults[key][i + 1].Z.ToUnit(DefaultUnits.ForceUnit); - break; - - case DisplayValue.ResXyz: - t1 = xyzResults[key][i].Xyz.ToUnit(DefaultUnits.ForceUnit); - t2 = xyzResults[key][i + 1].Xyz.ToUnit(DefaultUnits.ForceUnit); - break; - - case DisplayValue.Xx: - t1 = xxyyzzResults[key][i].X.ToUnit(DefaultUnits.MomentUnit); - t2 = xxyyzzResults[key][i + 1].X.ToUnit(DefaultUnits.MomentUnit); - break; - - case DisplayValue.Yy: - t1 = xxyyzzResults[key][i].Y.ToUnit(DefaultUnits.MomentUnit); - t2 = xxyyzzResults[key][i + 1].Y.ToUnit(DefaultUnits.MomentUnit); - break; - - case DisplayValue.Zz: - t1 = xxyyzzResults[key][i].Z.ToUnit(DefaultUnits.MomentUnit); - t2 = xxyyzzResults[key][i + 1].Z.ToUnit(DefaultUnits.MomentUnit); - break; - - case DisplayValue.ResXxyyzz: - t1 = xxyyzzResults[key][i].Xyz.ToUnit(DefaultUnits.MomentUnit); - t2 = xxyyzzResults[key][i + 1].Xyz.ToUnit(DefaultUnits.MomentUnit); - break; - } - - break; - - case FoldMode.StrainEnergy: - if (_disp == DisplayValue.X) { - t1 = xyzResults[key][i].X.ToUnit(DefaultUnits.EnergyUnit); - t2 = xyzResults[key][i + 1].X.ToUnit(DefaultUnits.EnergyUnit); - } else { - t1 = xyzResults[key][i].X.ToUnit(DefaultUnits.EnergyUnit); - t2 = xyzResults[key][i].X.ToUnit(DefaultUnits.EnergyUnit); - } - - break; - } - - var segmentline = new Line(start, end); - double tnorm1 = (2 * (t1.Value - dmin) / (dmax - dmin)) - 1; - double tnorm2 = (2 * (t2.Value - dmin) / (dmax - dmin)) - 1; - - Color valcol1 = double.IsNaN(tnorm1) ? Color.Black : ghGradient.ColourAt(tnorm1); - Color valcol2 = double.IsNaN(tnorm2) ? Color.Black : ghGradient.ColourAt(tnorm2); - - float size1 = (t1.Value >= 0 && dmax != 0) ? - Math.Max(2, (float)(t1.Value / dmax * scale)) : Math.Max(2, - (float)(Math.Abs(t1.Value) / Math.Abs(dmin) * scale)); - if (double.IsNaN(size1)) { - size1 = 1; - } - - float size2 = (t2.Value >= 0 && dmax != 0) ? - Math.Max(2, (float)(t2.Value / dmax * scale)) : Math.Max(2, - (float)(Math.Abs(t2.Value) / Math.Abs(dmin) * scale)); - if (double.IsNaN(size2)) { - size2 = 1; - } - - lock (resultLines) { - resultLines.Add( - new LineResultGoo(segmentline, t1, t2, valcol1, valcol2, size1, size2, key), - new GH_Path(key)); - } - } - }); - - #endregion - - #region Legend - - int gripheight = _legend.Height / ghGradient.GripCount; - _legendValues = new List(); - _legendValuesPosY = new List(); - - var ts = new List(); - var cs = new List(); - - for (int i = 0; i < ghGradient.GripCount; i++) { - double t = dmin + ((dmax - dmin) / ((double)ghGradient.GripCount - 1) * i); - double scl = Math.Pow(10, Math.Floor(Math.Log10(Math.Abs(t))) + 1); - scl = Math.Max(scl, 1); - t = scl * Math.Round(t / scl, 3); - - Color gradientcolour - = ghGradient.ColourAt((2 * (double)i / ((double)ghGradient.GripCount - 1)) - 1); - cs.Add(gradientcolour); - - int starty = i * gripheight; - int endy = starty + gripheight; - for (int y = starty; y < endy; y++) { - for (int x = 0; x < _legend.Width; x++) { - _legend.SetPixel(x, _legend.Height - y - 1, gradientcolour); - } - } - - switch (_mode) { - case FoldMode.Displacement when (int)_disp < 4: { - Length displacement = new Length(t, _lengthUnit).ToUnit(_lengthResultUnit); - _legendValues.Add(displacement.ToString("f" + significantDigits)); - ts.Add(new GH_UnitNumber(displacement)); - break; - } - case FoldMode.Displacement: { - var rotation = new Angle(t, AngleUnit.Radian); - _legendValues.Add(rotation.ToString("s" + significantDigits)); - ts.Add(new GH_UnitNumber(rotation)); - break; - } - case FoldMode.Force when (int)_disp < 4: { - var force = new Force(t, DefaultUnits.ForceUnit); - _legendValues.Add(force.ToString("s" + significantDigits)); - ts.Add(new GH_UnitNumber(force)); - break; - } - case FoldMode.Force: { - var moment = new Moment(t, DefaultUnits.MomentUnit); - _legendValues.Add(t.ToString("F" + significantDigits) + " " - + Moment.GetAbbreviation(DefaultUnits.MomentUnit)); - ts.Add(new GH_UnitNumber(moment)); - break; - } - default: { - var energy = new Energy(t, DefaultUnits.EnergyUnit); - _legendValues.Add(energy.ToString("s" + significantDigits)); - ts.Add(new GH_UnitNumber(energy)); - break; - } - } - - if (Math.Abs(t) > 1) { - _legendValues[i] = _legendValues[i] - .Replace(",", string.Empty); // remove thousand separator - } - - _legendValuesPosY.Add(_legend.Height - starty + (gripheight / 2) - 2); - } - - #endregion - - da.SetDataTree(0, resultLines); - da.SetDataList(1, cs); - da.SetDataList(2, ts); - } - - protected override void UpdateUIFromSelectedItems() { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[2]); - base.UpdateUIFromSelectedItems(); - } - - private void CreateGradient() { - var gradient = new GH_GradientControl(); - gradient.CreateAttributes(); - - gradient.Gradient = Colours.Stress_Gradient(); - gradient.Gradient.NormalizeGrips(); - gradient.Params.Input[0].AddVolatileData(new GH_Path(0), 0, -1); - gradient.Params.Input[1].AddVolatileData(new GH_Path(0), 0, 1); - gradient.Params.Input[2].AddVolatileDataList(new GH_Path(0), new List() { - -1, - -0.666, - -0.333, - 0, - 0.333, - 0.666, - 1, - }); - - gradient.Attributes.Pivot = new PointF( - Attributes.Bounds.X - gradient.Attributes.Bounds.Width - 50, - Params.Input[3].Attributes.Bounds.Y - (gradient.Attributes.Bounds.Height / 4) - 6); - - Instances.ActiveCanvas.Document.AddObject(gradient, false); - Params.Input[3].RemoveAllSources(); - Params.Input[3].AddSource(gradient.Params.Output[0]); - - UpdateUI(); - } - - private void Mode1Clicked() { - if (_mode == FoldMode.Displacement) { - return; - } - - RecordUndoEvent(_mode + " Parameters"); - _mode = FoldMode.Displacement; - - _slider = true; - _defScale = 100; - - ReDrawComponent(); - } - - private void Mode2Clicked() { - if (_mode == FoldMode.Force) { - return; - } - - RecordUndoEvent(_mode + " Parameters"); - _mode = FoldMode.Force; - - _slider = false; - _defScale = 0; - - ReDrawComponent(); - } - - private void Mode3Clicked() { - if (_mode == FoldMode.StrainEnergy) { - return; - } - - RecordUndoEvent(_mode + " Parameters"); - _mode = FoldMode.StrainEnergy; - - _slider = false; - _defScale = 0; - - ReDrawComponent(); - } - - private void ReDrawComponent() { - var pivot = new PointF(Attributes.Pivot.X, Attributes.Pivot.Y); - CreateAttributes(); - Attributes.Pivot = pivot; - Attributes.ExpireLayout(); - Attributes.PerformLayout(); - } - - private void ShowLegend(object sender, EventArgs e) { - _showLegend = !_showLegend; - ExpirePreview(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/Elem2dContourResults_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/Elem2dContourResults_OBSOLETE.cs deleted file mode 100644 index f6a46f2b8..000000000 --- a/GsaGH/Components/GraveyardComp/Elem2dContourResults_OBSOLETE.cs +++ /dev/null @@ -1,933 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Drawing; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper; -using Grasshopper.GUI.Gradient; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Data; -using Grasshopper.Kernel.Special; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.Graphics; -using GsaGH.Helpers.GsaApi; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Parameters; -using OasysGH.UI; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using Rhino.Collections; -using Rhino.Display; -using Rhino.Geometry; -using AngleUnit = OasysUnits.Units.AngleUnit; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to get Element2d results - /// - // ReSharper disable once InconsistentNaming - public class Elem2dContourResults_OBSOLETE : GH_OasysDropDownComponent { - private enum DisplayValue { - X, - Y, - Z, - ResXyz, - Xx, - Yy, - Zz, - ResXxyyzz, - } - - private enum FoldMode { - Displacement, - Force, - Stress, - } - - public override Guid ComponentGuid => new Guid("935d359a-9394-42fc-a76e-ea08ccb84135"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Contour2dResults; - private readonly List _displacement = new List(new[] { - "Translation Ux", - "Translation Uy", - "Translation Uz", - "Resolved |U|", - }); - private readonly List _force = new List(new[] { - "Force Nx", - "Force Ny", - "Force Nxy", - "Shear Qx", - "Shear Qy", - "Moment Mx", - "Moment My", - "Moment Mxy", - }); - private readonly List _layer = new List(new[] { - "Top", - "Middle", - "Bottom", - }); - private readonly List _stress = new List(new[] { - "Stress xx", - "Stress yy", - "Stress zz", - "Stress xy", - "Stress yz", - "Stress zx", - }); - private readonly List _type = new List(new[] { - "Displacement", - "Force", - "Stress", - }); - private string _case = string.Empty; - private double _defScale = 250; - private DisplayValue _disp = DisplayValue.ResXyz; - private int _flayer; - private bool _isShear; - private Bitmap _legend = new Bitmap(15, 120); - private List _legendValues; - private List _legendValuesPosY; - private LengthUnit _lengthResultUnit = DefaultUnits.LengthUnitResult; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - private double _maxValue = 1000; - private double _minValue; - private FoldMode _mode = FoldMode.Displacement; - private int _noDigits; - private string _resType; - private bool _showLegend = true; - private bool _slider = true; - - public Elem2dContourResults_OBSOLETE() : base("2D Contour Results", "ContourElem2d", - "Displays GSA 2D Element Results as Contour", CategoryName.Name(), SubCategoryName.Cat5()) { } - - public override void CreateAttributes() { - if (!_isInitialised) { - InitialiseDropdowns(); - } - - m_attributes = new DropDownSliderComponentAttributes(this, SetSelected, _dropDownItems, - _selectedItems, _slider, SetVal, SetMaxMin, _defScale, _maxValue, _minValue, _noDigits, - _spacerDescriptions); - } - - public override void DrawViewportWires(IGH_PreviewArgs args) { - base.DrawViewportWires(args); - if (!(_legendValues != null & _showLegend)) { - return; - } - - args.Display.DrawBitmap(new DisplayBitmap(_legend), args.Viewport.Bounds.Right - 110, 20); - for (int i = 0; i < _legendValues.Count; i++) { - args.Display.Draw2dText(_legendValues[i], Color.Black, - new Point2d(args.Viewport.Bounds.Right - 85, _legendValuesPosY[i]), false); - } - - args.Display.Draw2dText(_resType, Color.Black, - new Point2d(args.Viewport.Bounds.Right - 110, 7), false); - args.Display.Draw2dText(_case, Color.Black, - new Point2d(args.Viewport.Bounds.Right - 110, 145), false); - } - - public override bool Read(GH_IReader reader) { - _mode = (FoldMode)reader.GetInt32("Mode"); - _disp = (DisplayValue)reader.GetInt32("Display"); - _flayer = reader.GetInt32("flayer"); - _slider = reader.GetBoolean("slider"); - _noDigits = reader.GetInt32("noDec"); - _maxValue = reader.GetDouble("valMax"); - _minValue = reader.GetDouble("valMin"); - _defScale = reader.GetDouble("val"); - _showLegend = reader.GetBoolean("legend"); - return base.Read(reader); - } - - public void SetMaxMin(double max, double min) { - _maxValue = max; - _minValue = min; - } - - public override void SetSelected(int dropdownlistidd, int selectedidd) { - switch (dropdownlistidd) { - case 0: { - switch (selectedidd) { - case 0: { - if (_dropDownItems[1] != _displacement) { - if (_dropDownItems.Count == 4) // if coming from stress we remove the layer dropdown - { - _dropDownItems.RemoveAt(2); - _selectedItems.RemoveAt(2); - _spacerDescriptions.RemoveAt(2); - } - - _dropDownItems[1] = _displacement; - _dropDownItems[2] = FilteredUnits.FilteredLengthUnits; - - _selectedItems[0] = _dropDownItems[0][0]; // displacement - _selectedItems[1] = _dropDownItems[1][3]; // Resolved XYZ - _selectedItems[2] = Length.GetAbbreviation(_lengthUnit); - - _disp = (DisplayValue)3; - _isShear = false; - _flayer = 0; - Mode1Clicked(); - } - - break; - } - case 1: { - if (_dropDownItems[1] != _force) { - if (_dropDownItems.Count == 4) // if coming from stress we remove the layer dropdown - { - _dropDownItems.RemoveAt(2); - _selectedItems.RemoveAt(2); - _spacerDescriptions.RemoveAt(2); - } - - _dropDownItems[1] = _force; - - _selectedItems[0] = _dropDownItems[0][1]; - _selectedItems[1] = _dropDownItems[1][0]; - _selectedItems[2] = Length.GetAbbreviation(_lengthUnit); - - _disp = 0; - _isShear = false; - _flayer = 0; - Mode2Clicked(); - } - - break; - } - case 2: { - if (_dropDownItems[1] != _stress) { - if (_dropDownItems.Count < 4) { - _dropDownItems.Insert(2, _layer); - _spacerDescriptions.Insert(2, "Layer"); - } - - _dropDownItems[1] = _stress; - - _selectedItems[0] = _dropDownItems[0][2]; - _selectedItems[1] = _dropDownItems[1][0]; - - if (_selectedItems.Count < 4) { - _selectedItems.Insert(2, _dropDownItems[2][1]); - } else { - _selectedItems[2] = _dropDownItems[2][1]; - } - - _selectedItems[3] = Length.GetAbbreviation(_lengthUnit); - - _disp = 0; - _isShear = false; - Mode4Clicked(); - } - - break; - } - } - - break; - } - case 1: { - bool redraw = false; - _selectedItems[1] = _dropDownItems[1][selectedidd]; - if (_mode == FoldMode.Displacement) { - if ((int)_disp > 3 & selectedidd < 4) { - redraw = true; - _slider = true; - } - - if ((int)_disp < 4 & selectedidd > 3) { - redraw = true; - _slider = false; - } - } - - _disp = (DisplayValue)selectedidd; - if (_dropDownItems[1] != _displacement) { - _isShear = false; - if (_mode == FoldMode.Force) { - if (selectedidd == 3 | selectedidd == 4) { - _disp = (DisplayValue)selectedidd - 3; - _isShear = true; - } else if (selectedidd > 4) { - _disp = (DisplayValue)selectedidd - 1; - } - } else if (_mode == FoldMode.Force) { - if (selectedidd > 2) { - _disp = (DisplayValue)selectedidd + 1; - } - } - } - - if (redraw) { - ReDrawComponent(); - } - - break; - } - case 2 when _mode == FoldMode.Stress: { - switch (selectedidd) { - case 0: - _flayer = 1; - break; - - case 1: - _flayer = 0; - break; - - case 2: - _flayer = -1; - break; - } - - break; - } - default: - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[2]); - break; - } - - base.UpdateUI(); - } - - public void SetVal(double value) { - _defScale = value; - } - - public override void VariableParameterMaintenance() { - string lengthunitAbbreviation = Length.GetAbbreviation(_lengthUnit); - - switch (_mode) { - case FoldMode.Displacement when (int)_disp < 4: - Params.Output[2].Name = "Values [" + lengthunitAbbreviation + "]"; - break; - - case FoldMode.Displacement: - Params.Output[2].Name = "Values [rad]"; - break; - - case FoldMode.Force when (int)_disp < 4 | _isShear: - Params.Output[2].Name = "Legend Values [" - + ForcePerLength.GetAbbreviation(DefaultUnits.ForcePerLengthUnit) + "/" - + lengthunitAbbreviation + "]"; - break; - - case FoldMode.Force: - Params.Output[2].Name = "Legend Values [" + Force.GetAbbreviation(DefaultUnits.ForceUnit) - + "·" + lengthunitAbbreviation + "/" + lengthunitAbbreviation + "]"; - break; - - case FoldMode.Stress: - Params.Output[2].Name = "Legend Values [" - + Pressure.GetAbbreviation(DefaultUnits.StressUnitResult) + "]"; - break; - } - } - - public override bool Write(GH_IWriter writer) { - writer.SetInt32("Mode", (int)_mode); - writer.SetInt32("Display", (int)_disp); - writer.SetInt32("flayer", _flayer); - writer.SetBoolean("slider", _slider); - writer.SetInt32("noDec", _noDigits); - writer.SetDouble("valMax", _maxValue); - writer.SetDouble("valMin", _minValue); - writer.SetDouble("val", _defScale); - writer.SetBoolean("legend", _showLegend); - return base.Write(writer); - } - - protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - Menu_AppendItem(menu, "Show Legend", ShowLegend, true, _showLegend); - - var gradient = new GH_GradientControl(); - gradient.CreateAttributes(); - var extract = new ToolStripMenuItem("Extract Default Gradient", gradient.Icon_24x24, - (s, e) => CreateGradient()); - menu.Items.Add(extract); - Menu_AppendSeparator(menu); - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Result Type", - "Component", - "Geometry Unit", - "Deform Shape", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(_type); - _selectedItems.Add(_dropDownItems[0][0]); - - _dropDownItems.Add(_displacement); - _selectedItems.Add(_dropDownItems[1][3]); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaResultParameter(), "Result", "Res", "GSA Result", - GH_ParamAccess.item); - pManager.AddTextParameter("Element filter list", "El", - "Filter import by list." + Environment.NewLine + "Element list should take the form:" - + Environment.NewLine - + " 1 11 to 20 step 2 P1 not (G1 to G6 step 3) P11 not (PA PB1 PS2 PM3 PA4 M1)" - + Environment.NewLine - + "Refer to GSA help file for definition of lists and full vocabulary.", - GH_ParamAccess.item, "All"); - pManager.AddColourParameter("Colour", "Co", - "Optional list of colours to override default colours" + Environment.NewLine - + "A new gradient will be created from the input list of colours", GH_ParamAccess.list); - pManager[1].Optional = true; - pManager[2].Optional = true; - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - IQuantity length = new Length(0, _lengthResultUnit); - string lengthunitAbbreviation = string.Concat(length.ToString().Where(char.IsLetter)); - - pManager.AddGenericParameter("Mesh", "M", "Mesh with coloured result values", - GH_ParamAccess.item); - pManager.AddGenericParameter("Colours", "LC", "Legend Colours", GH_ParamAccess.list); - pManager.AddGenericParameter("Values [" + lengthunitAbbreviation + "]", "LT", "Legend Values", - GH_ParamAccess.list); - } - - protected override void SolveInternal(IGH_DataAccess da) { - var result = new GsaResult(); - var ghTyp = new GH_ObjectWrapper(); - if (!da.GetData(0, ref ghTyp)) { - return; - } - - #region Inputs - - if (ghTyp.Value is GsaResultGoo goo) { - result = goo.Value; - switch (result.Type) { - case CaseType.CombinationCase when result.SelectedPermutationIds.Count > 1: - this.AddRuntimeWarning("Combination case contains " - + result.SelectedPermutationIds.Count - + " - only one permutation can be displayed at a time." + Environment.NewLine - + "Displaying first permutation; please use the 'Select Results' to select other single permutations"); - _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; - break; - - case CaseType.CombinationCase: - _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; - break; - - case CaseType.AnalysisCase: - _case = "Case A" + result.CaseId + Environment.NewLine + result.CaseName; - break; - } - } else { - this.AddRuntimeError("Error converting input to GSA Result"); - return; - } - - string elementlist = "All"; - var ghType = new GH_String(); - if (da.GetData(1, ref ghType)) { - GH_Convert.ToString(ghType, out elementlist, GH_Conversion.Both); - } - - var ghColours = new List(); - var colors = new List(); - if (da.GetDataList(2, ghColours)) { - foreach (GH_Colour t in ghColours) { - GH_Convert.ToColor(t, out Color color, GH_Conversion.Both); - colors.Add(color); - } - } - - GH_Gradient ghGradient = Colours.Stress_Gradient(colors); - - #endregion - - var res = new GsaResultsValues(); - var resShear = new GsaResultsValues(); - switch (_mode) { - case FoldMode.Displacement: - res = result.Element2DDisplacementValues(elementlist, _lengthUnit)[0]; - break; - - case FoldMode.Force: - res = result.Element2DForceValues(elementlist, DefaultUnits.ForcePerLengthUnit, - DefaultUnits.ForceUnit)[0]; - resShear = result.Element2DShearValues(elementlist, DefaultUnits.ForcePerLengthUnit)[0]; - break; - - case FoldMode.Stress: - res = result.Element2DStressValues(elementlist, _flayer, - DefaultUnits.StressUnitResult)[0]; - break; - } - - ReadOnlyDictionary elems = result.Model.Model.Elements(elementlist); - ReadOnlyDictionary nodes = result.Model.Model.Nodes(); - - ConcurrentDictionary> xyzResults - = _isShear ? resShear.XyzResults : res.XyzResults; - ConcurrentDictionary> xxyyzzResults - = res.XxyyzzResults; - - Enum xyzunit = _lengthUnit; - Enum xxyyzzunit = AngleUnit.Radian; - switch (_mode) { - case FoldMode.Force: - xyzunit = DefaultUnits.ForcePerLengthUnit; - xxyyzzunit = DefaultUnits.ForceUnit; - break; - - case FoldMode.Stress: - xyzunit = DefaultUnits.StressUnitResult; - xxyyzzunit = DefaultUnits.StressUnitResult; - break; - } - - double dmaxX = _isShear ? resShear.DmaxX.As(xyzunit) : res.DmaxX.As(xyzunit); - double dmaxY = _isShear ? resShear.DmaxY.As(xyzunit) : res.DmaxY.As(xyzunit); - double dmaxZ = res.DmaxZ.As(xyzunit); - double dmaxXyz = (_mode == FoldMode.Displacement) ? res.DmaxXyz.As(xyzunit) : 0; - double dminX = _isShear ? resShear.DminX.As(xyzunit) : res.DminX.As(xyzunit); - double dminY = _isShear ? resShear.DminY.As(xyzunit) : res.DminY.As(xyzunit); - double dminZ = res.DminZ.As(xyzunit); - double dminXyz = (_mode == FoldMode.Displacement) ? res.DminXyz.As(xyzunit) : 0; - double dmaxXx = _isShear ? 0 : res.DmaxXx.As(xxyyzzunit); - double dmaxYy = _isShear ? 0 : res.DmaxYy.As(xxyyzzunit); - double dmaxZz = _isShear ? 0 : res.DmaxZz.As(xxyyzzunit); - double dmaxXxyyzz = 0; - double dminXx = _isShear ? 0 : res.DminXx.As(xxyyzzunit); - double dminYy = _isShear ? 0 : res.DminYy.As(xxyyzzunit); - double dminZz = _isShear ? 0 : res.DminZz.As(xxyyzzunit); - double dminXxyyzz = 0; - - #region Result mesh values - - double dmax = 0; - double dmin = 0; - switch (_disp) { - case DisplayValue.X: - dmax = dmaxX; - dmin = dminX; - if (_mode == FoldMode.Displacement) { - _resType = "Translation, Ux"; - } else if (_mode == FoldMode.Force & !_isShear) { - _resType = "2D Force, Nx"; - } else if (_mode == FoldMode.Force & _isShear) { - _resType = "2D Shear, Qx"; - } else if (_mode == FoldMode.Stress) { - _resType = "Stress, xx"; - } - - break; - - case DisplayValue.Y: - dmax = dmaxY; - dmin = dminY; - if (_mode == FoldMode.Displacement) { - _resType = "Translation, Uy"; - } else if (_mode == FoldMode.Force & !_isShear) { - _resType = "2D Force, Ny"; - } else if (_mode == FoldMode.Force & _isShear) { - _resType = "2D Shear, Qy"; - } else if (_mode == FoldMode.Stress) { - _resType = "2D Stress, yy"; - } - - break; - - case DisplayValue.Z: - dmax = dmaxZ; - dmin = dminZ; - if (_mode == FoldMode.Displacement) { - _resType = "Translation, Uz"; - } else if (_mode == FoldMode.Force & !_isShear) { - _resType = "2D Force, Nxy"; - } else if (_mode == FoldMode.Stress) { - _resType = "Stress, zz"; - } - - break; - - case DisplayValue.ResXyz: - dmax = dmaxXyz; - dmin = dminXyz; - if (_mode == FoldMode.Displacement) { - _resType = "Res. Trans., |U|"; - } - - break; - - case DisplayValue.Xx: - dmax = dmaxXx; - dmin = dminXx; - if (_mode == FoldMode.Force & !_isShear) { - _resType = "2D Moment, Mx"; - } else if (_mode == FoldMode.Stress) { - _resType = "Stress, xy"; - } - - break; - - case DisplayValue.Yy: - dmax = dmaxYy; - dmin = dminYy; - if (_mode == FoldMode.Force & !_isShear) { - _resType = "2D Moment, My"; - } else if (_mode == FoldMode.Stress) { - _resType = "Stress, yz"; - } - - break; - - case DisplayValue.Zz: - dmax = dmaxZz; - dmin = dminZz; - if (_mode == FoldMode.Force & !_isShear) { - _resType = "2D Moment, Mxy"; - } else if (_mode == FoldMode.Stress) { - _resType = "Stress, zy"; - } - - break; - - case DisplayValue.ResXxyyzz: - dmax = dmaxXxyyzz; - dmin = dminXxyyzz; - break; - } - - List rounded = ResultHelper.SmartRounder(dmax, dmin); - dmax = rounded[0]; - dmin = rounded[1]; - int significantDigits = (int)rounded[2]; - - #region create mesh - - var resultMeshes = new MeshResultGoo(new Mesh(), new List>(), - new List(), new List()); - var meshes = new ConcurrentDictionary(); - meshes.AsParallel().AsOrdered(); - var values = new ConcurrentDictionary>(); - values.AsParallel().AsOrdered(); - var verticies = new ConcurrentDictionary(); - verticies.AsParallel().AsOrdered(); - - Parallel.ForEach(elems.Keys, key => { - Element element = elems[key]; - if (element.Topology.Count < 3) { - return; - } - - Mesh tempmesh = GsaElementFactory.GetMeshFromApiElement2d(element, nodes, _lengthUnit); - if (tempmesh == null) { - return; - } - - List transformation = null; - var vals = new List(); - switch (_disp) { - case DisplayValue.X: - vals = xyzResults[key].Select(item => item.Value.X.ToUnit(xyzunit)).ToList(); - if (_mode == FoldMode.Displacement) { - transformation = vals.Select(item => new Vector3d(item.Value * _defScale, 0, 0)) - .ToList(); - } - - break; - - case DisplayValue.Y: - vals = xyzResults[key].Select(item => item.Value.Y.ToUnit(xyzunit)).ToList(); - if (_mode == FoldMode.Displacement) { - transformation = vals.Select(item => new Vector3d(0, item.Value * _defScale, 0)) - .ToList(); - } - - break; - - case DisplayValue.Z: - vals = xyzResults[key].Select(item => item.Value.Z.ToUnit(xyzunit)).ToList(); - if (_mode == FoldMode.Displacement) { - transformation = vals.Select(item => new Vector3d(0, 0, item.Value * _defScale)) - .ToList(); - } - - break; - - case DisplayValue.ResXyz: - vals = xyzResults[key].Select(item => item.Value.Xyz.ToUnit(xyzunit)).ToList(); - if (_mode == FoldMode.Displacement) { - transformation = xyzResults[key].Select(item - => new Vector3d(item.Value.X.As(xyzunit) * _defScale, - item.Value.Y.As(xyzunit) * _defScale, item.Value.Z.As(xyzunit) * _defScale)) - .ToList(); - } - - break; - - case DisplayValue.Xx: - vals = xxyyzzResults[key].Select(item => item.Value.X.ToUnit(xxyyzzunit)).ToList(); - break; - - case DisplayValue.Yy: - vals = xxyyzzResults[key].Select(item => item.Value.Y.ToUnit(xxyyzzunit)).ToList(); - break; - - case DisplayValue.Zz: - vals = xxyyzzResults[key].Select(item => item.Value.Z.ToUnit(xxyyzzunit)).ToList(); - break; - - case DisplayValue.ResXxyyzz: - vals = xxyyzzResults[key].Select(item => item.Value.Xyz.ToUnit(xxyyzzunit)).ToList(); - break; - } - - for (int i = 0; i < vals.Count - 1; - i++) // start at i=0, now the last index is the centre point in GsaAPI output so to count -1 - { - double tnorm = (2 * (vals[i].Value - dmin) / (dmax - dmin)) - 1; - Color col = double.IsNaN(tnorm) ? Color.Transparent : ghGradient.ColourAt(tnorm); - tempmesh.VertexColors.Add(col); - if (transformation == null) { - continue; - } - - Point3f def = tempmesh.Vertices[i]; - def.Transform(Transform.Translation(transformation[i])); - tempmesh.Vertices[i] = def; - } - - if ( - tempmesh.Vertices.Count - == 9) // add the value/colour at the centre point if quad-8 (as it already has a vertex here) - { - double tnorm = (2 * (vals.Last().Value - dmin) / (dmax - dmin)) - 1; - Color col = double.IsNaN(tnorm) ? Color.Transparent : ghGradient.ColourAt(tnorm); - tempmesh.VertexColors.Add(col); - if (transformation != null) { - Point3f def = tempmesh.Vertices[8]; - def.Transform(Transform.Translation(transformation.Last())); - tempmesh.Vertices[8] = def; - } - } - - if ( - vals.Count - == 1) // if analysis settings is set to '2D element forces and 2D/3D stresses at centre only' - { - double tnorm = (2 * (vals[0].Value - dmin) / (dmax - dmin)) - 1; - Color col = double.IsNaN(tnorm) ? Color.Transparent : ghGradient.ColourAt(tnorm); - for (int i = 0; i < tempmesh.Vertices.Count; i++) { - tempmesh.VertexColors.Add(col); - } - } - - meshes[key] = tempmesh; - values[key] = vals; - verticies[key] = new Point3dList(tempmesh.Vertices.Select(pt => (Point3d)pt).ToList()); - - #endregion - }); - - #endregion - - resultMeshes.AddRange(meshes.Values.ToList(), values.Values.ToList(), verticies.Values.ToList(), - meshes.Keys.ToList()); - - #region Legend - - int gripheight = _legend.Height / ghGradient.GripCount; - _legendValues = new List(); - _legendValuesPosY = new List(); - - var ts = new List(); - var cs = new List(); - - for (int i = 0; i < ghGradient.GripCount; i++) { - double t = dmin + ((dmax - dmin) / ((double)ghGradient.GripCount - 1) * i); - double scl = Math.Pow(10, Math.Floor(Math.Log10(Math.Abs(t))) + 1); - scl = Math.Max(scl, 1); - t = scl * Math.Round(t / scl, 3); - - Color gradientcolour - = ghGradient.ColourAt((2 * (double)i / ((double)ghGradient.GripCount - 1)) - 1); - cs.Add(gradientcolour); - - int starty = i * gripheight; - int endy = starty + gripheight; - for (int y = starty; y < endy; y++) { - for (int x = 0; x < _legend.Width; x++) { - _legend.SetPixel(x, _legend.Height - y - 1, gradientcolour); - } - } - - switch (_mode) { - case FoldMode.Displacement when (int)_disp < 4: { - Length displacement = new Length(t, _lengthUnit).ToUnit(_lengthResultUnit); - _legendValues.Add(displacement.ToString("f" + significantDigits)); - ts.Add(new GH_UnitNumber(displacement)); - break; - } - case FoldMode.Displacement: { - var rotation = new Angle(t, AngleUnit.Radian); - _legendValues.Add(rotation.ToString("s" + significantDigits)); - ts.Add(new GH_UnitNumber(rotation)); - break; - } - case FoldMode.Force when (int)_disp < 4 | _isShear: { - var forcePerLength = new ForcePerLength(t, DefaultUnits.ForcePerLengthUnit); - _legendValues.Add(forcePerLength.ToString("s" + significantDigits)); - ts.Add(new GH_UnitNumber(forcePerLength)); - break; - } - case FoldMode.Force: { - IQuantity length = new Length(0, _lengthUnit); - string lengthunitAbbreviation = string.Concat(length.ToString().Where(char.IsLetter)); - _legendValues.Add(new Force(t, DefaultUnits.ForceUnit).ToString("s" + significantDigits) - + lengthunitAbbreviation + "/" + lengthunitAbbreviation); - var moment = new Moment(t, DefaultUnits.MomentUnit); - ts.Add(new GH_UnitNumber(moment)); - break; - } - case FoldMode.Stress: { - var stress = new Pressure(t, DefaultUnits.StressUnitResult); - _legendValues.Add(stress.ToString("s" + significantDigits)); - ts.Add(new GH_UnitNumber(stress)); - break; - } - } - - if (Math.Abs(t) > 1) { - _legendValues[i] = _legendValues[i] - .Replace(",", string.Empty); // remove thousand separator - } - - _legendValuesPosY.Add(_legend.Height - starty + (gripheight / 2) - 2); - } - - #endregion - - da.SetData(0, resultMeshes); - da.SetDataList(1, cs); - da.SetDataList(2, ts); - } - - protected override void UpdateUIFromSelectedItems() { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[2]); - base.UpdateUIFromSelectedItems(); - } - - private void CreateGradient() { - var gradient = new GH_GradientControl(); - gradient.CreateAttributes(); - - gradient.Gradient = Colours.Stress_Gradient(); - gradient.Gradient.NormalizeGrips(); - gradient.Params.Input[0].AddVolatileData(new GH_Path(0), 0, -1); - gradient.Params.Input[1].AddVolatileData(new GH_Path(0), 0, 1); - gradient.Params.Input[2].AddVolatileDataList(new GH_Path(0), new List() { - -1, - -0.666, - -0.333, - 0, - 0.333, - 0.666, - 1, - }); - - gradient.Attributes.Pivot = new PointF( - Attributes.Bounds.X - gradient.Attributes.Bounds.Width - 50, - Params.Input[2].Attributes.Bounds.Y - (gradient.Attributes.Bounds.Height / 4) - 6); - - Instances.ActiveCanvas.Document.AddObject(gradient, false); - Params.Input[2].RemoveAllSources(); - Params.Input[2].AddSource(gradient.Params.Output[0]); - - UpdateUI(); - } - - private void Mode1Clicked() { - if (_mode == FoldMode.Displacement) { - return; - } - - RecordUndoEvent(_mode + " Parameters"); - _mode = FoldMode.Displacement; - - _slider = true; - _defScale = 100; - - ReDrawComponent(); - } - - private void Mode2Clicked() { - if (_mode == FoldMode.Force) { - return; - } - - RecordUndoEvent(_mode + " Parameters"); - _mode = FoldMode.Force; - - _slider = false; - _defScale = 0; - _spacerDescriptions[2] = "Deform Shape"; - - ReDrawComponent(); - } - - private void Mode4Clicked() { - if (_mode == FoldMode.Stress) { - return; - } - - RecordUndoEvent(_mode + " Parameters"); - _mode = FoldMode.Stress; - - _slider = false; - _defScale = 0; - - ReDrawComponent(); - } - - private void ReDrawComponent() { - var pivot = new PointF(Attributes.Pivot.X, Attributes.Pivot.Y); - CreateAttributes(); - Attributes.Pivot = pivot; - Attributes.ExpireLayout(); - Attributes.PerformLayout(); - } - - private void ShowLegend(object sender, EventArgs e) { - _showLegend = !_showLegend; - ExpirePreview(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/Elem2dFromBrep2_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/Elem2dFromBrep2_OBSOLETE.cs deleted file mode 100644 index dcce233ce..000000000 --- a/GsaGH/Components/GraveyardComp/Elem2dFromBrep2_OBSOLETE.cs +++ /dev/null @@ -1,258 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Components.GraveyardComp; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Helpers; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; -using Rhino.Collections; -using Rhino.Geometry; - -namespace GsaGH.Components { - /// - /// Component to edit a Node - /// - // ReSharper disable once InconsistentNaming - public class Elem2dFromBrep2_OBSOLETE : GH_OasysDropDownComponent { - public override Guid ComponentGuid => new Guid("83948408-c55d-49b9-b9a7-98034bcf3ce1"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Create2dElementsFromBrep; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - private Length _tolerance = DefaultUnits.Tolerance; - private string _toleranceTxt = string.Empty; - - public Elem2dFromBrep2_OBSOLETE() : base("Element2d from Brep", "Elem2dFromBrep", - "Mesh a non-planar Brep", CategoryName.Name(), SubCategoryName.Cat2()) { } - - public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - - var tolerance = new ToolStripTextBox { - Text = _tolerance.ToString(), - BackColor = Color.FromArgb(255, 180, 255, 150), - }; - tolerance.TextChanged += (s, e) => MaintainText(tolerance); - - var toleranceMenu = new ToolStripMenuItem("Set Tolerance", Resources.ModelUnits) { - Enabled = true, - ImageScaling = ToolStripItemImageScaling.SizeToFit, - }; - - toleranceMenu.DropDownItems[1].MouseUp += (s, e) => { - UpdateMessage(); - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - ExpireSolution(true); - }; - menu.Items.Add(toleranceMenu); - - Menu_AppendSeparator(menu); - } - - public override bool Read(GH_IReader reader) { - if (reader.ChunkExists("ParameterData")) { - return base.Read(reader); - } - - BaseReader.Read(reader, this); - _isInitialised = true; - UpdateUIFromSelectedItems(); - GH_IReader attributes = reader.FindChunk("Attributes"); - Attributes.Bounds = (RectangleF)attributes.Items[0].InternalData; - Attributes.Pivot = (PointF)attributes.Items[1].InternalData; - return true; - } - - public override void SetSelected(int i, int j) { - _selectedItems[i] = _dropDownItems[i][j]; - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[i]); - base.UpdateUI(); - } - - public override void VariableParameterMaintenance() { - Params.Input[4].Name = "Mesh Size [" + Length.GetAbbreviation(_lengthUnit) + "]"; - } - - protected override void BeforeSolveInstance() { - base.BeforeSolveInstance(); - UpdateMessage(); - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Unit", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddBrepParameter("Brep", "B", "Brep (can be non-planar)", GH_ParamAccess.item); - pManager.AddGenericParameter("Incl. Points or Nodes", "(P)", "Inclusion points or Nodes", - GH_ParamAccess.list); - pManager.AddGenericParameter("Incl. Curves or 1D Members", "(C)", - "Inclusion curves or 1D Members", GH_ParamAccess.list); - pManager.AddParameter(new GsaProperty2dParameter()); - pManager.AddGenericParameter("Mesh Size", "Ms", "Target mesh size", GH_ParamAccess.item); - - pManager[1].Optional = true; - pManager[2].Optional = true; - pManager[3].Optional = true; - pManager[4].Optional = true; - pManager.HideParameter(0); - pManager.HideParameter(1); - pManager.HideParameter(2); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaElement2dParameter(), "2D Elements", "E2D", "GSA 2D Elements", - GH_ParamAccess.list); - } - - protected override void SolveInternal(IGH_DataAccess da) { - var ghbrep = new GH_Brep(); - if (!da.GetData(0, ref ghbrep)) { - return; - } - - if (ghbrep == null) { - this.AddRuntimeWarning("Brep input is null"); - } - - var brep = new Brep(); - if (!GH_Convert.ToBrep(ghbrep, ref brep, GH_Conversion.Both)) { - return; - } - - var ghTypes = new List(); - var pts = new Point3dList(); - var nodes = new List(); - if (da.GetDataList(1, ghTypes)) { - foreach (GH_ObjectWrapper objectWrapper in ghTypes) { - var pt = new Point3d(); - if (objectWrapper.Value is GsaNodeGoo nodeGoo) { - nodes.Add(new GsaNode(nodeGoo.Value)); - } else if (GH_Convert.ToPoint3d(objectWrapper.Value, ref pt, GH_Conversion.Both)) { - pts.Add(new Point3d(pt)); - } else { - string type = objectWrapper.Value.GetType().ToString(); - type = type.Replace("GsaGH.Parameters.", string.Empty); - type = type.Replace("Goo", string.Empty); - this.AddRuntimeError("Unable to convert incl. Point/Node input parameter of type " - + type + " to point or node"); - } - } - } - - ghTypes = new List(); - var curves = new List(); - var member1ds = new List(); - if (da.GetDataList(2, ghTypes)) { - foreach (GH_ObjectWrapper objectWrapper in ghTypes) { - Curve crv = null; - if (objectWrapper.Value is GsaMember1dGoo member1dGoo) { - member1ds.Add(new GsaMember1d(member1dGoo.Value)); - } else if (GH_Convert.ToCurve(objectWrapper.Value, ref crv, GH_Conversion.Both)) { - curves.Add(crv.DuplicateCurve()); - } else { - string type = objectWrapper.Value.GetType().ToString(); - type = type.Replace("GsaGH.Parameters.", string.Empty); - type = type.Replace("Goo", string.Empty); - this.AddRuntimeError("Unable to convert incl. Curve/Mem1D input parameter of type " - + type + " to curve or 1D Member"); - } - } - } - - var meshSize = (Length)Input.UnitNumber(this, da, 4, _lengthUnit, true); -#pragma warning disable CS0618 // Type or member is obsolete - var elem2d = new GsaElement2d(brep, curves, pts, meshSize.As(_lengthUnit), member1ds, nodes, - _lengthUnit, _tolerance); -#pragma warning restore CS0618 // Type or member is obsolete - var ghTyp = new GH_ObjectWrapper(); - var prop2d = new GsaProperty2d(); - if (da.GetData(3, ref ghTyp)) { - if (ghTyp.Value is GsaProperty2dGoo prop2DGoo) { - prop2d = prop2DGoo.Value; - } else { - if (GH_Convert.ToInt32(ghTyp.Value, out int idd, GH_Conversion.Both)) { - prop2d.Id = idd; - } else { - this.AddRuntimeError( - "Unable to convert PA input to a 2D Property of reference integer"); - return; - } - } - } else { - prop2d.Id = 0; - } - - var prop2Ds = new List(); - for (int i = 0; i < elem2d.ApiElements.Count; i++) { - prop2Ds.Add(prop2d); - } - - elem2d.Prop2ds = prop2Ds; - - da.SetData(0, new GsaElement2dGoo(elem2d)); - - this.AddRuntimeRemark( - "This component is work-in-progress and provided 'as-is'. It will unroll the surface, do the meshing, map the mesh back on the original surface. Only single surfaces will work. Surfaces of high curvature and not-unrollable geometries (like a sphere) is unlikely to produce good results"); - } - - protected override void UpdateUIFromSelectedItems() { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[0]); - base.UpdateUIFromSelectedItems(); - } - - private void MaintainText(ToolStripItem tolerance) { - _toleranceTxt = tolerance.Text; - tolerance.BackColor = Length.TryParse(_toleranceTxt, out Length _) ? - Color.FromArgb(255, 180, 255, 150) : Color.FromArgb(255, 255, 100, 100); - } - - private void UpdateMessage() { - if (_toleranceTxt != string.Empty) { - try { - var newTolerance = Length.Parse(_toleranceTxt); - _tolerance = newTolerance; - } catch (Exception e) { - MessageBox.Show(e.Message); - return; - } - } - - Message = "Tol: " + _tolerance; - if (_tolerance.Meters < 0.001) { - this.AddRuntimeRemark( - "Set tolerance is quite small, you can change this by right-clicking the component."); - } - - if (_tolerance.Meters > 0.25) { - this.AddRuntimeRemark( - "Set tolerance is quite large, you can change this by right-clicking the component."); - } - } - } -} diff --git a/GsaGH/Components/GraveyardComp/Elem2dFromBrep_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/Elem2dFromBrep_OBSOLETE.cs deleted file mode 100644 index a0a5b28cd..000000000 --- a/GsaGH/Components/GraveyardComp/Elem2dFromBrep_OBSOLETE.cs +++ /dev/null @@ -1,192 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; -using Rhino.Collections; -using Rhino.Geometry; - -namespace GsaGH.Components { - /// - /// Component to edit a Node - /// - // ReSharper disable once InconsistentNaming - public class Elem2dFromBrep_OBSOLETE : GH_OasysDropDownComponent { - public override Guid ComponentGuid => new Guid("4fa7ccd9-530e-4036-b2bf-203017b55611"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Create2dElementsFromBrep; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - - public Elem2dFromBrep_OBSOLETE() : base("Element2d from Brep", "Elem2dFromBrep", - "Mesh a non-planar Brep", CategoryName.Name(), SubCategoryName.Cat2()) { } - - public override void SetSelected(int i, int j) { - _selectedItems[i] = _dropDownItems[i][j]; - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[i]); - base.UpdateUI(); - } - - public override void VariableParameterMaintenance() { - string unitAbbreviation = Length.GetAbbreviation(_lengthUnit); - - int i = 0; - Params.Input[i++].Name = "Brep [in " + unitAbbreviation + "]"; - Params.Input[i++].Name = "Incl. Points or Nodes [in " + unitAbbreviation + "]"; - Params.Input[i++].Name = "Incl. Curves or 1D Members [in " + unitAbbreviation + "]"; - i++; - Params.Input[i].Name = "Mesh Size [" + unitAbbreviation + "]"; - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new string[] { - "Unit", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - string unitAbbreviation = Length.GetAbbreviation(_lengthUnit); - pManager.AddBrepParameter("Brep [in " + unitAbbreviation + "]", "B", - "Brep (can be non-planar)", GH_ParamAccess.item); - pManager.AddGenericParameter("Incl. Points or Nodes [in " + unitAbbreviation + "]", "(P)", - "Inclusion points or Nodes", GH_ParamAccess.list); - pManager.AddGenericParameter("Incl. Curves or 1D Members [in " + unitAbbreviation + "]", - "(C)", "Inclusion curves or 1D Members", GH_ParamAccess.list); - pManager.AddParameter(new GsaProperty2dParameter()); - pManager.AddNumberParameter("Mesh Size [" + unitAbbreviation + "]", "Ms", "Targe mesh size", - GH_ParamAccess.item, 0); - - pManager[1].Optional = true; - pManager[2].Optional = true; - pManager[3].Optional = true; - pManager.HideParameter(0); - pManager.HideParameter(1); - pManager.HideParameter(2); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaElement2dParameter(), "2D Elements", "E2D", "GSA 2D Elements", - GH_ParamAccess.list); - } - - protected override void SolveInternal(IGH_DataAccess da) { - var ghbrep = new GH_Brep(); - if (!da.GetData(0, ref ghbrep)) { - return; - } - - if (ghbrep == null) { - this.AddRuntimeWarning("Brep input is null"); - } - - var brep = new Brep(); - if (!GH_Convert.ToBrep(ghbrep, ref brep, GH_Conversion.Both)) { - return; - } - - var ghTypes = new List(); - var point3ds = new Point3dList(); - var nodes = new List(); - if (da.GetDataList(1, ghTypes)) { - foreach (GH_ObjectWrapper objectWrapper in ghTypes) { - var point3d = new Point3d(); - if (objectWrapper.Value is GsaNodeGoo nodeGoo) { - nodes.Add(nodeGoo.Value); - } else if (GH_Convert.ToPoint3d(objectWrapper.Value, ref point3d, GH_Conversion.Both)) { - point3ds.Add(point3d); - } else { - string type = objectWrapper.Value.GetType().ToString(); - type = type.Replace("GsaGH.Parameters.", string.Empty); - type = type.Replace("Goo", string.Empty); - this.AddRuntimeError("Unable to convert incl. Point/Node input parameter of type " - + type + " to point or node"); - } - } - } - - ghTypes = new List(); - var crvs = new List(); - var mem1ds = new List(); - if (da.GetDataList(2, ghTypes)) { - foreach (GH_ObjectWrapper objectWrapper in ghTypes) { - Curve crv = null; - if (objectWrapper.Value is GsaMember1dGoo member1dGoo) { - mem1ds.Add(member1dGoo.Value); - } else if (GH_Convert.ToCurve(objectWrapper.Value, ref crv, GH_Conversion.Both)) { - crvs.Add(crv); - } else { - string type = objectWrapper.Value.GetType().ToString(); - type = type.Replace("GsaGH.Parameters.", string.Empty); - type = type.Replace("Goo", string.Empty); - this.AddRuntimeError("Unable to convert incl. Curve/Mem1D input parameter of type " - + type + " to curve or 1D Member"); - } - } - } - - var ghmsz = new GH_Number(); - Length meshSize = Length.Zero; - if (da.GetData(4, ref ghmsz)) { - GH_Convert.ToDouble(ghmsz, out double size, GH_Conversion.Both); - meshSize = new Length(size, _lengthUnit).ToUnit(LengthUnit.Meter); - } - -#pragma warning disable CS0618 // Type or member is obsolete - var elem2d = new GsaElement2d(brep, crvs, point3ds, meshSize.Value, mem1ds, nodes, - _lengthUnit, DefaultUnits.Tolerance); -#pragma warning restore CS0618 // Type or member is obsolete - - var ghTyp = new GH_ObjectWrapper(); - var prop2d = new GsaProperty2d(); - if (da.GetData(3, ref ghTyp)) { - if (ghTyp.Value is GsaProperty2dGoo prop2DGoo) { - prop2d = prop2DGoo.Value; - } else { - if (GH_Convert.ToInt32(ghTyp.Value, out int idd, GH_Conversion.Both)) { - prop2d.Id = idd; - } else { - this.AddRuntimeError( - "Unable to convert PA input to a 2D Property of reference integer"); - return; - } - } - } else { - prop2d.Id = 1; - } - - var prop2Ds = new List(); - for (int i = 0; i < elem2d.ApiElements.Count; i++) { - prop2Ds.Add(prop2d); - } - - elem2d.Prop2ds = prop2Ds; - - da.SetData(0, new GsaElement2dGoo(elem2d)); - - this.AddRuntimeRemark( - "This component is work-in-progress and provided 'as-is'. It will unroll the surface, do the meshing, map the mesh back on the original surface. Only single surfaces will work. Surfaces of high curvature and not-unrollable geometries (like a sphere) is unlikely to produce good results"); - } - - protected override void UpdateUIFromSelectedItems() { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[0]); - base.UpdateUIFromSelectedItems(); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/GetAnalysis2_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/GetAnalysis2_OBSOLETE.cs deleted file mode 100644 index 6043708e2..000000000 --- a/GsaGH/Components/GraveyardComp/GetAnalysis2_OBSOLETE.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using Grasshopper.Kernel; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; - -namespace GsaGH.Components.GraveyardComp { - /// - /// Component to retrieve non-geometric objects from a GSA model - /// - public class GetAnalysis2_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("566a94d2-a022-4f12-a645-0366deb1476c"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.GetModelAnalysis; - - public GetAnalysis2_OBSOLETE() : base("Get Model Analysis Tasks", "GetAnalysisTasks", - "Get Analysis Tasks and their Cases from GSA model", CategoryName.Name(), - SubCategoryName.Cat0()) { - Hidden = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaModelParameter(), "GSA Model", "GSA", - "GSA model containing some Analysis Cases and Tasks", GH_ParamAccess.item); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaAnalysisTaskParameter(), "Analysis Tasks", "ΣT", - "List of Analysis Tasks in model", GH_ParamAccess.list); - pManager.AddParameter(new GsaAnalysisCaseParameter(), "Analysis Cases", "ΣA", - "List of Analysis Cases in model", GH_ParamAccess.list); - } - - protected override void SolveInstance(IGH_DataAccess da) { - GsaModelGoo modelGoo = null; - da.GetData(0, ref modelGoo); - - Tuple, List> tuple - = modelGoo.Value.GetAnalysisTasksAndCombinations(); - - da.SetDataList(0, tuple.Item1); - da.SetDataList(1, tuple.Item2); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/GetAnalysis_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/GetAnalysis_OBSOLETE.cs deleted file mode 100644 index 45f34b942..000000000 --- a/GsaGH/Components/GraveyardComp/GetAnalysis_OBSOLETE.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using Grasshopper.Kernel; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; - -namespace GsaGH.Components { - /// - /// Component to retrieve non-geometric objects from a GSA model - /// - // ReSharper disable once InconsistentNaming - public class GetAnalysis_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("fa497db7-8bdd-438d-888f-83a85d6cd48a"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.GetModelAnalysis; - - public GetAnalysis_OBSOLETE() : base("Get Model Analysis", "GetAnalysis", - "Get Analysis Cases and Tasks from GSA model", CategoryName.Name(), SubCategoryName.Cat0()) { - Hidden = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddGenericParameter("GSA Model", "GSA", - "GSA model containing some Analysis Cases and Tasks", GH_ParamAccess.item); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddGenericParameter("Analysis Tasks", "Tasks", "List of analysis tasks in model", - GH_ParamAccess.list); - pManager.AddGenericParameter("Analysis Case Names", "Name", "Analysis case name", - GH_ParamAccess.list); - pManager.AddGenericParameter("Load Case/Combination ID", "LC", - "Load cases and combinations list", GH_ParamAccess.list); - pManager.AddGenericParameter("Analysis Case Description", "Desc", "Analysis case description", - GH_ParamAccess.list); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var gsaModel = new GsaModel(); - if (!da.GetData(0, ref gsaModel)) { - return; - } - - Model model = gsaModel.Model; - var taskList = new List(); - var descriptionList = new List(); - var caseNameList = new List(); - var analysisIdList = new List(); - - foreach (int key in model.AnalysisTasks().Keys) { - model.AnalysisTasks().TryGetValue(key, out AnalysisTask analTask); - taskList.Add(analTask?.Name); - } - - foreach (int key in model.Results().Keys) { - descriptionList.Add(model.AnalysisCaseDescription(key)); - caseNameList.Add(model.AnalysisCaseName(key)); - analysisIdList.Add(key); - } - - da.SetDataList(0, taskList); - da.SetDataList(1, caseNameList); - da.SetDataList(3, descriptionList); - da.SetDataList(2, analysisIdList); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/GetLoads_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/GetLoads_OBSOLETE.cs deleted file mode 100644 index 8a4e77c1f..000000000 --- a/GsaGH/Components/GraveyardComp/GetLoads_OBSOLETE.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Drawing; -using System.Linq; -using Grasshopper.Kernel; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to retrieve non-geometric objects from a GSA model - /// - public class GetLoads_OBSOLETE : GH_OasysDropDownComponent { - public override Guid ComponentGuid => new Guid("87ff28e5-a1a6-4d78-ba71-e930e01dca13"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.GetModelLoads; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - - public GetLoads_OBSOLETE() : base("Get Model Loads", "GetLoads", - "Get Loads and Grid Planes/Surfaces from GSA model", CategoryName.Name(), - SubCategoryName.Cat0()) { - Hidden = true; - } - - public override void SetSelected(int i, int j) { - _selectedItems[i] = _dropDownItems[i][j]; - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[i]); - base.UpdateUI(); - } - - public override void VariableParameterMaintenance() { - string unitAbbreviation = Length.GetAbbreviation(_lengthUnit); - int i = 4; - Params.Output[i++].Name = "Grid Point Loads [" + unitAbbreviation + "]"; - Params.Output[i++].Name = "Grid Line Loads [" + unitAbbreviation + "]"; - Params.Output[i++].Name = "Grid Area Loads [" + unitAbbreviation + "]"; - Params.Output[i].Name = "Grid Plane Surfaces [" + unitAbbreviation + "]"; - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Unit", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaModelParameter(), "GSA Model", "GSA", - "GSA model containing some loads", GH_ParamAccess.item); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - string unitAbbreviation = Length.GetAbbreviation(_lengthUnit); - - pManager.AddParameter(new GsaLoadParameter(), "Gravity Loads", "Gr", - "Gravity Loads from GSA Model", GH_ParamAccess.list); - pManager.AddParameter(new GsaLoadParameter(), "Node Loads", "No", "Node Loads from GSA Model", - GH_ParamAccess.list); - pManager.AddParameter(new GsaLoadParameter(), "Beam Loads", "Be", "Beam Loads from GSA Model", - GH_ParamAccess.list); - pManager.AddParameter(new GsaLoadParameter(), "Face Loads", "Fa", "Face Loads from GSA Model", - GH_ParamAccess.list); - pManager.AddParameter(new GsaLoadParameter(), "Grid Point Loads [" + unitAbbreviation + "]", - "Pt", "Grid Point Loads from GSA Model", GH_ParamAccess.list); - pManager.AddParameter(new GsaLoadParameter(), "Grid Line Loads [" + unitAbbreviation + "]", - "Ln", "Grid Line Loads from GSA Model", GH_ParamAccess.list); - pManager.AddParameter(new GsaLoadParameter(), "Grid Area Loads [" + unitAbbreviation + "]", - "Ar", "Grid Area Loads from GSA Model", GH_ParamAccess.list); - pManager.AddParameter(new GsaGridPlaneSurfaceParameter(), - "Grid Plane Surfaces [" + unitAbbreviation + "]", "GPS", - "Grid Plane Surfaces from GSA Model", GH_ParamAccess.list); - pManager.HideParameter(7); - } - - protected override void SolveInternal(IGH_DataAccess da) { - GsaModelGoo modelGoo = null; - da.GetData(0, ref modelGoo); - - GsaAPI.Model model = modelGoo.Value.Model; - ReadOnlyDictionary loadCases = model.LoadCases(); - List gravity = GsaLoadFactory.CreateGravityLoadsFromApi(model.GravityLoads(), loadCases); - List node = GsaLoadFactory.CreateNodeLoadsFromApi(model, loadCases); - List beam = GsaLoadFactory.CreateBeamLoadsFromApi(model.BeamLoads(), loadCases); - List face = GsaLoadFactory.CreateFaceLoadsFromApi(model.FaceLoads(), loadCases); - - IReadOnlyDictionary srfDict = model.GridSurfaces(); - IReadOnlyDictionary plnDict = model.GridPlanes(); - IReadOnlyDictionary axDict = model.Axes(); - List point = GsaLoadFactory.CreateGridPointLoadsFromApi( - model.GridPointLoads(), srfDict, plnDict, axDict, loadCases, _lengthUnit); - List line = GsaLoadFactory.CreateGridLineLoadsFromApi( - model.GridLineLoads(), srfDict, plnDict, axDict, loadCases, _lengthUnit); - List area = GsaLoadFactory.CreateGridAreaLoadsFromApi( - model.GridAreaLoads(), srfDict, plnDict, axDict, loadCases, _lengthUnit); - - var gps = srfDict.Keys.Select(key - => new GsaGridPlaneSurfaceGoo(GsaLoadFactory.CreateGridPlaneSurfaceFromApi(srfDict, plnDict, axDict, key, - _lengthUnit))).ToList(); - - da.SetDataList(0, gravity); - da.SetDataList(1, node); - da.SetDataList(2, beam); - da.SetDataList(3, face); - da.SetDataList(4, point); - da.SetDataList(5, line); - da.SetDataList(6, area); - da.SetDataList(7, gps); - } - - protected override void UpdateUIFromSelectedItems() { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[0]); - base.UpdateUIFromSelectedItems(); - } - } -} \ No newline at end of file diff --git a/GsaGH/Components/GraveyardComp/GetProperties_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/GetProperties_OBSOLETE.cs deleted file mode 100644 index 924e0c9eb..000000000 --- a/GsaGH/Components/GraveyardComp/GetProperties_OBSOLETE.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using Grasshopper.Kernel; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; - -namespace GsaGH.Components.GraveyardComp { - /// - /// Component to retrieve non-geometric objects from a GSA model - /// - public class GetProperties_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("e7914f27-ea03-48e4-b7bd-a87121141f1e"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.GetModelProperties; - - public GetProperties_OBSOLETE() : base("Get Model Properties", "GetProps", - "Get Sections, 2D Properties and Springs from GSA model", CategoryName.Name(), - SubCategoryName.Cat0()) { - Hidden = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaModelParameter(), "GSA Model", "GSA", - "GSA model containing some properties", GH_ParamAccess.item); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaSectionParameter(), "Sections", "PB", - "Section Properties from GSA Model", GH_ParamAccess.list); - pManager.AddParameter(new GsaProperty2dParameter(), "2D Properties", "PA", - "2D Properties from GSA Model", GH_ParamAccess.list); - pManager.AddParameter(new GsaProperty3dParameter(), "3D Properties", "PV", - "3D Properties from GSA Model", GH_ParamAccess.list); - pManager.AddParameter(new GsaMaterialParameter(), "Custom Materials", "Mat", - "Custom Materials from GSA Model", GH_ParamAccess.list); - } - - protected override void SolveInstance(IGH_DataAccess da) { - GsaModelGoo modelGoo = null; - da.GetData(0, ref modelGoo); - - var materials = new List(); - materials.AddRange( - modelGoo.Value.Materials.SteelMaterials.Values.Select(x => new GsaMaterialGoo(x))); - materials.AddRange( - modelGoo.Value.Materials.ConcreteMaterials.Values.Select(x => new GsaMaterialGoo(x))); - materials.AddRange( - modelGoo.Value.Materials.FrpMaterials.Values.Select(x => new GsaMaterialGoo(x))); - materials.AddRange( - modelGoo.Value.Materials.AluminiumMaterials.Values.Select(x => new GsaMaterialGoo(x))); - materials.AddRange( - modelGoo.Value.Materials.TimberMaterials.Values.Select(x => new GsaMaterialGoo(x))); - materials.AddRange( - modelGoo.Value.Materials.GlassMaterials.Values.Select(x => new GsaMaterialGoo(x))); - materials.AddRange( - modelGoo.Value.Materials.FabricMaterials.Values.Select(x => new GsaMaterialGoo(x))); - materials.AddRange( - modelGoo.Value.Materials.AnalysisMaterials.Values.Select(x => new GsaMaterialGoo(x))); - - da.SetDataList(0, modelGoo.Value.Sections.Values); - da.SetDataList(1, modelGoo.Value.Prop2ds.Values); - da.SetDataList(2, modelGoo.Value.Prop3ds.Values); - da.SetDataList(3, materials); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/GetSectionProperties2_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/GetSectionProperties2_OBSOLETE.cs deleted file mode 100644 index 715e1b58e..000000000 --- a/GsaGH/Components/GraveyardComp/GetSectionProperties2_OBSOLETE.cs +++ /dev/null @@ -1,184 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; - -namespace GsaGH.Components { - /// - /// Component to get geometric properties of a section - /// - public class GetSectionProperties2_OBSOLETE : GH_OasysComponent, IGH_VariableParameterComponent { - public override Guid ComponentGuid => new Guid("fc59d2f7-496e-4862-8f66-31f1068fcab7"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.SectionProperties; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitSection; - - public GetSectionProperties2_OBSOLETE() : base("Section Properties", "SectProp", - "Get GSA Section Properties", CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - - var unitsMenu = new ToolStripMenuItem("Select unit", Resources.ModelUnits) { - Enabled = true, - ImageScaling = ToolStripItemImageScaling.SizeToFit, - }; - foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => Update(unit)) { - Checked = unit == Length.GetAbbreviation(_lengthUnit), - Enabled = true, - }; - unitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - menu.Items.Add(unitsMenu); - - Menu_AppendSeparator(menu); - } - - bool IGH_VariableParameterComponent.CanInsertParameter(GH_ParameterSide side, int index) { - return false; - } - - bool IGH_VariableParameterComponent.CanRemoveParameter(GH_ParameterSide side, int index) { - return false; - } - - IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index) { - return null; - } - - bool IGH_VariableParameterComponent.DestroyParameter(GH_ParameterSide side, int index) { - return false; - } - - public override bool Read(GH_IReader reader) { - _lengthUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("LengthUnit")); - return base.Read(reader); - } - - public virtual void VariableParameterMaintenance() { - AreaUnit areaUnit = UnitsHelper.GetAreaUnit(_lengthUnit); - AreaMomentOfInertiaUnit inertiaUnit = UnitsHelper.GetAreaMomentOfInertiaUnit(_lengthUnit); - - Params.Output[0].Name = "Area [" + Area.GetAbbreviation(areaUnit) + "]"; - Params.Output[1].Name = "Moment of Inertia y-y [" - + AreaMomentOfInertia.GetAbbreviation(inertiaUnit) + "]"; - Params.Output[2].Name = "Moment of Inertia z-z [" - + AreaMomentOfInertia.GetAbbreviation(inertiaUnit) + "]"; - Params.Output[3].Name = "Moment of Inertia y-z [" - + AreaMomentOfInertia.GetAbbreviation(inertiaUnit) + "]"; - Params.Output[4].Name - = "Torsion constant [" + AreaMomentOfInertia.GetAbbreviation(inertiaUnit) + "]"; - } - - public override bool Write(GH_IWriter writer) { - writer.SetString("LengthUnit", _lengthUnit.ToString()); - return base.Write(writer); - } - - protected override void BeforeSolveInstance() { - Message = Length.GetAbbreviation(_lengthUnit); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaSectionParameter(), GsaSectionGoo.Name, GsaSectionGoo.NickName, - GsaSectionGoo.Description + " to get a bit more info out of.", GH_ParamAccess.item); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - AreaUnit areaUnit = UnitsHelper.GetAreaUnit(_lengthUnit); - AreaMomentOfInertiaUnit inertiaUnit = UnitsHelper.GetAreaMomentOfInertiaUnit(_lengthUnit); - - pManager.AddGenericParameter("Area [" + Area.GetAbbreviation(areaUnit) + "]", "A", - "Section Area", GH_ParamAccess.item); - pManager.AddGenericParameter( - "Moment of Inertia y-y [" + AreaMomentOfInertia.GetAbbreviation(inertiaUnit) + "]", "Iyy", - "Section Moment of Intertia around local y-y axis", GH_ParamAccess.item); - pManager.AddGenericParameter( - "Moment of Inertia z-z [" + AreaMomentOfInertia.GetAbbreviation(inertiaUnit) + "]", "Izz", - "Section Moment of Intertia around local z-z axis", GH_ParamAccess.item); - pManager.AddGenericParameter( - "Moment of Inertia y-z [" + AreaMomentOfInertia.GetAbbreviation(inertiaUnit) + "]", "Iyz", - "Section Moment of Intertia around local y-z axis", GH_ParamAccess.item); - pManager.AddGenericParameter( - "Torsion constant [" + AreaMomentOfInertia.GetAbbreviation(inertiaUnit) + "]", "J", - "Section Torsion constant J", GH_ParamAccess.item); - pManager.AddGenericParameter("Shear Area Factor in y", "Ky", - "Section Shear Area Factor in local y-direction", GH_ParamAccess.item); - pManager.AddGenericParameter("Shear Area Factor in z", "Kz", - "Section Shear Area Factor in local z-direction", GH_ParamAccess.item); - pManager.AddGenericParameter("Surface A/Length [m²/m]", "S/L", - "Section Surface Area per Unit Length", GH_ParamAccess.item); - pManager.AddGenericParameter("Volume/Length [m³/m]", "V/L", "Section Volume per Unit Length", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var ghTyp = new GH_ObjectWrapper(); - if (!da.GetData(0, ref ghTyp)) { - return; - } - - GsaSection section; - if (ghTyp.Value is GsaSectionGoo sectionGoo) { - section = sectionGoo.Value; - } else { - string profile = string.Empty; - ghTyp.CastTo(ref profile); - if (GsaSection.IsValidProfile(profile)) { - section = new GsaSection(profile); - } else { - this.AddRuntimeWarning("Invalid profile syntax: " + profile); - return; - } - } - - AreaUnit areaUnit = UnitsHelper.GetAreaUnit(_lengthUnit); - AreaMomentOfInertiaUnit inertiaUnit = UnitsHelper.GetAreaMomentOfInertiaUnit(_lengthUnit); - - GsaSectionProperties props = section.SectionProperties; - - da.SetData(0, new GH_UnitNumber(new Area(props.Area.As(areaUnit), areaUnit))); - da.SetData(1, - new GH_UnitNumber(new AreaMomentOfInertia(props.Iyy.As(inertiaUnit), inertiaUnit))); - da.SetData(2, - new GH_UnitNumber(new AreaMomentOfInertia(props.Izz.As(inertiaUnit), inertiaUnit))); - da.SetData(3, - new GH_UnitNumber(new AreaMomentOfInertia(props.Iyz.As(inertiaUnit), inertiaUnit))); - da.SetData(4, - new GH_UnitNumber(new AreaMomentOfInertia(props.J.As(inertiaUnit), inertiaUnit))); - da.SetData(5, props.Kyy); - da.SetData(6, props.Kzz); - da.SetData(7, new GH_UnitNumber(props.SurfaceAreaPerLength)); - da.SetData(8, new GH_UnitNumber(props.VolumePerLength)); - } - - private void Update(string unit) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), unit); - Message = unit; - (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); - ExpireSolution(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/GetSectionProperties_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/GetSectionProperties_OBSOLETE.cs deleted file mode 100644 index d6413add0..000000000 --- a/GsaGH/Components/GraveyardComp/GetSectionProperties_OBSOLETE.cs +++ /dev/null @@ -1,155 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; - -namespace GsaGH.Components { - /// - /// Component to get geometric properties of a section - /// - // ReSharper disable once InconsistentNaming - public class GetSectionProperties_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("6504a99f-a4e2-4e30-8251-de31ea83e8cb"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.SectionProperties; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitSection; - - public GetSectionProperties_OBSOLETE() : base("Section Properties", "SectProp", - "Get GSA Section Properties", CategoryName.Name(), SubCategoryName.Cat1()) { - Hidden = true; - } - - public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - - var unitsMenu = new ToolStripMenuItem("Select unit", Resources.ModelUnits) { - Enabled = true, - ImageScaling = ToolStripItemImageScaling.SizeToFit, - }; - foreach (string unit in UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)) { - var toolStripMenuItem = new ToolStripMenuItem(unit, null, (s, e) => Update(unit)) { - Checked = unit == Length.GetAbbreviation(_lengthUnit), - Enabled = true, - }; - unitsMenu.DropDownItems.Add(toolStripMenuItem); - } - - menu.Items.Add(unitsMenu); - - Menu_AppendSeparator(menu); - } - - public override bool Read(GH_IReader reader) { - if (reader.ItemExists("LengthUnit")) // = v0.9.33 => saved as IGH_Variableblabla - { - _lengthUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("LengthUnit")); - bool flag = base.Read(reader); - return flag & Params.ReadAllParameterData(reader); - } - - _lengthUnit = DefaultUnits.LengthUnitSection; - return base.Read(reader); - } - - public override bool Write(GH_IWriter writer) { - writer.SetString("LengthUnit", _lengthUnit.ToString()); - return base.Write(writer); - } - - protected override void BeforeSolveInstance() { - Message = Length.GetAbbreviation(_lengthUnit); - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaSectionParameter(), GsaSectionGoo.Name, GsaSectionGoo.NickName, - GsaSectionGoo.Description + " to get a bit more info out of.", GH_ParamAccess.item); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - AreaUnit areaUnit = UnitsHelper.GetAreaUnit(_lengthUnit); - AreaMomentOfInertiaUnit inertiaUnit = UnitsHelper.GetAreaMomentOfInertiaUnit(_lengthUnit); - - pManager.AddGenericParameter("Area [" + Area.GetAbbreviation(areaUnit) + "]", "A", - "Section Area", GH_ParamAccess.item); - pManager.AddGenericParameter( - "Moment of Inertia y-y [" + AreaMomentOfInertia.GetAbbreviation(inertiaUnit) + "]", "Iyy", - "Section Moment of Intertia around local y-y axis", GH_ParamAccess.item); - pManager.AddGenericParameter( - "Moment of Inertia z-z [" + AreaMomentOfInertia.GetAbbreviation(inertiaUnit) + "]", "Izz", - "Section Moment of Intertia around local z-z axis", GH_ParamAccess.item); - pManager.AddGenericParameter( - "Moment of Inertia y-z [" + AreaMomentOfInertia.GetAbbreviation(inertiaUnit) + "]", "Iyz", - "Section Moment of Intertia around local y-z axis", GH_ParamAccess.item); - pManager.AddGenericParameter( - "Torsion constant [" + AreaMomentOfInertia.GetAbbreviation(inertiaUnit) + "]", "J", - "Section Torsion constant J", GH_ParamAccess.item); - pManager.AddGenericParameter("Shear Area Factor in y", "Ky", - "Section Shear Area Factor in local y-direction", GH_ParamAccess.item); - pManager.AddGenericParameter("Shear Area Factor in z", "Kz", - "Section Shear Area Factor in local z-direction", GH_ParamAccess.item); - pManager.AddGenericParameter("Surface A/Length [m²/m]", "S/L", - "Section Surface Area per Unit Length", GH_ParamAccess.item); - pManager.AddGenericParameter("Volume/Length [m³/m]", "V/L", "Section Volume per Unit Length", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - GsaSection section; - var ghTyp = new GH_ObjectWrapper(); - if (!da.GetData(0, ref ghTyp)) { - return; - } - - if (ghTyp.Value is GsaSectionGoo sectionGoo) { - section = sectionGoo.Value; - } else { - string profile = string.Empty; - ghTyp.CastTo(ref profile); - section = new GsaSection(profile); - } - - AreaUnit areaUnit = UnitsHelper.GetAreaUnit(_lengthUnit); - AreaMomentOfInertiaUnit inertiaUnit = UnitsHelper.GetAreaMomentOfInertiaUnit(_lengthUnit); - - GsaSectionProperties props = section.SectionProperties; - - da.SetData(0, new GH_UnitNumber(new Area(props.Area.As(areaUnit), areaUnit))); - da.SetData(1, - new GH_UnitNumber(new AreaMomentOfInertia(props.Iyy.As(inertiaUnit), inertiaUnit))); - da.SetData(2, - new GH_UnitNumber(new AreaMomentOfInertia(props.Izz.As(inertiaUnit), inertiaUnit))); - da.SetData(3, - new GH_UnitNumber(new AreaMomentOfInertia(props.Iyz.As(inertiaUnit), inertiaUnit))); - da.SetData(4, - new GH_UnitNumber(new AreaMomentOfInertia(props.J.As(inertiaUnit), inertiaUnit))); - da.SetData(5, props.Kyy); - da.SetData(6, props.Kzz); - da.SetData(7, new GH_UnitNumber(props.SurfaceAreaPerLength)); - da.SetData(8, new GH_UnitNumber(props.VolumePerLength)); - } - - private void Update(string unit) { - _lengthUnit = Length.ParseUnit(unit); - Message = unit; - ExpireSolution(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/GlobalResult_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/GlobalResult_OBSOLETE.cs deleted file mode 100644 index d4f636f23..000000000 --- a/GsaGH/Components/GraveyardComp/GlobalResult_OBSOLETE.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Drawing; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using Rhino.Geometry; - -namespace GsaGH.Components { - /// - /// Component to retrieve non-geometric objects from a GSA model - /// - // ReSharper disable once InconsistentNaming - public class GlobalResult_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("267d8dc3-aa6e-4ed2-b82d-57fc290173cc"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.ResultGlobal; - - public GlobalResult_OBSOLETE() : base("Global Results", "GlobalResult", - "Get Global Results from GSA model", CategoryName.Name(), SubCategoryName.Cat5()) { - Hidden = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddGenericParameter("GSA Model", "GSA", "GSA model containing some results", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Load Case", "LC", "Load Case (default 1)", GH_ParamAccess.item, - 1); - pManager[1].Optional = true; - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddVectorParameter("Total Force Loads [kN]", "ΣF", - "Sum of all Force Loads in GSA Model", GH_ParamAccess.item); - pManager.AddVectorParameter("Total Moment Loads [kNm]", "ΣM", - "Sum of all Moment Loads in GSA Model", GH_ParamAccess.item); - pManager.AddVectorParameter("Total Force Reactions [kN]", "ΣRf", - "Sum of all Rection Forces in GSA Model", GH_ParamAccess.item); - pManager.AddVectorParameter("Total Moment Reactions [kNm]", "ΣRm", - "Sum of all Reaction Moments in GSA Model", GH_ParamAccess.item); - pManager.AddVectorParameter("Effective Mass [kg]", "Σkg", "Effective Mass in GSA Model", - GH_ParamAccess.item); - pManager.AddVectorParameter("Effective Inertia [m4]", "ΣI", "Effective Inertia in GSA Model", - GH_ParamAccess.item); - pManager.AddNumberParameter("Mode", "Mo", "Mode number if LC is a dynamic task", - GH_ParamAccess.item); - pManager.AddVectorParameter("Modal", "Md", - "Modal results in vector form:" + Environment.NewLine + "x: Modal Mass" - + Environment.NewLine + "y: Modal Stiffness" + Environment.NewLine - + "z: Modal Geometric Stiffness", GH_ParamAccess.item); - pManager.AddNumberParameter("Frequency [Hz]", "f", "Frequency of selected LoadCase / mode", - GH_ParamAccess.item); - pManager.AddNumberParameter("Load Factor", "LF", "Load Factor for selected LoadCase / mode", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - GsaModel model; - var ghTyp = new GH_ObjectWrapper(); - if (!da.GetData(0, ref ghTyp)) { - return; - } - - if (ghTyp.Value is GsaModelGoo modelGoo) { - model = modelGoo.Value; - } else { - this.AddRuntimeError("Error converting input to GSA Model"); - return; - } - - var ghACase = new GH_Integer(); - da.GetData(1, ref ghACase); - GH_Convert.ToInt32(ghACase, out int analCase, GH_Conversion.Both); - - model.Model.Results().TryGetValue(analCase, out AnalysisCaseResult analysisCaseResult); - if (analysisCaseResult == null) { - this.AddRuntimeError("No results exist for Analysis Case " + analCase + " in file"); - return; - } - - const double unitfactorForce = 1000; - const double unitfactorMoment = 1000; - - var force = new Vector3d(analysisCaseResult.Global.TotalLoad.X / unitfactorForce, - analysisCaseResult.Global.TotalLoad.Y / unitfactorForce, - analysisCaseResult.Global.TotalLoad.Z / unitfactorForce); - - var moment = new Vector3d(analysisCaseResult.Global.TotalLoad.XX / unitfactorMoment, - analysisCaseResult.Global.TotalLoad.YY / unitfactorMoment, - analysisCaseResult.Global.TotalLoad.ZZ / unitfactorMoment); - - var reaction = new Vector3d(analysisCaseResult.Global.TotalReaction.X / unitfactorForce, - analysisCaseResult.Global.TotalReaction.Y / unitfactorForce, - analysisCaseResult.Global.TotalReaction.Z / unitfactorForce); - - var reactionmoment = new Vector3d( - analysisCaseResult.Global.TotalReaction.XX / unitfactorMoment, - analysisCaseResult.Global.TotalReaction.YY / unitfactorMoment, - analysisCaseResult.Global.TotalReaction.ZZ / unitfactorMoment); - - var effMass = new Vector3d(analysisCaseResult.Global.EffectiveMass.X, - analysisCaseResult.Global.EffectiveMass.Y, analysisCaseResult.Global.EffectiveMass.Z); - - Vector3d effStiff; - if (analysisCaseResult.Global.EffectiveInertia != null) { - effStiff = new Vector3d(analysisCaseResult.Global.EffectiveInertia.X, - analysisCaseResult.Global.EffectiveInertia.Y, - analysisCaseResult.Global.EffectiveInertia.Z); - } else { - effStiff = new Vector3d(); - } - - var modal = new Vector3d(analysisCaseResult.Global.ModalMass, - analysisCaseResult.Global.ModalStiffness, - analysisCaseResult.Global.ModalGeometricStiffness); - - da.SetData(0, force); - da.SetData(1, moment); - da.SetData(2, reaction); - da.SetData(3, reactionmoment); - da.SetData(4, effMass); - da.SetData(5, effStiff); - da.SetData(6, analysisCaseResult.Global.Mode); - da.SetData(7, modal); - da.SetData(8, analysisCaseResult.Global.Frequency); - da.SetData(9, analysisCaseResult.Global.LoadFactor); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/GwaModel_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/GwaModel_OBSOLETE.cs deleted file mode 100644 index 417e159c4..000000000 --- a/GsaGH/Components/GraveyardComp/GwaModel_OBSOLETE.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using Grasshopper.Kernel; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using Interop.Gsa_10_2; -using OasysGH; -using OasysGH.Components; - -namespace GsaGH.Components { - /// - /// Component to create a GSA model from GWA string - /// - // ReSharper disable once InconsistentNaming - public class GwaModel_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("6f701c53-1531-45ef-9842-9356da59b590"); - public override GH_Exposure Exposure => GH_Exposure.tertiary | GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.GwaCommand; - - public GwaModel_OBSOLETE() : base("Create GWA Model", "GWA", - "Create a model from a GWA string.", CategoryName.Name(), SubCategoryName.Cat0()) { - Hidden = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddTextParameter("GWA string", "GWA", - "GWA string from GSA. Right-click on any data, and select copy all. Paste into notepad to check the data. \r\nThis input takes a a list of text strings that will automatically be joined. Construct a tree structure if you want to create multiple GSA files. \r\nThe syntax of the command is based on GWA syntax and the units follow the GWA unit syntax; –\r\nrefer to the “GSA Keywords” document for details", - GH_ParamAccess.list); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaModelParameter()); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var m = new ComAuto(); - m.NewFile(); - string gwa = string.Empty; - var strings = new List(); - if (da.GetDataList(0, strings)) { - gwa = strings.Aggregate(gwa, (current, s) => current + s + "\n"); - } - - m.GwaCommand(gwa); - string temp = Path.GetTempPath() + Guid.NewGuid() + ".gwb"; - m.SaveAs(temp); - var gsaGh = new GsaModel(); - gsaGh.Model.Open(temp); - da.SetData(0, gsaGh); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/LoadProperties_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/LoadProperties_OBSOLETE.cs deleted file mode 100644 index a417c0c45..000000000 --- a/GsaGH/Components/GraveyardComp/LoadProperties_OBSOLETE.cs +++ /dev/null @@ -1,265 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; -using Rhino.Geometry; - -namespace GsaGH.Components { - public class LoadProperties_OBSOLETE : GH_OasysDropDownComponent { - public override Guid ComponentGuid => new Guid("0df96bee-3440-4699-b08d-d805220d1f68"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.LoadProperties; - private ForceUnit _forceUnit = DefaultUnits.ForceUnit; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - - public LoadProperties_OBSOLETE() : base("Load Properties", "LoadProp", "Get properties of a GSA Load", - CategoryName.Name(), SubCategoryName.Cat3()) { - Hidden = true; - } - - public override void SetSelected(int i, int j) { - _selectedItems[i] = _dropDownItems[i][j]; - switch (i) { - case 0: - _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), _selectedItems[0]); - break; - - case 1: - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[1]); - break; - } - - _selectedItems[1] = Length.GetAbbreviation(_lengthUnit); - base.UpdateUI(); - } - - public override void VariableParameterMaintenance() { - try { - string forceUnitAbbreviation = Force.GetAbbreviation(_forceUnit); - string forcePerLengthUnit - = ForcePerLength.GetAbbreviation( - UnitsHelper.GetForcePerLengthUnit(_forceUnit, _lengthUnit)); - string forcePerAreaUnit - = Pressure.GetAbbreviation(UnitsHelper.GetForcePerAreaUnit(_forceUnit, _lengthUnit)); - string unitAbbreviation = string.Join(", ", new { - forceUnitAbbreviation, - forcePerLengthUnit, - forcePerAreaUnit, - }); - - Params.Output[6].Name = "Load Value or Factor X [" + unitAbbreviation + "]"; - Params.Output[7].Name = "Load Value or Factor X [" + unitAbbreviation + "]"; - Params.Output[8].Name = "Load Value or Factor X [" + unitAbbreviation + "]"; - Params.Output[9].Name = "Load Value [" + unitAbbreviation + "]"; - } catch (Exception e) { - this.AddRuntimeError(e.Message); - } - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Force Unit", - "Length Unit", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Force)); - _dropDownItems[0].RemoveAt(_dropDownItems[0].Count - 1); - _selectedItems.Add(Force.GetAbbreviation(_forceUnit)); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaLoadParameter(), "Load", "Ld", "Load to get some info out of.", - GH_ParamAccess.item); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - string forceUnitAbbreviation = Force.GetAbbreviation(_forceUnit); - string lengthUnitAbbreviation = Length.GetAbbreviation(_lengthUnit); - string unitAbbreviation = forceUnitAbbreviation + "/" + lengthUnitAbbreviation; - - pManager.AddIntegerParameter("Load case", "LC", "Load case number", GH_ParamAccess.item); - pManager.AddTextParameter("Name", "Na", "Load name", GH_ParamAccess.item); - pManager.AddGenericParameter("Elements/Nodes/Definition", "Def", - "Element/Node list that load is applied to or Grid point / polygon definition", - GH_ParamAccess.item); - pManager.AddIntegerParameter("Axis", "Ax", "Axis Property (0 : Global // -1 : Local", - GH_ParamAccess.item); - pManager.AddTextParameter("Direction", "Di", "Load direction", GH_ParamAccess.item); - pManager.AddBooleanParameter("Projected", "Pj", "Projected", GH_ParamAccess.item); - pManager.AddGenericParameter( - "Load Value or Factor X [" + forceUnitAbbreviation + ", " + unitAbbreviation + "]", "V1", - "Value at Start, Point 1 or Factor X", GH_ParamAccess.item); - pManager.AddGenericParameter( - "Load Value or Factor Y [" + forceUnitAbbreviation + ", " + unitAbbreviation + "]", "V2", - "Value at End, Point 2 or Factor Y", GH_ParamAccess.item); - pManager.AddGenericParameter( - "Load Value or Factor Z [" + forceUnitAbbreviation + ", " + unitAbbreviation + "]", "V3", - "Value at Point 3 or Factor Z", GH_ParamAccess.item); - pManager.AddGenericParameter( - "Load Value [" + forceUnitAbbreviation + ", " + unitAbbreviation + "]", "V4", - "Value at Point 4", GH_ParamAccess.item); - pManager.AddGenericParameter("Grid Plane Surface", "GPS", "Grid Plane Surface", - GH_ParamAccess.item); - } - - protected override void SolveInternal(IGH_DataAccess da) { - ForcePerLengthUnit forcePerLengthUnit - = UnitsHelper.GetForcePerLengthUnit(_forceUnit, _lengthUnit); - PressureUnit forcePerAreaUnit = UnitsHelper.GetForcePerAreaUnit(_forceUnit, _lengthUnit); - - var ghTyp = new GH_ObjectWrapper(); - if (!da.GetData(0, ref ghTyp)) { - return; - } - - if (ghTyp.Value is GsaLoadGoo loadGoo) { - IGsaLoad gsaLoad = loadGoo.Value; - switch (gsaLoad) { - case GsaGravityLoad gravityLoad: - da.SetData(0, gravityLoad.ApiLoad.Case); - da.SetData(1, gravityLoad.ApiLoad.Name); - da.SetData(2, gravityLoad.ApiLoad.EntityList); - da.SetData(6, gravityLoad.ApiLoad.Factor.X); - da.SetData(7, gravityLoad.ApiLoad.Factor.Y); - da.SetData(8, gravityLoad.ApiLoad.Factor.Z); - return; - - case GsaNodeLoad nodeLoad: - da.SetData(0, nodeLoad.ApiLoad.Case); - da.SetData(1, nodeLoad.ApiLoad.Name); - da.SetData(2, nodeLoad.ApiLoad.Nodes); - da.SetData(3, nodeLoad.ApiLoad.AxisProperty); - da.SetData(4, nodeLoad.ApiLoad.Direction); - var apiNodeForce = new Force(nodeLoad.ApiLoad.Value, ForceUnit.Newton); - var outNodeForce = new Force(apiNodeForce.As(_forceUnit), _forceUnit); - da.SetData(6, new GH_UnitNumber(outNodeForce)); - return; - - case GsaBeamLoad beamLoad: - da.SetData(0, beamLoad.ApiLoad.Case); - da.SetData(1, beamLoad.ApiLoad.Name); - da.SetData(2, beamLoad.ApiLoad.EntityList); - da.SetData(3, beamLoad.ApiLoad.AxisProperty); - da.SetData(4, beamLoad.ApiLoad.Direction); - da.SetData(5, beamLoad.ApiLoad.IsProjected); - var apiBeamForce1 = new ForcePerLength(beamLoad.ApiLoad.Value(0), - ForcePerLengthUnit.NewtonPerMeter); - var outBeamForce1 - = new ForcePerLength(apiBeamForce1.As(forcePerLengthUnit), forcePerLengthUnit); - da.SetData(6, new GH_UnitNumber(outBeamForce1)); - var apiBeamForce2 = new ForcePerLength(beamLoad.ApiLoad.Value(1), - ForcePerLengthUnit.NewtonPerMeter); - var outBeamForce2 - = new ForcePerLength(apiBeamForce2.As(forcePerLengthUnit), forcePerLengthUnit); - da.SetData(7, new GH_UnitNumber(outBeamForce2)); - return; - - case GsaFaceLoad faceLoad: - da.SetData(0, faceLoad.ApiLoad.Case); - da.SetData(1, faceLoad.ApiLoad.Name); - da.SetData(2, faceLoad.ApiLoad.EntityList); - da.SetData(3, faceLoad.ApiLoad.AxisProperty); - da.SetData(4, faceLoad.ApiLoad.Direction); - da.SetData(5, faceLoad.ApiLoad.IsProjected); - var apiFaceForce1 = new Pressure(faceLoad.ApiLoad.Value(0), - PressureUnit.NewtonPerSquareMeter); - var outFaceForce1 = new Pressure(apiFaceForce1.As(forcePerAreaUnit), forcePerAreaUnit); - da.SetData(6, new GH_UnitNumber(outFaceForce1)); - var apiFaceForce2 = new Pressure(faceLoad.ApiLoad.Value(1), - PressureUnit.NewtonPerSquareMeter); - var outFaceForce2 = new Pressure(apiFaceForce2.As(forcePerAreaUnit), forcePerAreaUnit); - da.SetData(7, new GH_UnitNumber(outFaceForce2)); - var apiFaceForce3 = new Pressure(faceLoad.ApiLoad.Value(2), - PressureUnit.NewtonPerSquareMeter); - var outFaceForce3 = new Pressure(apiFaceForce3.As(forcePerAreaUnit), forcePerAreaUnit); - da.SetData(8, new GH_UnitNumber(outFaceForce3)); - var apiFaceForce4 = new Pressure(faceLoad.ApiLoad.Value(3), - PressureUnit.NewtonPerSquareMeter); - var outFaceForce4 = new Pressure(apiFaceForce4.As(forcePerAreaUnit), forcePerAreaUnit); - da.SetData(9, new GH_UnitNumber(outFaceForce4)); - return; - - case GsaGridPointLoad gridPointLoad: - da.SetData(0, gridPointLoad.ApiLoad.Case); - da.SetData(1, gridPointLoad.ApiLoad.Name); - da.SetData(2, new GH_Point(gridPointLoad.GetPoint(_lengthUnit))); - da.SetData(3, gridPointLoad.ApiLoad.AxisProperty); - da.SetData(4, gridPointLoad.ApiLoad.Direction); - var apiPointForce = new Force(gridPointLoad.ApiLoad.Value, ForceUnit.Newton); - var outPointForce = new Force(apiPointForce.As(_forceUnit), _forceUnit); - da.SetData(6, new GH_UnitNumber(outPointForce)); - da.SetData(10, new GsaGridPlaneSurfaceGoo(gridPointLoad.GridPlaneSurface)); - return; - - case GsaGridLineLoad gridLineLoad: - da.SetData(0, gridLineLoad.ApiLoad.Case); - da.SetData(1, gridLineLoad.ApiLoad.Name); - da.SetData(2, new Polyline(gridLineLoad.Points)); - da.SetData(3, gridLineLoad.ApiLoad.AxisProperty); - da.SetData(4, gridLineLoad.ApiLoad.Direction); - var apiLineForce1 = new ForcePerLength(gridLineLoad.ApiLoad.ValueAtStart, - ForcePerLengthUnit.NewtonPerMeter); - var outLineForce1 - = new ForcePerLength(apiLineForce1.As(forcePerLengthUnit), forcePerLengthUnit); - da.SetData(6, new GH_UnitNumber(outLineForce1)); - var apiLineForce2 = new ForcePerLength(gridLineLoad.ApiLoad.ValueAtEnd, - ForcePerLengthUnit.NewtonPerMeter); - var outLineForce2 - = new ForcePerLength(apiLineForce2.As(forcePerLengthUnit), forcePerLengthUnit); - da.SetData(7, new GH_UnitNumber(outLineForce2)); - da.SetData(10, new GsaGridPlaneSurfaceGoo(gridLineLoad.GridPlaneSurface)); - return; - - case GsaGridAreaLoad gridAreaLoad: - da.SetData(0, gridAreaLoad.ApiLoad.Case); - da.SetData(1, gridAreaLoad.ApiLoad.Name); - var polyline = new Polyline(gridAreaLoad.Points); - if (!polyline.IsClosed) { - var pts = gridAreaLoad.Points.ToList(); - pts.Add(pts[0]); - polyline = new Polyline(pts); - } - - da.SetData(2, polyline); - da.SetData(3, gridAreaLoad.ApiLoad.AxisProperty); - da.SetData(4, gridAreaLoad.ApiLoad.Direction); - var apiAreaForce = new Pressure(gridAreaLoad.ApiLoad.Value, - PressureUnit.NewtonPerSquareMeter); - var outAreaForce = new Pressure(apiAreaForce.As(forcePerAreaUnit), forcePerAreaUnit); - da.SetData(6, new GH_UnitNumber(outAreaForce)); - da.SetData(10, new GsaGridPlaneSurfaceGoo(gridAreaLoad.GridPlaneSurface)); - return; - } - } else { - this.AddRuntimeError("Error converting input to GSA Load"); - } - } - - protected override void UpdateUIFromSelectedItems() { - _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), _selectedItems[0]); - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[1]); - base.UpdateUIFromSelectedItems(); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/NodeContourResults_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/NodeContourResults_OBSOLETE.cs deleted file mode 100644 index 23767a273..000000000 --- a/GsaGH/Components/GraveyardComp/NodeContourResults_OBSOLETE.cs +++ /dev/null @@ -1,716 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Drawing; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper; -using Grasshopper.GUI.Gradient; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Data; -using Grasshopper.Kernel.Special; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.Graphics; -using GsaGH.Helpers.GsaApi; -using GsaGH.Helpers.Import; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Parameters; -using OasysGH.UI; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using Rhino.Display; -using Rhino.Geometry; -using AngleUnit = OasysUnits.Units.AngleUnit; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to display GSA node result contours - /// - // ReSharper disable once InconsistentNaming - public class NodeContourResults_OBSOLETE : GH_OasysDropDownComponent { - private enum DisplayValue { - X, - Y, - Z, - ResXyz, - Xx, - Yy, - Zz, - ResXxyyzz, - } - - private enum FoldMode { - Displacement, - Reaction, - } - - public override Guid ComponentGuid => new Guid("47053884-2c22-4f2c-b092-8531fa5751e1"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.ContourNodeResults; - private readonly List _displacement = new List(new[] { - "Translation Ux", - "Translation Uy", - "Translation Uz", - "Resolved |U|", - "Rotation Rxx", - "Rotation Ryy", - "Rotation Rzz", - "Resolved |R|", - }); - private readonly Bitmap _legend = new Bitmap(15, 120); - private readonly List _reaction = new List(new[] { - "Reaction Fx", - "Reaction Fy", - "Reaction Fz", - "Resolved |F|", - "Reaction Mxx", - "Reaction Myy", - "Reaction Mzz", - "Resolved |M|", - }); - private readonly List _type = new List(new[] { - "Displacement", - "Reaction", - }); - private string _case = string.Empty; - private double _defScale = 250; - private DisplayValue _disp = DisplayValue.ResXyz; - private List _legendValues; - private List _legendValuesPosY; - private LengthUnit _lengthResultUnit = DefaultUnits.LengthUnitResult; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - private double _maxValue = 1000; - private double _minValue; - private FoldMode _mode = FoldMode.Displacement; - private int _noDigits; - private string _resType; - private bool _showLegend = true; - private bool _slider = true; - - public NodeContourResults_OBSOLETE() : base("Node Contour Results", "ContourNode", - "Diplays GSA Node Results as Contours", CategoryName.Name(), SubCategoryName.Cat5()) { } - - public override void CreateAttributes() { - if (!_isInitialised) { - InitialiseDropdowns(); - } - - m_attributes = new DropDownSliderComponentAttributes(this, SetSelected, _dropDownItems, - _selectedItems, _slider, SetVal, SetMaxMin, _defScale, _maxValue, _minValue, _noDigits, - _spacerDescriptions); - } - - public override void DrawViewportWires(IGH_PreviewArgs args) { - base.DrawViewportWires(args); - if (!(_legendValues != null & _showLegend)) { - return; - } - - args.Display.DrawBitmap(new DisplayBitmap(_legend), args.Viewport.Bounds.Right - 110, 20); - for (int i = 0; i < _legendValues.Count; i++) { - args.Display.Draw2dText(_legendValues[i], Color.Black, - new Point2d(args.Viewport.Bounds.Right - 85, _legendValuesPosY[i]), false); - } - - args.Display.Draw2dText(_resType, Color.Black, - new Point2d(args.Viewport.Bounds.Right - 110, 7), false); - args.Display.Draw2dText(_case, Color.Black, - new Point2d(args.Viewport.Bounds.Right - 110, 145), false); - } - - public override bool Read(GH_IReader reader) { - _mode = (FoldMode)reader.GetInt32("Mode"); - _disp = (DisplayValue)reader.GetInt32("Display"); - _slider = reader.GetBoolean("slider"); - _noDigits = reader.GetInt32("noDec"); - _maxValue = reader.GetDouble("valMax"); - _minValue = reader.GetDouble("valMin"); - _defScale = reader.GetDouble("val"); - _showLegend = reader.GetBoolean("legend"); - return base.Read(reader); - } - - public void SetMaxMin(double max, double min) { - _maxValue = max; - _minValue = min; - } - - public override void SetSelected(int dropdownlistidd, int selectedidd) { - switch (dropdownlistidd) { - case 0: { - switch (selectedidd) { - case 0: { - if (_dropDownItems[1] != _displacement) { - _dropDownItems[1] = _displacement; - _selectedItems[0] = _dropDownItems[0][0]; - _selectedItems[1] = _dropDownItems[1][3]; - Mode1Clicked(); - } - - break; - } - case 1: { - if (_dropDownItems[1] != _reaction) { - _dropDownItems[1] = _reaction; - _selectedItems[0] = _dropDownItems[0][1]; - _selectedItems[1] = _dropDownItems[1][3]; - Mode2Clicked(); - } - - break; - } - } - - break; - } - case 1: - _disp = (DisplayValue)selectedidd; - _selectedItems[1] = _dropDownItems[1][selectedidd]; - break; - - default: - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[2]); - break; - } - - base.UpdateUI(); - } - - public void SetVal(double value) { - _defScale = value; - } - - public override void VariableParameterMaintenance() { - switch (_mode) { - case FoldMode.Displacement when (int)_disp < 4: { - IQuantity length = new Length(0, _lengthUnit); - string lengthunitAbbreviation = string.Concat(length.ToString().Where(char.IsLetter)); - Params.Output[2].Name = "Values [" + lengthunitAbbreviation + "]"; - break; - } - case FoldMode.Displacement: - Params.Output[2].Name = "Values [rad]"; - break; - - case FoldMode.Reaction when (int)_disp < 4: { - IQuantity force = new Force(0, DefaultUnits.ForceUnit); - string forceunitAbbreviation = string.Concat(force.ToString().Where(char.IsLetter)); - Params.Output[2].Name = "Values [" + forceunitAbbreviation + "]"; - break; - } - case FoldMode.Reaction: { - string momentunitAbbreviation = Moment.GetAbbreviation(DefaultUnits.MomentUnit); - Params.Output[2].Name = "Values [" + momentunitAbbreviation + "]"; - break; - } - } - } - - public override bool Write(GH_IWriter writer) { - writer.SetInt32("Mode", (int)_mode); - writer.SetInt32("Display", (int)_disp); - writer.SetBoolean("slider", _slider); - writer.SetInt32("noDec", _noDigits); - writer.SetDouble("valMax", _maxValue); - writer.SetDouble("valMin", _minValue); - writer.SetDouble("val", _defScale); - writer.SetBoolean("legend", _showLegend); - return base.Write(writer); - } - - protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - Menu_AppendItem(menu, "Show Legend", ShowLegend, true, _showLegend); - - var gradient = new GH_GradientControl(); - gradient.CreateAttributes(); - var extract = new ToolStripMenuItem("Extract Default Gradient", gradient.Icon_24x24, - (s, e) => CreateGradient()); - menu.Items.Add(extract); - Menu_AppendSeparator(menu); - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Result Type", - "Component", - "Geometry Unit", - "Deform Shape", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(_type); - _selectedItems.Add(_dropDownItems[0][0]); - - _dropDownItems.Add(_displacement); - _selectedItems.Add(_dropDownItems[1][3]); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); - _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaResultParameter(), "Result", "Res", "GSA Result", - GH_ParamAccess.item); - pManager.AddTextParameter("Node filter list", "No", - "Filter results by list." + Environment.NewLine + "Node list should take the form:" - + Environment.NewLine + " 1 11 to 72 step 2 not (XY3 31 to 45)" + Environment.NewLine - + "Refer to GSA help file for definition of lists and full vocabulary.", - GH_ParamAccess.item, "All"); - pManager.AddColourParameter("Colour", "Co", - "Optional list of colours to override default colours." + Environment.NewLine - + "A new gradient will be created from the input list of colours", GH_ParamAccess.list); - pManager.AddNumberParameter("Scalar", "x:X", "Scale the result display size", - GH_ParamAccess.item, 10); - pManager[1].Optional = true; - pManager[2].Optional = true; - pManager[3].Optional = true; - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - IQuantity length = new Length(0, _lengthResultUnit); - string lengthunitAbbreviation = string.Concat(length.ToString().Where(char.IsLetter)); - - pManager.AddGenericParameter("Point", "P", "Contoured Points with result values", - GH_ParamAccess.list); - pManager.AddGenericParameter("Colours", "LC", "Legend Colours", GH_ParamAccess.list); - pManager.AddGenericParameter("Values [" + lengthunitAbbreviation + "]", "LT", "Legend Values", - GH_ParamAccess.list); - } - - protected override void SolveInternal(IGH_DataAccess da) { - var result = new GsaResult(); - var ghTyp = new GH_ObjectWrapper(); - if (!da.GetData(0, ref ghTyp)) { - return; - } - - #region Inputs - - if (ghTyp.Value is GsaResultGoo goo) { - result = goo.Value; - switch (result.Type) { - case CaseType.CombinationCase when result.SelectedPermutationIds.Count > 1: - this.AddRuntimeWarning("Combination case contains " - + result.SelectedPermutationIds.Count - + " - only one permutation can be displayed at a time." + Environment.NewLine - + "Displaying first permutation; please use the 'Select Results' to select other single permutations"); - _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; - break; - - case CaseType.CombinationCase: - _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; - break; - - case CaseType.AnalysisCase: - _case = "Case A" + result.CaseId + Environment.NewLine + result.CaseName; - break; - } - } else { - this.AddRuntimeError("Error converting input to GSA Result"); - return; - } - - string nodeList = "All"; - var ghNoList = new GH_String(); - if (da.GetData(1, ref ghNoList)) { - if (GH_Convert.ToString(ghNoList, out string tempnodeList, GH_Conversion.Both)) { - nodeList = tempnodeList; - } - } - - var ghColours = new List(); - var colors = new List(); - if (da.GetDataList(2, ghColours)) { - foreach (GH_Colour t in ghColours) { - GH_Convert.ToColor(t, out Color color, GH_Conversion.Both); - colors.Add(color); - } - } - - GH_Gradient ghGradient = Colours.Stress_Gradient(colors); - - var ghScale = new GH_Number(); - da.GetData(3, ref ghScale); - GH_Convert.ToDouble(ghScale, out double scale, GH_Conversion.Both); - - #endregion - - var res = new GsaResultsValues(); - switch (_mode) { - case FoldMode.Displacement: - res = result.NodeDisplacementValues(nodeList, _lengthUnit)[0]; - break; - - case FoldMode.Reaction: - res = result.NodeReactionForceValues(nodeList, DefaultUnits.ForceUnit, - DefaultUnits.MomentUnit)[0]; - nodeList = string.Join(" ", res.Ids); - break; - } - - ReadOnlyDictionary nodes = result.Model.Model.Nodes(nodeList); - - ConcurrentDictionary> xyzResults - = res.XyzResults; - ConcurrentDictionary> xxyyzzResults - = res.XxyyzzResults; - - Enum xyzunit = _lengthUnit; - Enum xxyyzzunit = AngleUnit.Radian; - if (_mode == FoldMode.Reaction) { - xyzunit = DefaultUnits.ForceUnit; - xxyyzzunit = DefaultUnits.MomentUnit; - } - - double dmaxX = res.DmaxX.As(xyzunit); - double dmaxY = res.DmaxY.As(xyzunit); - double dmaxZ = res.DmaxZ.As(xyzunit); - double dmaxXyz = res.DmaxXyz.As(xyzunit); - double dminX = res.DminX.As(xyzunit); - double dminY = res.DminY.As(xyzunit); - double dminZ = res.DminZ.As(xyzunit); - double dminXyz = res.DminXyz.As(xyzunit); - double dmaxXx = res.DmaxXx.As(xxyyzzunit); - double dmaxYy = res.DmaxYy.As(xxyyzzunit); - double dmaxZz = res.DmaxZz.As(xxyyzzunit); - double dmaxXxyyzz = res.DmaxXxyyzz.As(xxyyzzunit); - double dminXx = res.DminXx.As(xxyyzzunit); - double dminYy = res.DminYy.As(xxyyzzunit); - double dminZz = res.DminZz.As(xxyyzzunit); - double dminXxyyzz = res.DminXxyyzz.As(xxyyzzunit); - - #region Result point values - - ConcurrentDictionary gsanodes = Nodes.GetNodeDictionary(nodes, _lengthUnit); - double dmax = 0; - double dmin = 0; - switch (_disp) { - case DisplayValue.X: - dmax = dmaxX; - dmin = dminX; - _resType = _mode == FoldMode.Displacement ? "Translation, Ux" : "Reaction Force, Fx"; - break; - - case DisplayValue.Y: - dmax = dmaxY; - dmin = dminY; - _resType = _mode == FoldMode.Displacement ? "Translation, Uy" : "Reaction Force, Fy"; - break; - - case DisplayValue.Z: - dmax = dmaxZ; - dmin = dminZ; - _resType = _mode == FoldMode.Displacement ? "Translation, Uz" : "Reaction Force, Fz"; - break; - - case DisplayValue.ResXyz: - dmax = dmaxXyz; - dmin = dminXyz; - _resType = _mode == FoldMode.Displacement ? "Res. Trans., |U|" : "Res. Rxn. Force, |F|"; - break; - - case DisplayValue.Xx: - dmax = dmaxXx; - dmin = dminXx; - _resType = _mode == FoldMode.Displacement ? "Rotation, Rxx" : "Reaction Moment, Mxx"; - break; - - case DisplayValue.Yy: - dmax = dmaxYy; - dmin = dminYy; - _resType = _mode == FoldMode.Displacement ? "Rotation, Ryy" : "Reaction Moment, Ryy"; - break; - - case DisplayValue.Zz: - dmax = dmaxZz; - dmin = dminZz; - _resType = _mode == FoldMode.Displacement ? "Rotation, Rzz" : "Reaction Moment, Rzz"; - break; - - case DisplayValue.ResXxyyzz: - dmax = dmaxXxyyzz; - dmin = dminXxyyzz; - _resType = _mode == FoldMode.Displacement ? "Res. Rot., |R|" : "Res. Rxn. Mom., |M|"; - break; - } - - List rounded = ResultHelper.SmartRounder(dmax, dmin); - dmax = rounded[0]; - dmin = rounded[1]; - int significantDigits = (int)rounded[2]; - - var pointResultGoos = new ConcurrentDictionary(); - - Parallel.ForEach(gsanodes, node => { - if (node.Value.Value == null) { - return; - } - - int nodeId = node.Value.Value.Id; - if (!xyzResults.ContainsKey(nodeId)) { - return; - } - - if (dmin == 0 & dmax == 0) { - return; - } - - var def = new Point3d(node.Value.Value.Point); - IQuantity t = null; - switch (_mode) { - case FoldMode.Displacement: - var translation = new Vector3d(0, 0, 0); - switch (_disp) { - case DisplayValue.X: - t = xyzResults[nodeId][0].X.ToUnit(_lengthUnit); - translation.X = t.Value * _defScale; - break; - - case DisplayValue.Y: - t = xyzResults[nodeId][0].Y.ToUnit(_lengthUnit); - translation.Y = t.Value * _defScale; - break; - - case DisplayValue.Z: - t = xyzResults[nodeId][0].Z.ToUnit(_lengthUnit); - translation.Z = t.Value * _defScale; - break; - - case DisplayValue.ResXyz: - t = xyzResults[nodeId][0].Xyz.ToUnit(_lengthUnit); - translation.X = xyzResults[nodeId][0].X.As(_lengthUnit) * _defScale; - translation.Y = xyzResults[nodeId][0].Y.As(_lengthUnit) * _defScale; - translation.Z = xyzResults[nodeId][0].Z.As(_lengthUnit) * _defScale; - break; - - case DisplayValue.Xx: - t = xxyyzzResults[nodeId][0].X.ToUnit(AngleUnit.Radian); - break; - - case DisplayValue.Yy: - t = xxyyzzResults[nodeId][0].Y.ToUnit(AngleUnit.Radian); - break; - - case DisplayValue.Zz: - t = xxyyzzResults[nodeId][0].Z.ToUnit(AngleUnit.Radian); - break; - - case DisplayValue.ResXxyyzz: - t = xxyyzzResults[nodeId][0].Xyz.ToUnit(AngleUnit.Radian); - break; - } - - def.Transform(Transform.Translation(translation)); - break; - - case FoldMode.Reaction: - switch (_disp) { - case DisplayValue.X: - t = xyzResults[nodeId][0].X.ToUnit(DefaultUnits.ForceUnit); - break; - - case DisplayValue.Y: - t = xyzResults[nodeId][0].Y.ToUnit(DefaultUnits.ForceUnit); - break; - - case DisplayValue.Z: - t = xyzResults[nodeId][0].Z.ToUnit(DefaultUnits.ForceUnit); - break; - - case DisplayValue.ResXyz: - t = xyzResults[nodeId][0].Xyz.ToUnit(DefaultUnits.ForceUnit); - break; - - case DisplayValue.Xx: - t = xxyyzzResults[nodeId][0].X.ToUnit(DefaultUnits.MomentUnit); - break; - - case DisplayValue.Yy: - t = xxyyzzResults[nodeId][0].Y.ToUnit(DefaultUnits.MomentUnit); - break; - - case DisplayValue.Zz: - t = xxyyzzResults[nodeId][0].Z.ToUnit(DefaultUnits.MomentUnit); - break; - - case DisplayValue.ResXxyyzz: - t = xxyyzzResults[nodeId][0].Xyz.ToUnit(DefaultUnits.MomentUnit); - break; - } - - break; - } - - double tnorm = (2 * (t.Value - dmin) / (dmax - dmin)) - 1; - Color valcol = ghGradient.ColourAt(tnorm); - float size = (t.Value >= 0 && dmax != 0) ? Math.Max(2, (float)(t.Value / dmax * scale)) : - Math.Max(2, (float)(Math.Abs(t.Value) / Math.Abs(dmin) * scale)); - - pointResultGoos[nodeId] = new PointResultGoo(def, t, valcol, size, nodeId); - }); - - #endregion - - #region Legend - - int gripheight = _legend.Height / ghGradient.GripCount; - _legendValues = new List(); - _legendValuesPosY = new List(); - - var ts = new List(); - var cs = new List(); - - for (int i = 0; i < ghGradient.GripCount; i++) { - double t = dmin + ((dmax - dmin) / ((double)ghGradient.GripCount - 1) * i); - t = ResultHelper.RoundToSignificantDigits(t, significantDigits); - - Color gradientcolour - = ghGradient.ColourAt((2 * (double)i / ((double)ghGradient.GripCount - 1)) - 1); - cs.Add(gradientcolour); - - int starty = i * gripheight; - int endy = starty + gripheight; - for (int y = starty; y < endy; y++) { - for (int x = 0; x < _legend.Width; x++) { - _legend.SetPixel(x, _legend.Height - y - 1, gradientcolour); - } - } - - switch (_mode) { - case FoldMode.Displacement when (int)_disp < 4: { - Length displacement = new Length(t, _lengthUnit).ToUnit(_lengthResultUnit); - _legendValues.Add(displacement.ToString("f" + significantDigits)); - ts.Add(new GH_UnitNumber(displacement)); - break; - } - case FoldMode.Displacement: { - var rotation = new Angle(t, AngleUnit.Radian); - _legendValues.Add(rotation.ToString("s" + significantDigits)); - ts.Add(new GH_UnitNumber(rotation)); - break; - } - case FoldMode.Reaction when (int)_disp < 4: { - var reactionForce = new Force(t, DefaultUnits.ForceUnit); - _legendValues.Add(reactionForce.ToString("s" + significantDigits)); - ts.Add(new GH_UnitNumber(reactionForce)); - break; - } - case FoldMode.Reaction: { - var reactionMoment = new Moment(t, DefaultUnits.MomentUnit); - _legendValues.Add(t.ToString("F" + significantDigits) + " " - + Moment.GetAbbreviation(DefaultUnits.MomentUnit)); - ts.Add(new GH_UnitNumber(reactionMoment)); - break; - } - } - - if (Math.Abs(t) > 1) { - _legendValues[i] = _legendValues[i] - .Replace(",", string.Empty); // remove thousand separator - } - - _legendValuesPosY.Add(_legend.Height - starty + (gripheight / 2) - 2); - } - - #endregion - - da.SetDataList(0, pointResultGoos.OrderBy(x => x.Key).Select(y => y.Value).ToList()); - da.SetDataList(1, cs); - da.SetDataList(2, ts); - } - - protected override void UpdateUIFromSelectedItems() { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[2]); - base.UpdateUIFromSelectedItems(); - } - - private void CreateGradient() { - var gradient = new GH_GradientControl(); - gradient.CreateAttributes(); - - gradient.Gradient = Colours.Stress_Gradient(null); - gradient.Gradient.NormalizeGrips(); - gradient.Params.Input[0].AddVolatileData(new GH_Path(0), 0, -1); - gradient.Params.Input[1].AddVolatileData(new GH_Path(0), 0, 1); - gradient.Params.Input[2].AddVolatileDataList(new GH_Path(0), new List() { - -1, - -0.666, - -0.333, - 0, - 0.333, - 0.666, - 1, - }); - - gradient.Attributes.Pivot = new PointF( - Attributes.Bounds.X - gradient.Attributes.Bounds.Width - 50, - Params.Input[2].Attributes.Bounds.Y - (gradient.Attributes.Bounds.Height / 4) - 6); - - Instances.ActiveCanvas.Document.AddObject(gradient, false); - Params.Input[2].RemoveAllSources(); - Params.Input[2].AddSource(gradient.Params.Output[0]); - - UpdateUI(); - } - - private void Mode1Clicked() { - if (_mode == FoldMode.Displacement) { - return; - } - - RecordUndoEvent(_mode + " Parameters"); - _mode = FoldMode.Displacement; - - _slider = true; - _defScale = 100; - - ReDrawComponent(); - } - - private void Mode2Clicked() { - if (_mode == FoldMode.Reaction) { - return; - } - - RecordUndoEvent(_mode + " Parameters"); - _mode = FoldMode.Reaction; - _slider = false; - _defScale = 0; - - ReDrawComponent(); - } - - private void ReDrawComponent() { - var pivot = new PointF(Attributes.Pivot.X, Attributes.Pivot.Y); - CreateAttributes(); - Attributes.Pivot = pivot; - Attributes.ExpireLayout(); - Attributes.PerformLayout(); - } - - private void ShowLegend(object sender, EventArgs e) { - _showLegend = !_showLegend; - ExpirePreview(true); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/ProfileHelper.cs b/GsaGH/Components/GraveyardComp/ProfileHelper.cs deleted file mode 100644 index aacc527e9..000000000 --- a/GsaGH/Components/GraveyardComp/ProfileHelper.cs +++ /dev/null @@ -1,268 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel; -using Rhino.Geometry; - -namespace GsaGH.Graveyard { - /// - /// Helper class for Profile/Section conversions - /// - public class ConvertSection { - - /// - /// Method to convert a GsaProfile to a string that can be read by GSA - /// (in GsaAPI.Section.Profile or GsaGH.Parameters.GsaSection.Section.Profile) - /// NOTE: - /// - Does not cover all profile types available in GSA (but all available in GsaProfile) - /// - Geometric can handle custom profiles with voids. Origin/anchor to be implemented. - /// - Catalogue profiles yet to be implemented - /// - /// - /// - public static string ProfileConversion(ProfileHelper gsaProfile) { - switch (gsaProfile.ProfileType) { - case ProfileHelper.ProfileTypes.Standard: { - string unit = " "; - - switch (gsaProfile.SectUnit) { - case ProfileHelper.SectUnitOptions.UCm: - unit = "(cm) "; - break; - - case ProfileHelper.SectUnitOptions.Um: - unit = "(m) "; - break; - - case ProfileHelper.SectUnitOptions.UIn: - unit = "(in) "; - break; - - case ProfileHelper.SectUnitOptions.UFt: - unit = "(ft) "; - break; - } - - switch (gsaProfile.StdShape) { - case ProfileHelper.StdShapeOptions.Rectangle when gsaProfile.IsTapered: - return "STD TR" + unit + gsaProfile.D.ToString("0.############") + " " - + gsaProfile.B1.ToString("0.############") + " " - + gsaProfile.B2.ToString("0.############"); - - case ProfileHelper.StdShapeOptions.Rectangle when gsaProfile.IsHollow: - return "STD RHS" + unit + gsaProfile.D.ToString("0.############") + " " - + gsaProfile.B1.ToString("0.############") + " " - + gsaProfile.Tw1.ToString("0.############") + " " - + gsaProfile.Tf1.ToString("0.############"); - - case ProfileHelper.StdShapeOptions.Rectangle: - return "STD R" + unit + gsaProfile.D.ToString("0.############") + " " - + gsaProfile.B1.ToString("0.############"); - - case ProfileHelper.StdShapeOptions.Circle when gsaProfile.IsHollow: { - return gsaProfile.IsElliptical ? - "STD OVAL" + unit + gsaProfile.D.ToString("0.############") + " " - + gsaProfile.B1.ToString("0.############") + " " - + gsaProfile.Tw1.ToString("0.############") : "STD CHS" + unit - + gsaProfile.D.ToString("0.############") + " " - + gsaProfile.Tw1.ToString("0.############"); - } - case ProfileHelper.StdShapeOptions.Circle when gsaProfile.IsElliptical: - return "STD E" + unit + gsaProfile.D.ToString("0.############") + " " - + gsaProfile.B1.ToString("0.############") + " 2"; - - case ProfileHelper.StdShapeOptions.Circle: - return "STD C" + unit + gsaProfile.D.ToString("0.############"); - - case ProfileHelper.StdShapeOptions.Section when gsaProfile.IsGeneral: { - return gsaProfile.IsTapered ? - "STD TI" + unit + gsaProfile.D.ToString("0.############") + " " - + gsaProfile.B1.ToString("0.############") + " " - + gsaProfile.B2.ToString("0.############") + " " - + gsaProfile.Tw1.ToString("0.############") + " " - + gsaProfile.Tw2.ToString("0.############") + " " - + gsaProfile.Tf1.ToString("0.############") + " " - + gsaProfile.Tf2.ToString("0.############") : "STD GI" + unit - + gsaProfile.D.ToString("0.############") + " " - + gsaProfile.B1.ToString("0.############") + " " - + gsaProfile.B2.ToString("0.############") + " " - + gsaProfile.Tw1.ToString("0.############") + " " - + gsaProfile.Tf1.ToString("0.############") + " " - + gsaProfile.Tf2.ToString("0.############"); - } - case ProfileHelper.StdShapeOptions.Section: - return "STD I" + unit + gsaProfile.D.ToString("0.############") + " " - + gsaProfile.B1.ToString("0.############") + " " - + gsaProfile.Tw1.ToString("0.############") + " " - + gsaProfile.Tf1.ToString("0.############"); - - case ProfileHelper.StdShapeOptions.Tee when gsaProfile.IsTapered: - return "STD TT" + unit + gsaProfile.D.ToString("0.############") + " " - + gsaProfile.B1.ToString("0.############") + " " - + gsaProfile.Tw1.ToString("0.############") + " " - + gsaProfile.Tw2.ToString("0.############") + " " - + gsaProfile.Tf1.ToString("0.############"); - - case ProfileHelper.StdShapeOptions.Tee: - return "STD T" + unit + gsaProfile.D.ToString("0.############") + " " - + gsaProfile.B1.ToString("0.############") + " " - + gsaProfile.Tw1.ToString("0.############") + " " - + gsaProfile.Tf1.ToString("0.############"); - - case ProfileHelper.StdShapeOptions.Channel when gsaProfile.IsB2B: - return "STD DCH" + unit + gsaProfile.D.ToString("0.############") + " " - + gsaProfile.B1.ToString("0.############") + " " - + gsaProfile.Tw1.ToString("0.############") + " " - + gsaProfile.Tf1.ToString("0.############"); - - case ProfileHelper.StdShapeOptions.Channel: - return "STD CH" + unit + gsaProfile.D.ToString("0.############") + " " - + gsaProfile.B1.ToString("0.############") + " " - + gsaProfile.Tw1.ToString("0.############") + " " - + gsaProfile.Tf1.ToString("0.############"); - - case ProfileHelper.StdShapeOptions.Angle when gsaProfile.IsB2B: - return "STD D" + unit + gsaProfile.D.ToString("0.############") + " " - + gsaProfile.B1.ToString("0.############") + " " - + gsaProfile.Tw1.ToString("0.############") + " " - + gsaProfile.Tf1.ToString("0.############"); - - case ProfileHelper.StdShapeOptions.Angle: - return "STD A" + unit + gsaProfile.D.ToString("0.############") + " " - + gsaProfile.B1.ToString("0.############") + " " - + gsaProfile.Tw1.ToString("0.############") + " " - + gsaProfile.Tf1.ToString("0.############"); - - default: return "STD something else"; - } - } - case ProfileHelper.ProfileTypes.Catalogue: { - string outputSectionString = string.Empty; - - if (gsaProfile.CatalogueProfileName != null) { - outputSectionString = gsaProfile.CatalogueProfileName; - } - - return $"CAT {outputSectionString}"; - } - case ProfileHelper.ProfileTypes.Geometric - when gsaProfile.GeoType == ProfileHelper.GeoTypes.Perim: { - string unit = string.Empty; - - switch (gsaProfile.SectUnit) { - case ProfileHelper.SectUnitOptions.UMm: - unit = "(mm)"; - break; - - case ProfileHelper.SectUnitOptions.UCm: - unit = "(cm)"; - break; - - case ProfileHelper.SectUnitOptions.Um: - unit = "(m)"; - break; - - case ProfileHelper.SectUnitOptions.UIn: - unit = "(in)"; - break; - - case ProfileHelper.SectUnitOptions.UFt: - unit = "(ft)"; - break; - } - - string profile = "GEO P" + unit; - int iPoint = 0; - foreach (Point2d point in gsaProfile.PerimeterPoints) { - if (iPoint > 0) { - profile += " L"; - } else { - profile += " M"; - } - - profile += "(" + point.X + "|" + point.Y + ")"; - iPoint++; - } - - if (gsaProfile.VoidPoints == null || !(gsaProfile.VoidPoints.Count > 0)) { - return profile; - } - - { - foreach (List voidPoint in gsaProfile.VoidPoints) { - iPoint = 0; - foreach (Point2d point in voidPoint) { - if (iPoint > 0) { - profile += " L"; - } else { - profile += " M"; - } - - profile += "(" + point.X + "|" + point.Y + ")"; - iPoint++; - } - } - } - - return profile; - } - case ProfileHelper.ProfileTypes.Geometric: return "GEO"; - - default: return null; - } - } - } - - /// - /// Profile class holds information about a profile - /// : Standard, Catalogue or Geometric - /// ShapeOptions for Standard type - /// Section units - /// - public class ProfileHelper { - public enum GeoTypes { - [Description("Perimeter")] Perim, - } - - public enum ProfileTypes { - [Description("Standard")] Standard, - [Description("Catalogue")] Catalogue, - [Description("Geometric")] Geometric, - } - - public enum SectUnitOptions { - [Description("mm")] UMm, - [Description("cm")] UCm, - [Description("m")] Um, - [Description("ft")] UFt, - [Description("in")] UIn, - } - - public enum StdShapeOptions { - [Description("Rectangle")] Rectangle, - [Description("Circle")] Circle, - [Description("Section")] Section, - [Description("Tee")] Tee, - [Description("Channel")] Channel, - [Description("Angle")] Angle, - } - - public double B1; - public double B2; - public string CatalogueProfileName = string.Empty; - public double D; - public GeoTypes GeoType; - public bool IsB2B; - public bool IsElliptical; - public bool IsGeneral; - public bool IsHollow; - public bool IsTapered; - public List PerimeterPoints; - public ProfileTypes ProfileType; - public SectUnitOptions SectUnit = SectUnitOptions.UMm; - public StdShapeOptions StdShape; - public double Tf1; - public double Tf2; - public double Tw1; - public double Tw2; - public List> VoidPoints; - } -} diff --git a/GsaGH/Components/GraveyardComp/ReactionForceDiagrams2_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/ReactionForceDiagrams2_OBSOLETE.cs deleted file mode 100644 index 74112283f..000000000 --- a/GsaGH/Components/GraveyardComp/ReactionForceDiagrams2_OBSOLETE.cs +++ /dev/null @@ -1,425 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Drawing; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.Graphics; -using GsaGH.Helpers.Import; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.UI; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; -using Rhino.Collections; -using Rhino.Geometry; -using ForceUnit = OasysUnits.Units.ForceUnit; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to display GSA reaction forces - /// - public class ReactionForceDiagrams2_OBSOLETE : GH_OasysDropDownComponent { - private enum DisplayValue { - X, - Y, - Z, - ResXyz, - Xx, - Yy, - Zz, - ResXxyyzz, - } - - public override Guid ComponentGuid => new Guid("3f359541-342e-4323-be43-d12c4708f2e5"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.ReactionForceDiagrams; - private readonly List _reactionStringList = new List(new[] { - "Reaction Fx", - "Reaction Fy", - "Reaction Fz", - "Resolved |F|", - "Reaction Mxx", - "Reaction Myy", - "Reaction Mzz", - "Resolved |M|", - }); - private ForceUnit _forceUnit = DefaultUnits.ForceUnit; - private LengthUnit _lengthResultUnit = DefaultUnits.LengthUnitResult; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - private MomentUnit _momentUnit = DefaultUnits.MomentUnit; - private ConcurrentDictionary _reactionForceVectors - = new ConcurrentDictionary(); - private DisplayValue _selectedDisplayValue = DisplayValue.ResXyz; - private bool _showText = true; - - public ReactionForceDiagrams2_OBSOLETE() : base("Reaction Force Diagrams", "ReactionForce", - "Diplays GSA Node Reaction Force Results as Vector Diagrams", CategoryName.Name(), - SubCategoryName.Cat5()) { } - - public override void CreateAttributes() { - if (!_isInitialised) { - InitialiseDropdowns(); - } - - m_attributes = new DropDownComponentAttributes(this, SetSelected, _dropDownItems, - _selectedItems, _spacerDescriptions); - } - - public override bool Read(GH_IReader reader) { - _selectedDisplayValue = (DisplayValue)reader.GetInt32("Display"); - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("model")); - _lengthResultUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("length")); - _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), reader.GetString("force")); - _momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), reader.GetString("moment")); - return base.Read(reader); - } - - public override void SetSelected(int i, int j) { - _selectedDisplayValue = (DisplayValue)j; - _selectedItems[i] = _dropDownItems[i][j]; - base.UpdateUI(); - } - - public override bool Write(GH_IWriter writer) { - writer.SetInt32("Display", (int)_selectedDisplayValue); - writer.SetString("model", Length.GetAbbreviation(_lengthUnit)); - writer.SetString("length", Length.GetAbbreviation(_lengthResultUnit)); - writer.SetString("force", Force.GetAbbreviation(_forceUnit)); - writer.SetString("moment", Moment.GetAbbreviation(_momentUnit)); - return base.Write(writer); - } - - protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - Menu_AppendItem(menu, "Show Text", ShowText, true, _showText); - - var unitsMenu = new ToolStripMenuItem("Select Units", Resources.ModelUnits); - ToolStripMenuItem forceUnitsMenu = GenerateToolStripMenuItem.GetSubMenuItem("Force", - EngineeringUnits.Force, Force.GetAbbreviation(_forceUnit), UpdateForce); - ToolStripMenuItem momentUnitsMenu = GenerateToolStripMenuItem.GetSubMenuItem("Moment", - EngineeringUnits.Moment, Moment.GetAbbreviation(_momentUnit), UpdateMoment); - - var toolStripItems = new List { - forceUnitsMenu, - momentUnitsMenu, - }; - - if (_lengthUnit == LengthUnit.Undefined) { - ToolStripMenuItem modelUnitsMenu = GenerateToolStripMenuItem.GetSubMenuItem( - "Model geometry", EngineeringUnits.Length, Length.GetAbbreviation(_lengthUnit), - UpdateModel); - } - - unitsMenu.DropDownItems.AddRange(toolStripItems.ToArray()); - unitsMenu.ImageScaling = ToolStripItemImageScaling.SizeToFit; - - menu.Items.Add(unitsMenu); - Menu_AppendSeparator(menu); - } - - protected override void BeforeSolveInstance() { - Message = (int)_selectedDisplayValue < 4 ? Force.GetAbbreviation(_forceUnit) : - Moment.GetAbbreviation(_momentUnit); - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Component", - }); - - _dropDownItems = new List> { - _reactionStringList, - }; - _selectedItems = new List { - _dropDownItems[0][3], - }; - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaResultParameter(), "Result", "Res", "GSA Result", - GH_ParamAccess.item); - pManager.AddGenericParameter("Node filter list", "No", - "Filter results by list (by default 'all')" + Environment.NewLine - + "Input a GSA List or a text string taking the form:" + Environment.NewLine - + " 1 11 to 72 step 2 not (XY3 31 to 45)" + Environment.NewLine - + "Refer to GSA help file for definition of lists and full vocabulary.", - GH_ParamAccess.item); - pManager.AddColourParameter("Colour", "Co", "[Optional] Colour to override default colour", - GH_ParamAccess.item); - pManager.AddNumberParameter("Scalar", "x:X", - "Scale the result vectors to a specific size. If left empty, automatic scaling based on model size and maximum result by load cases will be computed.", - GH_ParamAccess.item); - - for (int i = 1; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddPointParameter("Anchor Point", "A", "Support Node Location", GH_ParamAccess.list); - pManager.AddGenericParameter("Vector", "V", "Reaction Force Vector", GH_ParamAccess.list); - pManager.AddGenericParameter("Value", "Val", "Reaction Force Value", GH_ParamAccess.list); - pManager.HideParameter(0); - } - - protected override void SolveInternal(IGH_DataAccess da) { - this.AddRuntimeError("Reaction Force results are now in Global axis - please update your script accordingly!"); - var result = new GsaResult(); - var ghObject = new GH_ObjectWrapper(); - - if (!da.GetData(0, ref ghObject) || !IsGhObjectValid(ghObject)) { - return; - } - - result = (ghObject.Value as GsaResultGoo).Value; - string nodeList = Inputs.GetNodeListDefinition(this, da, 1, result.Model); - - GsaResultsValues forceValues - = result.NodeReactionForceValues(nodeList, _forceUnit, _momentUnit)[0]; - nodeList = string.Join(" ", forceValues.Ids); - - LengthUnit lengthUnit = GetLengthUnit(result); - - ReadOnlyDictionary gsaFilteredNodes = result.Model.Model.Nodes(nodeList); - ConcurrentDictionary nodes = Nodes.GetNodeDictionary(gsaFilteredNodes, - lengthUnit, result.Model.Model.Axes()); - - double scale = 1; - if (!da.GetData(3, ref scale)) { - scale = ComputeAutoScale(forceValues, result.Model.BoundingBox); - } - - Color color = Color.Empty; - da.GetData(2, ref color); - - _reactionForceVectors - = new ConcurrentDictionary(); - Parallel.ForEach(nodes, node => { - (GsaVectorDiagram reactionForceVector, GsaAnnotationGoo annotation, IQuantity forceValue) - = CreateReactionForceVector(node, forceValues, scale, color); - if (reactionForceVector != null) { - _reactionForceVectors.TryAdd(node.Key, (reactionForceVector, annotation, forceValue)); - } - }); - - SetOutputs(da); - PostHog.Result(result.Type, 0, GsaResultsValues.ResultType.Force, - _selectedDisplayValue.ToString()); - } - - private double ComputeAutoScale(GsaResultsValues forceValues, BoundingBox bbox) { - double maxValue = 0; - switch (_selectedDisplayValue) { - case DisplayValue.X: - maxValue = Math.Max(forceValues.DmaxX.As(_forceUnit), - Math.Abs(forceValues.DminX.As(_forceUnit))); - break; - case DisplayValue.Y: - maxValue = Math.Max(forceValues.DmaxY.As(_forceUnit), - Math.Abs(forceValues.DminY.As(_forceUnit))); - break; - case DisplayValue.Z: - maxValue = Math.Max(forceValues.DmaxZ.As(_forceUnit), - Math.Abs(forceValues.DminZ.As(_forceUnit))); - break; - case DisplayValue.ResXyz: - maxValue = Math.Max(forceValues.DmaxXyz.As(_forceUnit), - Math.Abs(forceValues.DminXyz.As(_forceUnit))); - break; - - case DisplayValue.Xx: - maxValue = Math.Max(forceValues.DmaxXx.As(_momentUnit), - Math.Abs(forceValues.DminXx.As(_momentUnit))); - break; - case DisplayValue.Yy: - maxValue = Math.Max(forceValues.DmaxYy.As(_momentUnit), - Math.Abs(forceValues.DminYy.As(_momentUnit))); - break; - case DisplayValue.Zz: - maxValue = Math.Max(forceValues.DmaxZz.As(_momentUnit), - Math.Abs(forceValues.DminZz.As(_momentUnit))); - break; - case DisplayValue.ResXxyyzz: - maxValue = Math.Max(forceValues.DmaxXxyyzz.As(_momentUnit), - Math.Abs(forceValues.DminXxyyzz.As(_momentUnit))); - break; - } - - double factor = 0.1; // maxVector = 10% of bbox diagonal - return bbox.Diagonal.Length * factor / maxValue; - } - - private (GsaVectorDiagram diagram, GsaAnnotationGoo annotation, IQuantity forceValue) - CreateReactionForceVector( - KeyValuePair node, GsaResultsValues forceValues, double scale, Color color) { - int nodeId = node.Key; - ConcurrentDictionary> xyzResults - = forceValues.XyzResults; - ConcurrentDictionary> xxyyzzResults - = forceValues.XxyyzzResults; - - if (!xyzResults.ContainsKey(nodeId)) { - return (null, null, null); - } - - bool isForce = (int)_selectedDisplayValue < 4; - GsaResultQuantity quantity; - Enum unit; - - if (isForce) { - quantity = xyzResults[nodeId][0]; - unit = _forceUnit; - } else { - quantity = xxyyzzResults[nodeId][0]; - unit = _momentUnit; - } - - var direction = new Vector3d(); - IQuantity forceValue = null; - - Vector3d xAxis = node.Value.Value.IsGlobalAxis ? Vector3d.XAxis : - node.Value.Value.LocalAxis.XAxis; - xAxis.Unitize(); - Vector3d yAxis = node.Value.Value.IsGlobalAxis ? Vector3d.YAxis : - node.Value.Value.LocalAxis.YAxis; - yAxis.Unitize(); - Vector3d zAxis = node.Value.Value.IsGlobalAxis ? Vector3d.ZAxis : - node.Value.Value.LocalAxis.ZAxis; - zAxis.Unitize(); - - xAxis *= quantity.X.As(unit) * scale; - yAxis *= quantity.Y.As(unit) * scale; - zAxis *= quantity.Z.As(unit) * scale; - - switch (_selectedDisplayValue) { - case DisplayValue.X: - case DisplayValue.Xx: - direction = xAxis; - forceValue = quantity.X.ToUnit(unit); - break; - - case DisplayValue.Y: - case DisplayValue.Yy: - direction = yAxis; - forceValue = quantity.Y.ToUnit(unit); - break; - - case DisplayValue.Z: - case DisplayValue.Zz: - direction = zAxis; - forceValue = quantity.Z.ToUnit(unit); - break; - - case DisplayValue.ResXyz: - case DisplayValue.ResXxyyzz: - direction = xAxis + yAxis + zAxis; - forceValue = quantity.Xyz.ToUnit(unit); - break; - } - - var vectorResult = new GsaVectorDiagram(node.Value.Value.Point, direction, !isForce, color); - - var pt = new Point3d(node.Value.Value.Point); - var move = Transform.Translation(direction); - pt.Transform(move); - Color col = isForce ? Colours.GsaDarkPurple : Colours.GsaGold; - - var annotation = new GsaAnnotationGoo(new GsaAnnotationDot(pt, col, forceValue.ToString())); - return (vectorResult, annotation, forceValue); - } - - private LengthUnit GetLengthUnit(GsaResult gsaResult) { - LengthUnit lengthUnit = gsaResult.Model.ModelUnit; - bool isUndefined = lengthUnit == LengthUnit.Undefined; - - if (!isUndefined) { - return lengthUnit; - } - - lengthUnit = _lengthUnit; - this.AddRuntimeRemark("Model came straight out of GSA and we couldn't read the units. " - + "The geometry has been scaled to be in " + lengthUnit.ToString() - + ". This can be changed by right-clicking the component -> 'Select Units'"); - - return lengthUnit; - } - - private bool IsGhObjectValid(GH_ObjectWrapper ghObject) { - bool valid = false; - if (ghObject == null || ghObject.Value == null) { - this.AddRuntimeWarning("Input is null"); - } else if (!(ghObject.Value is GsaResultGoo)) { - this.AddRuntimeError("Error converting input to GSA Result"); - } else { - valid = true; - } - - return valid; - } - - private void SetOutputs(IGH_DataAccess dataAccess) { - IOrderedEnumerable> orderedDict - = _reactionForceVectors.OrderBy(index => index.Key); - var startingPoints = new Point3dList(); - var vectors = new List(); - var forceValues = new List(); - - foreach (KeyValuePair - keyValuePair in orderedDict) { - startingPoints.Add(keyValuePair.Value.diagram.AnchorPoint); - vectors.Add(keyValuePair.Value.diagram); - forceValues.Add(keyValuePair.Value.force); - } - - dataAccess.SetDataList(0, startingPoints); - dataAccess.SetDataList(1, vectors); - dataAccess.SetDataList(2, forceValues); - } - - private void ShowText(object sender, EventArgs e) { - _showText = !_showText; - ExpirePreview(true); - base.UpdateUI(); - } - - private void UpdateForce(string unit) { - _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), unit); - ExpirePreview(true); - base.UpdateUI(); - } - - private void UpdateModel(string unit) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), unit); - ExpirePreview(true); - base.UpdateUI(); - } - - private void UpdateMoment(string unit) { - _momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), unit); - ExpirePreview(true); - base.UpdateUI(); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/ReactionForceDiagrams_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/ReactionForceDiagrams_OBSOLETE.cs deleted file mode 100644 index 0fc0cc2c3..000000000 --- a/GsaGH/Components/GraveyardComp/ReactionForceDiagrams_OBSOLETE.cs +++ /dev/null @@ -1,408 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Drawing; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; -using GH_IO.Serialization; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers; -using GsaGH.Helpers.GH; -using GsaGH.Helpers.Import; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.UI; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; -using Rhino.Collections; -using Rhino.Geometry; -using ForceUnit = OasysUnits.Units.ForceUnit; -using LengthUnit = OasysUnits.Units.LengthUnit; - -namespace GsaGH.Components { - /// - /// Component to display GSA reaction forces - /// - public class ReactionForceDiagrams_OBSOLETE : GH_OasysDropDownComponent { - private enum DisplayValue { - X, - Y, - Z, - ResXyz, - Xx, - Yy, - Zz, - ResXxyyzz, - } - - public override Guid ComponentGuid => new Guid("5bc139e5-614b-4f2d-887c-a980f1cbb32c"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.ReactionForceDiagrams; - private readonly List _reactionStringList = new List(new[] { - "Reaction Fx", - "Reaction Fy", - "Reaction Fz", - "Resolved |F|", - "Reaction Mxx", - "Reaction Myy", - "Reaction Mzz", - "Resolved |M|", - }); - private ForceUnit _forceUnit = DefaultUnits.ForceUnit; - private LengthUnit _lengthResultUnit = DefaultUnits.LengthUnitResult; - private LengthUnit _lengthUnit = DefaultUnits.LengthUnitGeometry; - private MomentUnit _momentUnit = DefaultUnits.MomentUnit; - private ConcurrentDictionary _reactionForceVectors - = new ConcurrentDictionary(); - - private DisplayValue _selectedDisplayValue = DisplayValue.ResXyz; - private bool _showText = true; - - public ReactionForceDiagrams_OBSOLETE() : base("Reaction Force Diagrams", "ReactionForce", - "Diplays GSA Node Reaction Force Results as Vector Diagrams", CategoryName.Name(), - SubCategoryName.Cat5()) { } - - public override void CreateAttributes() { - if (!_isInitialised) { - InitialiseDropdowns(); - } - - m_attributes = new DropDownComponentAttributes(this, SetSelected, _dropDownItems, - _selectedItems, _spacerDescriptions); - } - - public override bool Read(GH_IReader reader) { - _selectedDisplayValue = (DisplayValue)reader.GetInt32("Display"); - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("model")); - _lengthResultUnit - = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), reader.GetString("length")); - _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), reader.GetString("force")); - _momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), reader.GetString("moment")); - return base.Read(reader); - } - - public override void SetSelected(int i, int j) { - _selectedDisplayValue = (DisplayValue)j; - _selectedItems[i] = _dropDownItems[i][j]; - base.UpdateUI(); - } - - public override bool Write(GH_IWriter writer) { - writer.SetInt32("Display", (int)_selectedDisplayValue); - writer.SetString("model", Length.GetAbbreviation(_lengthUnit)); - writer.SetString("length", Length.GetAbbreviation(_lengthResultUnit)); - writer.SetString("force", Force.GetAbbreviation(_forceUnit)); - writer.SetString("moment", Moment.GetAbbreviation(_momentUnit)); - return base.Write(writer); - } - - protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu) { - if (!(menu is ContextMenuStrip)) { - return; // this method is also called when clicking EWR balloon - } - - Menu_AppendSeparator(menu); - Menu_AppendItem(menu, "Show Text", ShowText, true, _showText); - - var unitsMenu = new ToolStripMenuItem("Select Units", Resources.ModelUnits); - ToolStripMenuItem forceUnitsMenu = GenerateToolStripMenuItem.GetSubMenuItem("Force", - EngineeringUnits.Force, Force.GetAbbreviation(_forceUnit), UpdateForce); - ToolStripMenuItem momentUnitsMenu = GenerateToolStripMenuItem.GetSubMenuItem("Moment", - EngineeringUnits.Moment, Moment.GetAbbreviation(_momentUnit), UpdateMoment); - - var toolStripItems = new List { - forceUnitsMenu, - momentUnitsMenu, - }; - - if (_lengthUnit == LengthUnit.Undefined) { - ToolStripMenuItem modelUnitsMenu = GenerateToolStripMenuItem.GetSubMenuItem( - "Model geometry", EngineeringUnits.Length, Length.GetAbbreviation(_lengthUnit), - UpdateModel); - toolStripItems.Insert(0, modelUnitsMenu); - } - - unitsMenu.DropDownItems.AddRange(toolStripItems.ToArray()); - unitsMenu.ImageScaling = ToolStripItemImageScaling.SizeToFit; - - menu.Items.Add(unitsMenu); - Menu_AppendSeparator(menu); - } - - protected override void BeforeSolveInstance() { - Message = (int)_selectedDisplayValue < 4 ? Force.GetAbbreviation(_forceUnit) : - Moment.GetAbbreviation(_momentUnit); - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Component", - }); - - _dropDownItems = new List> { - _reactionStringList, - }; - _selectedItems = new List { - _dropDownItems[0][3], - }; - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaResultParameter(), "Result", "Res", "GSA Result", - GH_ParamAccess.item); - pManager.AddGenericParameter("Node filter list", "No", - "Filter results by list (by default 'all')" + Environment.NewLine - + "Input a GSA List or a text string taking the form:" + Environment.NewLine - + " 1 11 to 72 step 2 not (XY3 31 to 45)" + Environment.NewLine - + "Refer to GSA help file for definition of lists and full vocabulary.", - GH_ParamAccess.item); - pManager[1].Optional = true; - pManager.AddNumberParameter("Scalar", "x:X", - "Scale the result vectors to a specific size. If left empty, automatic scaling based on model size and maximum result by load cases will be computed.", - GH_ParamAccess.item); - pManager[2].Optional = true; - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddPointParameter("Anchor Point", "A", "Support Node Location", GH_ParamAccess.list); - pManager.AddGenericParameter("Vector", "V", "Reaction Force Vector", GH_ParamAccess.list); - pManager.AddGenericParameter("Value", "Val", "Reaction Force Value", GH_ParamAccess.list); - pManager.HideParameter(0); - } - - protected override void SolveInternal(IGH_DataAccess da) { - this.AddRuntimeError("Reaction Force results are now in Global axis - please update your script accordingly!"); - var result = new GsaResult(); - var ghObject = new GH_ObjectWrapper(); - - if (!da.GetData(0, ref ghObject) || !IsGhObjectValid(ghObject)) { - return; - } - - result = (ghObject.Value as GsaResultGoo).Value; - string nodeList = Inputs.GetNodeListDefinition(this, da, 1, result.Model); - - GsaResultsValues forceValues = result.NodeReactionForceValues(nodeList, _forceUnit, _momentUnit)[0]; - nodeList = string.Join(" ", forceValues.Ids); - - LengthUnit lengthUnit = GetLengthUnit(result); - - ReadOnlyDictionary gsaFilteredNodes = result.Model.Model.Nodes(nodeList); - ConcurrentDictionary nodes = Nodes.GetNodeDictionary(gsaFilteredNodes, - lengthUnit, result.Model.Model.Axes()); - - double scale = 1; - if (!da.GetData(2, ref scale)) { - scale = ComputeAutoScale(forceValues, result.Model.BoundingBox); - } - - _reactionForceVectors = new ConcurrentDictionary(); - Parallel.ForEach(nodes, node => { - (GsaVectorDiagram reactionForceVector, IQuantity forceValue) - = CreateReactionForceVector(node, forceValues, scale); - if (reactionForceVector != null) { - _reactionForceVectors.TryAdd(node.Key, (reactionForceVector, forceValue)); - } - }); - - SetOutputs(da); - PostHog.Result(result.Type, 0, GsaResultsValues.ResultType.Force, - _selectedDisplayValue.ToString()); - } - - private double ComputeAutoScale(GsaResultsValues forceValues, BoundingBox bbox) { - double maxValue = 0; - switch (_selectedDisplayValue) { - case DisplayValue.X: - maxValue = Math.Max(forceValues.DmaxX.As(_forceUnit), - Math.Abs(forceValues.DminX.As(_forceUnit))); - break; - case DisplayValue.Y: - maxValue = Math.Max(forceValues.DmaxY.As(_forceUnit), - Math.Abs(forceValues.DminY.As(_forceUnit))); - break; - case DisplayValue.Z: - maxValue = Math.Max(forceValues.DmaxZ.As(_forceUnit), - Math.Abs(forceValues.DminZ.As(_forceUnit))); - break; - case DisplayValue.ResXyz: - maxValue = Math.Max(forceValues.DmaxXyz.As(_forceUnit), - Math.Abs(forceValues.DminXyz.As(_forceUnit))); - break; - - case DisplayValue.Xx: - maxValue = Math.Max(forceValues.DmaxXx.As(_momentUnit), - Math.Abs(forceValues.DminXx.As(_momentUnit))); - break; - case DisplayValue.Yy: - maxValue = Math.Max(forceValues.DmaxYy.As(_momentUnit), - Math.Abs(forceValues.DminYy.As(_momentUnit))); - break; - case DisplayValue.Zz: - maxValue = Math.Max(forceValues.DmaxZz.As(_momentUnit), - Math.Abs(forceValues.DminZz.As(_momentUnit))); - break; - case DisplayValue.ResXxyyzz: - maxValue = Math.Max(forceValues.DmaxXxyyzz.As(_momentUnit), - Math.Abs(forceValues.DminXxyyzz.As(_momentUnit))); - break; - } - - double factor = 0.1; // maxVector = 10% of bbox diagonal - return bbox.Diagonal.Length * factor / maxValue; - } - - private (GsaVectorDiagram diagram, IQuantity quantity) CreateReactionForceVector( - KeyValuePair node, GsaResultsValues forceValues, double scale) { - int nodeId = node.Key; - ConcurrentDictionary> xyzResults - = forceValues.XyzResults; - ConcurrentDictionary> xxyyzzResults - = forceValues.XxyyzzResults; - - if (!xyzResults.ContainsKey(nodeId)) { - return (null, null); - } - - bool isForce = (int)_selectedDisplayValue < 4; - GsaResultQuantity quantity; - Enum unit; - - if (isForce) { - quantity = xyzResults[nodeId][0]; - unit = _forceUnit; - } else { - quantity = xxyyzzResults[nodeId][0]; - unit = _momentUnit; - } - - var direction = new Vector3d(); - IQuantity forceValue = null; - - Vector3d xAxis = node.Value.Value.IsGlobalAxis ? Vector3d.XAxis : - node.Value.Value.LocalAxis.XAxis; - xAxis.Unitize(); - Vector3d yAxis = node.Value.Value.IsGlobalAxis ? Vector3d.YAxis : - node.Value.Value.LocalAxis.YAxis; - yAxis.Unitize(); - Vector3d zAxis = node.Value.Value.IsGlobalAxis ? Vector3d.ZAxis : - node.Value.Value.LocalAxis.ZAxis; - zAxis.Unitize(); - - xAxis *= quantity.X.As(unit) * scale; - yAxis *= quantity.Y.As(unit) * scale; - zAxis *= quantity.Z.As(unit) * scale; - - switch (_selectedDisplayValue) { - case DisplayValue.X: - case DisplayValue.Xx: - direction = xAxis; - forceValue = quantity.X.ToUnit(unit); - break; - - case DisplayValue.Y: - case DisplayValue.Yy: - direction = yAxis; - forceValue = quantity.Y.ToUnit(unit); - break; - - case DisplayValue.Z: - case DisplayValue.Zz: - direction = zAxis; - forceValue = quantity.Z.ToUnit(unit); - break; - - case DisplayValue.ResXyz: - case DisplayValue.ResXxyyzz: - direction = xAxis + yAxis + zAxis; - forceValue = quantity.Xyz.ToUnit(unit); - break; - } - - return (new GsaVectorDiagram(node.Value.Value.Point, direction, !isForce, Color.Empty), forceValue); - } - - private LengthUnit GetLengthUnit(GsaResult gsaResult) { - LengthUnit lengthUnit = gsaResult.Model.ModelUnit; - bool isUndefined = lengthUnit == LengthUnit.Undefined; - - if (!isUndefined) { - return lengthUnit; - } - - lengthUnit = _lengthUnit; - this.AddRuntimeRemark("Model came straight out of GSA and we couldn't read the units. " - + "The geometry has been scaled to be in " + lengthUnit.ToString() - + ". This can be changed by right-clicking the component -> 'Select Units'"); - - return lengthUnit; - } - - private bool IsGhObjectValid(GH_ObjectWrapper ghObject) { - bool valid = false; - if (ghObject == null || ghObject.Value == null) { - this.AddRuntimeWarning("Input is null"); - } else if (!(ghObject.Value is GsaResultGoo)) { - this.AddRuntimeError("Error converting input to GSA Result"); - } else { - valid = true; - } - - return valid; - } - - private void SetOutputs(IGH_DataAccess dataAccess) { - IOrderedEnumerable> orderedDict - = _reactionForceVectors.OrderBy(index => index.Key); - var startingPoints = new Point3dList(); - var vectors = new List(); - var forces = new List(); - - foreach (KeyValuePair keyValuePair in - orderedDict) { - startingPoints.Add(keyValuePair.Value.diagram.AnchorPoint); - vectors.Add(keyValuePair.Value.diagram); - forces.Add(keyValuePair.Value.force); - } - - dataAccess.SetDataList(0, startingPoints); - dataAccess.SetDataList(1, vectors); - dataAccess.SetDataList(2, forces); - } - - private void ShowText(object sender, EventArgs e) { - _showText = !_showText; - ExpirePreview(true); - base.UpdateUI(); - } - - private void UpdateForce(string unit) { - _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), unit); - ExpirePreview(true); - base.UpdateUI(); - } - - private void UpdateModel(string unit) { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), unit); - ExpirePreview(true); - base.UpdateUI(); - } - - private void UpdateMoment(string unit) { - _momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), unit); - ExpirePreview(true); - base.UpdateUI(); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/ReactionForce_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/ReactionForce_OBSOLETE.cs deleted file mode 100644 index b05c79192..000000000 --- a/GsaGH/Components/GraveyardComp/ReactionForce_OBSOLETE.cs +++ /dev/null @@ -1,247 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Threading.Tasks; -using Grasshopper; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Data; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using OasysGH.Parameters; -using OasysGH.Units; -using OasysGH.Units.Helpers; -using OasysUnits; -using OasysUnits.Units; - -namespace GsaGH.Components { - /// - /// Component to get GSA reaction forces - /// - public class ReactionForce_OBSOLETE : GH_OasysDropDownComponent { - public override Guid ComponentGuid => new Guid("4f06d674-c736-4d9c-89d9-377bc424c547"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.ReactionForces; - private ForceUnit _forceUnit = DefaultUnits.ForceUnit; - private MomentUnit _momentUnit = DefaultUnits.MomentUnit; - - public ReactionForce_OBSOLETE() : base("Reaction Forces", "ReacForce", "Reaction Force result values", - CategoryName.Name(), SubCategoryName.Cat5()) { - Hidden = true; - } - - public override void SetSelected(int i, int j) { - _selectedItems[i] = _dropDownItems[i][j]; - switch (i) { - case 0: - _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), _selectedItems[i]); - break; - - case 1: - _momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), _selectedItems[i]); - break; - } - - base.UpdateUI(); - } - - public override void VariableParameterMaintenance() { - string forceunitAbbreviation = Force.GetAbbreviation(_forceUnit); - string momentunitAbbreviation = Moment.GetAbbreviation(_momentUnit); - int i = 0; - Params.Output[i++].Name = "Force X [" + forceunitAbbreviation + "]"; - Params.Output[i++].Name = "Force Y [" + forceunitAbbreviation + "]"; - Params.Output[i++].Name = "Force Z [" + forceunitAbbreviation + "]"; - Params.Output[i++].Name = "Force |XYZ| [" + forceunitAbbreviation + "]"; - Params.Output[i++].Name = "Moment XX [" + momentunitAbbreviation + "]"; - Params.Output[i++].Name = "Moment YY [" + momentunitAbbreviation + "]"; - Params.Output[i++].Name = "Moment ZZ [" + momentunitAbbreviation + "]"; - Params.Output[i].Name = "Moment |XXYYZZ| [" + momentunitAbbreviation + "]"; - } - - protected override void InitialiseDropdowns() { - _spacerDescriptions = new List(new[] { - "Force Unit", - "Moment Unit", - }); - - _dropDownItems = new List>(); - _selectedItems = new List(); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Force)); - _selectedItems.Add(Force.GetAbbreviation(_forceUnit)); - - _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Moment)); - _selectedItems.Add(Moment.GetAbbreviation(_momentUnit)); - - _isInitialised = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaResultParameter(), "Result", "Res", "GSA Result", - GH_ParamAccess.list); - pManager.AddGenericParameter("Node filter list", "No", - "Filter results by list (by default 'all')" + Environment.NewLine - + "Input a GSA List or a text string taking the form:" + Environment.NewLine - + " 1 11 to 72 step 2 not (XY3 31 to 45)" + Environment.NewLine - + "Refer to GSA help file for definition of lists and full vocabulary.", - GH_ParamAccess.item); - pManager[1].Optional = true; - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - this.AddRuntimeError("Reaction Force results are now in Global axis - please update your script accordingly!"); - string forceunitAbbreviation = Force.GetAbbreviation(_forceUnit); - string momentunitAbbreviation = Moment.GetAbbreviation(_momentUnit); - - string note = Environment.NewLine + "DataTree organised as { CaseID ; Permutation } " - + Environment.NewLine + "fx. {1;2} is Case 1, Permutation 2, where each branch " - + Environment.NewLine + "branch contains a list matching the NodeIDs in the ID output."; - string axis = " in Node's Local Axis (Global Axis is no Local Axis has been set)."; - - pManager.AddGenericParameter("Force X [" + forceunitAbbreviation + "]", "Fx", - "Reaction Forces in X-direction" + axis + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Force Y [" + forceunitAbbreviation + "]", "Fy", - "Reaction Forces in Y-direction" + axis + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Force Z [" + forceunitAbbreviation + "]", "Fz", - "Reaction Forces in Z-direction" + axis + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Force |XYZ| [" + forceunitAbbreviation + "]", "|F|", - "Combined |XYZ| Reaction Forces" + axis + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Moment XX [" + momentunitAbbreviation + "]", "Mxx", - "Reaction Moments around X-axis" + axis + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Moment YY [" + momentunitAbbreviation + "]", "Myy", - "Reaction Moments around Y-axis" + axis + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Moment ZZ [" + momentunitAbbreviation + "]", "Mzz", - "Reaction Moments around Z-axis" + axis + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Moment |XYZ| [" + momentunitAbbreviation + "]", "|M|", - "Combined |XXYYZZ| Reaction Moments" + axis + note, GH_ParamAccess.tree); - pManager.AddTextParameter("Nodes IDs", "ID", "Node IDs for each result value", - GH_ParamAccess.list); - } - - protected override void SolveInternal(IGH_DataAccess da) { - var result = new GsaResult(); - - string nodeList = string.Empty; - - var outTransX = new DataTree(); - var outTransY = new DataTree(); - var outTransZ = new DataTree(); - var outTransXyz = new DataTree(); - var outRotX = new DataTree(); - var outRotY = new DataTree(); - var outRotZ = new DataTree(); - var outRotXyz = new DataTree(); - var outIDs = new DataTree(); - - var ghTypes = new List(); - if (!da.GetDataList(0, ghTypes)) { - return; - } - - foreach (GH_ObjectWrapper ghTyp in ghTypes) { - switch (ghTyp?.Value) { - case null: - this.AddRuntimeWarning("Input is null"); - return; - - case GsaResultGoo goo: - result = goo.Value; - nodeList = Inputs.GetNodeListDefinition(this, da, 1, result.Model); - break; - - default: - this.AddRuntimeError("Error converting input to GSA Result"); - return; - } - - List vals - = result.NodeReactionForceValues(nodeList, _forceUnit, _momentUnit); - - List permutations = result.SelectedPermutationIds ?? new List() { - 1, - }; - if (permutations.Count == 1 && permutations[0] == -1) { - permutations = Enumerable.Range(1, vals.Count).ToList(); - } - - foreach (int perm in permutations) { - var path = new GH_Path(result.CaseId, result.SelectedPermutationIds == null ? 0 : perm); - - var transX = new List(); - var transY = new List(); - var transZ = new List(); - var transXyz = new List(); - var rotX = new List(); - var rotY = new List(); - var rotZ = new List(); - var rotXyz = new List(); - - Parallel.For(0, 2, item => // split into two tasks - { - switch (item) { - case 0: - foreach (int key in vals[perm - 1].Ids) { - // there is only one result per node - GsaResultQuantity values = vals[perm - 1].XyzResults[key][0]; - // use ToUnit to capture changes in dropdown - transX.Add(new GH_UnitNumber(values.X.ToUnit(_forceUnit))); - transY.Add(new GH_UnitNumber(values.Y.ToUnit(_forceUnit))); - transZ.Add(new GH_UnitNumber(values.Z.ToUnit(_forceUnit))); - transXyz.Add(new GH_UnitNumber(values.Xyz.ToUnit(_forceUnit))); - } - break; - - case 1: - foreach (int key in vals[perm - 1].Ids) { - // there is only one result per node - GsaResultQuantity values = vals[perm - 1].XxyyzzResults[key][0]; - // use ToUnit to capture changes in dropdown - rotX.Add(new GH_UnitNumber(values.X.ToUnit(_momentUnit))); - rotY.Add(new GH_UnitNumber(values.Y.ToUnit(_momentUnit))); - rotZ.Add(new GH_UnitNumber(values.Z.ToUnit(_momentUnit))); - rotXyz.Add(new GH_UnitNumber(values.Xyz.ToUnit(_momentUnit))); - } - break; - } - }); - - outTransX.AddRange(transX, path); - outTransY.AddRange(transY, path); - outTransZ.AddRange(transZ, path); - outTransXyz.AddRange(transXyz, path); - outRotX.AddRange(rotX, path); - outRotY.AddRange(rotY, path); - outRotZ.AddRange(rotZ, path); - outRotXyz.AddRange(rotXyz, path); - outIDs.AddRange(vals[perm - 1].Ids, path); - } - } - - da.SetDataTree(0, outTransX); - da.SetDataTree(1, outTransY); - da.SetDataTree(2, outTransZ); - da.SetDataTree(3, outTransXyz); - da.SetDataTree(4, outRotX); - da.SetDataTree(5, outRotY); - da.SetDataTree(6, outRotZ); - da.SetDataTree(7, outRotXyz); - da.SetDataTree(8, outIDs); - - PostHog.Result(result.Type, 0, GsaResultsValues.ResultType.Force); - } - - protected override void UpdateUIFromSelectedItems() { - _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), _selectedItems[0]); - _momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), _selectedItems[1]); - base.UpdateUIFromSelectedItems(); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/ShowId_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/ShowId_OBSOLETE.cs deleted file mode 100644 index 628744aba..000000000 --- a/GsaGH/Components/GraveyardComp/ShowId_OBSOLETE.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Data; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; -using Rhino.Collections; -using Rhino.Geometry; - -namespace GsaGH.Components.GraveyardComp { - public class ShowId_OBSOLETE : GH_OasysComponent { - public override BoundingBox ClippingBox - => _pts != null ? new BoundingBox(_pts) : base.ClippingBox; - public override Guid ComponentGuid => new Guid("e01fde68-b591-4ada-b590-9506fc962114"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.Annotate; - private Point3dList _pts; - private List _txts; - - public ShowId_OBSOLETE() : base("ShowID", "ID", - "Show the ID of a Node, Element, Member geometry or Result parameters", CategoryName.Name(), - SubCategoryName.Cat2()) { } - - public override void DrawViewportWires(IGH_PreviewArgs args) { - base.DrawViewportWires(args); - - if (_txts == null) { - return; - } - - for (int i = 0; i < _txts.Count; i++) { - Point2d positionOnTheScreen = args.Viewport.WorldToClient(_pts[i]); - args.Display.Draw2dText(_txts[i], - Attributes.Selected ? args.WireColour_Selected : args.WireColour, positionOnTheScreen, - true); - } - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddGenericParameter("Node/Element/Member/Result", "Geo", - "Node, Element, Member or Point/Line/Mesh result to get ID for.", GH_ParamAccess.tree); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddPointParameter("Position", "P", "The (centre/mid) location(s) of the object(s)", - GH_ParamAccess.tree); - pManager.HideParameter(0); - pManager.AddIntegerParameter("Index", "ID", "The objects ID(s)", GH_ParamAccess.tree); - } - - protected override void SolveInstance(IGH_DataAccess da) { - _pts = new Point3dList(); - _txts = new List(); - - if (!da.GetDataTree(0, out GH_Structure tree)) { - return; - } - - var ids = new GH_Structure(); - var ghPts = new GH_Structure(); - - foreach (GH_Path path in tree.Paths) { - foreach (IGH_Goo goo in tree.get_Branch(path)) { - int id = 0; - Point3d pt = Point3d.Unset; - - switch (goo) { - case GsaElement2dGoo e2d: - for (int i = 0; i < e2d.Value.Mesh.Faces.Count; i++) { - _txts.Add(e2d.Value.Ids[i].ToString()); - ids.Append(new GH_Integer(e2d.Value.Ids[i]), path); - _pts.Add(e2d.Value.Mesh.Faces.GetFaceCenter(i)); - ghPts.Append(new GH_Point(e2d.Value.Mesh.Faces.GetFaceCenter(i)), path); - } - - continue; - - case GsaElement3dGoo e3d: - for (int i = 0; i < e3d.Value.NgonMesh.Ngons.Count; i++) { - _txts.Add(e3d.Value.Ids[i].ToString()); - ids.Append(new GH_Integer(e3d.Value.Ids[i]), path); - _pts.Add(e3d.Value.NgonMesh.Ngons.GetNgonCenter(i)); - ghPts.Append(new GH_Point(e3d.Value.NgonMesh.Ngons.GetNgonCenter(i)), path); - } - - continue; - - case MeshResultGoo resMesh: - for (int i = 0; i < resMesh.ElementIds.Count; i++) { - _txts.Add(resMesh.ElementIds[i].ToString()); - ids.Append(new GH_Integer(resMesh.ElementIds[i]), path); - if (resMesh.Value.Ngons.Count > 0) { - _pts.Add(resMesh.Value.Ngons.GetNgonCenter(i)); - ghPts.Append(new GH_Point(resMesh.Value.Ngons.GetNgonCenter(i)), path); - } - else { - _pts.Add(resMesh.Value.Faces.GetFaceCenter(i)); - ghPts.Append(new GH_Point(resMesh.Value.Faces.GetFaceCenter(i)), path); - } - } - - continue; - - case GsaNodeGoo node: - id = node.Value.Id; - pt = node.Value.Point; - break; - - case GsaElement1dGoo e1d: - id = e1d.Value.Id; - pt = e1d.Value.Line.PointAtNormalizedLength(0.5); - break; - - case GsaMember1dGoo m1d: - id = m1d.Value.Id; - pt = m1d.Value.PolyCurve.PointAtNormalizedLength(0.5); - break; - - case GsaMember2dGoo m2d: - id = m2d.Value.Id; - m2d.Value.PolyCurve.TryGetPolyline(out Polyline pl); - pt = pl.CenterPoint(); - break; - - case GsaMember3dGoo m3d: - id = m3d.Value.Id; - pt = m3d.Value.SolidMesh.GetBoundingBox(false).Center; - break; - - case PointResultGoo resPoint: - id = resPoint.NodeId; - pt = resPoint.Value; - break; - - case LineResultGoo resLine: - id = resLine.ElementId; - pt = resLine.Value.PointAt(0.5); - break; - - case GsaVectorDiagram resVector: - pt = resVector.AnchorPoint; - break; - - default: - this.AddRuntimeWarning("Unable to convert " + goo.TypeName - + " to Node, Element (1D/2D/3D), Member (1D/2D/3D) or Point/Line/Mesh result."); - break; - } - - _txts.Add(id.ToString()); - ids.Append(new GH_Integer(id), path); - _pts.Add(pt); - ghPts.Append(new GH_Point(pt), path); - } - } - - da.SetDataTree(0, ghPts); - da.SetDataTree(1, ids); - } - } -} diff --git a/GsaGH/Components/GraveyardComp/Units_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/Units_OBSOLETE.cs deleted file mode 100644 index d1082fc3c..000000000 --- a/GsaGH/Components/GraveyardComp/Units_OBSOLETE.cs +++ /dev/null @@ -1,239 +0,0 @@ -using System; -using System.Drawing; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaAPI; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; - -namespace GsaGH.Components { - public class Units_OBSOLETE : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("2eb77ab2-6ea1-4899-ab95-6ae8a36d9d23"); - public override GH_Exposure Exposure => GH_Exposure.hidden; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.ModelUnits; - - public Units_OBSOLETE() : base("Model Units", "Units", - "Get or set the units used by GSA when opening this Model", - CategoryName.Name(), SubCategoryName.Cat0()) { - Hidden = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaModelParameter(), "GSA Model", "GSA", - "Existing GSA model to get or set units for.", - GH_ParamAccess.item); - pManager.AddTextParameter("Acceleration", "Acc", "Set Acceleration Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Angle", "Ang", "Set Angle Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Energy", "E", "Set Energy Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Force", "F", "Set Force Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Geometry", "LL", "Set 'Length - large' Unit used for Node Geometry for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Property Dimension", "LP", "Set 'Length - sections' Unit used for Property Dimensions for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Displacement", "LS", "Set 'Length - small' Unit used for Displacement Results for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Mass", "M", "Set Mass Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Stress", "S", "Set Stress Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Time Long", "TL", "Set Time Long Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Time Medium", "TM", "Set Time Medium Unitfor this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Time Short", "TS", "Set Time Short Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Velocity", "V", "Set Velocity Unit for this GSA Model", - GH_ParamAccess.item); - for (int i = 1; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaModelParameter()); - pManager.AddTextParameter("Acceleration", "Acc", "Get Acceleration Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Angle", "Ang", "Get Angle Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Energy", "E", "Get Energy Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Force", "F", "Get Force Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Geometry", "LL", "Get 'Length - large' Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Property Dimension", "LP", "Get 'Length - sections' Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Displacement", "LS", "Get 'Length - small' Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Mass", "M", "Get Mass Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Stress", "S", "Get Stress Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Time Long", "TL", "Get Time Long Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Time Medium", "TM", "Get Time Medium Unitfor this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Time Short", "TS", "Get Time Short Unit for this GSA Model", - GH_ParamAccess.item); - pManager.AddTextParameter("Velocity", "V", "Get Velocity Unit for this GSA Model", - GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - GsaModelGoo gooModel = null; - GsaModel model = null; - int i = 0; - if (da.GetData(i++, ref gooModel)) { - model = gooModel.Value.Clone(); - } - UiUnits units = model.Units; - - var ghString = new GH_String(); - if (da.GetData(i++, ref ghString)) { - Tuple result = ParseUnit(ghString, typeof(AccelerationUnit)); - if (result.Item1) { - units.Acceleration = (AccelerationUnit)result.Item2; - } - } - - ghString = new GH_String(); - if (da.GetData(i++, ref ghString)) { - Tuple result = ParseUnit(ghString, typeof(AngleUnit)); - if (result.Item1) { - units.Angle = (AngleUnit)result.Item2; - } - } - - ghString = new GH_String(); - if (da.GetData(i++, ref ghString)) { - Tuple result = ParseUnit(ghString, typeof(EnergyUnit)); - if (result.Item1) { - units.Energy = (EnergyUnit)result.Item2; - } - } - - ghString = new GH_String(); - if (da.GetData(i++, ref ghString)) { - Tuple result = ParseUnit(ghString, typeof(ForceUnit)); - if (result.Item1) { - units.Force = (ForceUnit)result.Item2; - } - } - - ghString = new GH_String(); - if (da.GetData(i++, ref ghString)) { - Tuple result = ParseUnit(ghString, typeof(LengthUnit)); - if (result.Item1) { - units.LengthLarge = (LengthUnit)result.Item2; - } - } - - ghString = new GH_String(); - if (da.GetData(i++, ref ghString)) { - Tuple result = ParseUnit(ghString, typeof(LengthUnit)); - if (result.Item1) { - units.LengthSections = (LengthUnit)result.Item2; - } - } - - ghString = new GH_String(); - if (da.GetData(i++, ref ghString)) { - Tuple result = ParseUnit(ghString, typeof(LengthUnit)); - if (result.Item1) { - units.LengthSmall = (LengthUnit)result.Item2; - } - } - - ghString = new GH_String(); - if (da.GetData(i++, ref ghString)) { - Tuple result = ParseUnit(ghString, typeof(MassUnit)); - if (result.Item1) { - units.Mass = (MassUnit)result.Item2; - } - } - - ghString = new GH_String(); - if (da.GetData(i++, ref ghString)) { - Tuple result = ParseUnit(ghString, typeof(StressUnit)); - if (result.Item1) { - units.Stress = (StressUnit)result.Item2; - } - } - - ghString = new GH_String(); - if (da.GetData(i++, ref ghString)) { - Tuple result = ParseUnit(ghString, typeof(TimeUnit)); - if (result.Item1) { - units.TimeLong = (TimeUnit)result.Item2; - } - } - - ghString = new GH_String(); - if (da.GetData(i++, ref ghString)) { - Tuple result = ParseUnit(ghString, typeof(TimeUnit)); - if (result.Item1) { - units.TimeMedium = (TimeUnit)result.Item2; - } - } - - ghString = new GH_String(); - if (da.GetData(i++, ref ghString)) { - Tuple result = ParseUnit(ghString, typeof(TimeUnit)); - if (result.Item1) { - units.TimeShort = (TimeUnit)result.Item2; - } - } - - ghString = new GH_String(); - if (da.GetData(i++, ref ghString)) { - Tuple result = ParseUnit(ghString, typeof(VelocityUnit)); - if (result.Item1) { - units.Velocity = (VelocityUnit)result.Item2; - } - } - - i = 0; - - da.SetData(i++, new GsaModelGoo(new GsaModel(model.Model))); - da.SetData(i++, units.Acceleration.ToString()); - da.SetData(i++, units.Angle.ToString()); - da.SetData(i++, units.Energy.ToString()); - da.SetData(i++, units.Force.ToString()); - da.SetData(i++, units.LengthLarge.ToString()); - da.SetData(i++, units.LengthSections.ToString()); - da.SetData(i++, units.LengthSmall.ToString()); - da.SetData(i++, units.Mass.ToString()); - da.SetData(i++, units.Stress.ToString()); - da.SetData(i++, units.TimeLong.ToString()); - da.SetData(i++, units.TimeMedium.ToString()); - da.SetData(i++, units.TimeShort.ToString()); - da.SetData(i++, units.Velocity.ToString()); - - this.AddRuntimeRemark( - "This component can be used to set the default units when the model is saved and opening in GSA. " + - Environment.NewLine + "To change the default units used inside Grasshopper go to the Oasys menu -> Oasys Units."); - } - - private Tuple ParseUnit(GH_String ghString, Type type) { - if (GH_Convert.ToString(ghString, out string txt, GH_Conversion.Both)) { - try { - var unit = (Enum)Enum.Parse(type, txt, ignoreCase: true); - return Tuple.Create(true, unit); - } catch (ArgumentException) { - string[] names = Enum.GetNames(type); - this.AddRuntimeError($"Unable to convert '{txt}' to a known unit. Accepted inputs are:" - + Environment.NewLine + string.Join(Environment.NewLine, names)); - } - } - return Tuple.Create(false, null); - } - } -} \ No newline at end of file diff --git a/GsaGH/Components/GraveyardComp/BaseReader.cs b/GsaGH/Helpers/GH/BaseReader.cs similarity index 98% rename from GsaGH/Components/GraveyardComp/BaseReader.cs rename to GsaGH/Helpers/GH/BaseReader.cs index 15072befd..c8fe59d4f 100644 --- a/GsaGH/Components/GraveyardComp/BaseReader.cs +++ b/GsaGH/Helpers/GH/BaseReader.cs @@ -4,7 +4,7 @@ using Grasshopper.Kernel; using Grasshopper.Kernel.Parameters; -namespace GsaGH.Components.GraveyardComp { +namespace GsaGH.Helpers.GH { internal class BaseReader { internal static bool Read( @@ -47,7 +47,8 @@ internal static bool Read( GH_IReader ghIReader2 = reader.FindChunk("Attributes"); if (ghIReader2 != null) { owner.Attributes.Read(ghIReader2); - } else { + } + else { reader.AddMessage("Attributes chunk is missing. Could be a hint something's wrong.", GH_Message_Type.info); } @@ -57,7 +58,8 @@ internal static bool Read( bool value1 = false; if (reader.TryGetBoolean("Hidden", ref value1)) { previewObject.Hidden = value1; - } else { + } + else { bool value2 = true; if (reader.TryGetBoolean("Preview", ref value2)) { previewObject.Hidden = !value2; diff --git a/GsaGHTests/3_Components/ComponentsTests.cs b/GsaGHTests/3_Components/ComponentsTests.cs index e32a7924b..c8c092cb6 100644 --- a/GsaGHTests/3_Components/ComponentsTests.cs +++ b/GsaGHTests/3_Components/ComponentsTests.cs @@ -75,7 +75,6 @@ public void WhenInitialiseDropdowns_ThenDropDownItemsCount_ShouldBeValid( [InlineData(typeof(CreateBool6))] [InlineData(typeof(Create1dMember))] [InlineData(typeof(CreateSupport))] - [InlineData(typeof(CreateMember1d_OBSOLETE))] public void WhenInitialiseDropdowns_ThenDropDownItems_ShouldBeNull(Type t) { var obj = (GH_OasysDropDownComponent)Activator.CreateInstance(t); obj.InitialiseDropdowns(); diff --git a/GsaGHTests/4_CustomUIComponents/DeserializeTests.cs b/GsaGHTests/4_CustomUIComponents/DeserializeTests.cs index b501c7ea3..d1d028313 100644 --- a/GsaGHTests/4_CustomUIComponents/DeserializeTests.cs +++ b/GsaGHTests/4_CustomUIComponents/DeserializeTests.cs @@ -1,6 +1,5 @@ using System; using GsaGH.Components; -using GsaGH.Components.GraveyardComp; using GsaGHTests.Helpers; using OasysGH.Components; using Xunit; @@ -52,33 +51,6 @@ public class DeserializeTests { [InlineData(typeof(ReactionForceDiagrams))] [InlineData(typeof(AnnotateDetailed))] [InlineData(typeof(LoadDiagrams))] - //Graveyard - [InlineData(typeof(CreateBool6_OBSOLETE))] - [InlineData(typeof(CreateGridPlane_OBSOLETE))] - [InlineData(typeof(CreateGridSurface_OBSOLETE))] - [InlineData(typeof(CreateMaterial_OBSOLETE))] - [InlineData(typeof(CreateMember1d_OBSOLETE))] - [InlineData(typeof(CreateMember2d_OBSOLETE))] - [InlineData(typeof(CreateProfile_OBSOLETE))] - [InlineData(typeof(CreateProp2d_OBSOLETE))] - [InlineData(typeof(EditMember1d3_OBSOLETE))] - [InlineData(typeof(EditMember1d_OBSOLETE))] - [InlineData(typeof(EditMember2d_OBSOLETE))] - [InlineData(typeof(EditMember3d_OBSOLETE))] - [InlineData(typeof(EditNode_OBSOLETE))] - [InlineData(typeof(EditProp2d3_OBSOLETE))] - [InlineData(typeof(EditProp2d4_OBSOLETE))] - [InlineData(typeof(EditProp2d5_OBSOLETE))] - [InlineData(typeof(EditProp2d6_OBSOLETE))] - [InlineData(typeof(EditProp2d_OBSOLETE))] - [InlineData(typeof(EditSectionModifier2_OBSOLETE))] - [InlineData(typeof(Elem1dContourResults_OBSOLETE))] - [InlineData(typeof(Elem2dContourResults_OBSOLETE))] - [InlineData(typeof(Elem2dFromBrep2_OBSOLETE))] - [InlineData(typeof(GetSectionProperties2_OBSOLETE))] - [InlineData(typeof(NodeContourResults_OBSOLETE))] - [InlineData(typeof(ReactionForceDiagrams2_OBSOLETE))] - [InlineData(typeof(ReactionForceDiagrams_OBSOLETE))] public void DeSerializeComponentTest(Type t) { var comp = (GH_OasysComponent)Activator.CreateInstance(t); OasysDropDownComponentTestHelper.TestDeserialize(comp); diff --git a/IntegrationTests/1_ExampleFiles/GsaGH_Example5_4PointSrfMidSupport.cs b/IntegrationTests/1_ExampleFiles/GsaGH_Example5_4PointSrfMidSupport.cs index d6a0033b9..36640208f 100644 --- a/IntegrationTests/1_ExampleFiles/GsaGH_Example5_4PointSrfMidSupport.cs +++ b/IntegrationTests/1_ExampleFiles/GsaGH_Example5_4PointSrfMidSupport.cs @@ -9,7 +9,6 @@ namespace IntegrationTests.ExampleFiles { [Collection("GrasshopperFixture collection")] - [SuppressMessage("ReSharper", "InconsistentNaming")] public class Example5_4PointSrfMidSupport_Test { public static GH_Document Document() { diff --git a/IntegrationTests/2_Parameters/1_Properties/CreateProfileTests.cs b/IntegrationTests/2_Parameters/1_Properties/CreateProfileTests.cs new file mode 100644 index 000000000..5fc03dd18 --- /dev/null +++ b/IntegrationTests/2_Parameters/1_Properties/CreateProfileTests.cs @@ -0,0 +1,71 @@ +using System.IO; +using System.Reflection; +using Grasshopper.Kernel; +using Grasshopper.Kernel.Types; +using GsaGH.Parameters; +using OasysUnits; +using OasysUnits.Units; +using Xunit; + +namespace IntegrationTests.Parameters { + [Collection("GrasshopperFixture collection")] + public class CreateProfileTests { + public static GH_Document Document => document ?? (document = OpenDocument()); + private static GH_Document document = null; + + [Fact] + public void NoRuntimeErrorTest() { + Helper.TestNoRuntimeMessagesInDocument(Document, GH_RuntimeMessageLevel.Error); + } + + [Fact] + public void NoRuntimeWarningTest() { + Helper.TestNoRuntimeMessagesInDocument(Document, GH_RuntimeMessageLevel.Warning); + } + + [Theory] + [InlineData("Angle", "STD A(mm) 500 100 10 20 [R(0)]")] + [InlineData("Channel", "STD CH(cm) 50 10 1 2")] + [InlineData("CircleHollow", "STD CHS(m) 5 0.1")] + [InlineData("Circle", "STD C(in) 11")] + [InlineData("CruciformSymmetrical", "STD X(mm) 500 100 10 20")] + [InlineData("EllipseHollow", "STD OVAL(mm) 500 100 10")] + [InlineData("GeneralC", "STD GC(mm) 500 100 10 20")] + [InlineData("GeneralZ", "STD GZ(mm) 500 100 10 20 30 30")] + [InlineData("IBeamAsymmetrical", "STD GI(mm) 500 100 10 20 30 30")] + [InlineData("IBeamCellular", "STD CB(mm) 500 100 10 20 300 3000")] + [InlineData("IBeamSymmetrical", "STD I(mm) 500 100 10 20")] + [InlineData("Perimeter", "GEO P(m) M(1|2) L(1|-2) L(-1|-2) L(-1|2)")] + [InlineData("RectangleHollow", "STD RHS(mm) 500 100 10 20")] + [InlineData("Rectangle", "STD R(mm) 500 100")] + [InlineData("RectoEllipse", "STD RE(mm) 500 400 350 300 2")] + [InlineData("RectoCircle", "STD RC(mm) 500 100")] + [InlineData("SecantPile", "STD SPW(mm) 500 100 10")] + [InlineData("SheetPile", "STD SHT(mm) 500 100 10 20 30 30")] + [InlineData("Trapezoid", "STD TR(mm) 500 100 10")] + [InlineData("T", "STD T(mm) 500 100 10 20")] + public void OutputTest(string groupIdentifier, string expected) { + GH_Document doc = Document; + IGH_Param param = Helper.FindParameter(doc, groupIdentifier); + var output = (GH_String)param.VolatileData.get_Branch(0)[0]; + Assert.Equal(expected, output.Value); + } + + private static GH_Document OpenDocument() { + string fileName = MethodBase.GetCurrentMethod().DeclaringType + ".gh"; + fileName = fileName.Replace("IntegrationTests.Parameters.", string.Empty); + fileName = fileName.Replace("Tests", string.Empty); + + string solutiondir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent + .Parent.FullName; + string path = Path.Combine(new string[] { + solutiondir, + "ExampleFiles", + "Parameters", + "1_Properties", + }); + + return Helper.CreateDocument(Path.Combine(path, fileName)); + } + } +} diff --git a/IntegrationTests/3_Components/NodeResultsTests.cs b/IntegrationTests/3_Components/NodeResultsTests.cs index f02748fdc..79d39fc8b 100644 --- a/IntegrationTests/3_Components/NodeResultsTests.cs +++ b/IntegrationTests/3_Components/NodeResultsTests.cs @@ -32,7 +32,7 @@ public void NodeContourSupportPtsCountTests() { } [Theory] - [InlineData("FContour", 871.0, 66.14, 1)] + [InlineData("FContour", 580.7, 66.14, 1)] public void NodeContourTests( string name, double expected1, double expected2, int precision = 6) { GH_Document doc = Document; diff --git a/codecov.yml b/codecov.yml index 075f8c16e..b96068cc9 100644 --- a/codecov.yml +++ b/codecov.yml @@ -27,5 +27,3 @@ flags: carryforward: false ignore: - "GsaGHTests" # ignore project (as it is referenced by Integration test) - - "GsaGH/Components/GraveyardComp" # ignore old versions of components in graveyard folder - - "GsaGH/Properties" # ignore icons and Resources.Designer.cs file auto-generated by visual studio