diff --git a/ExampleFiles/Parameters/3_Loads/GridPointLoad.gh b/ExampleFiles/Parameters/3_Loads/GridPointLoad.gh new file mode 100644 index 000000000..6baf4fae6 Binary files /dev/null and b/ExampleFiles/Parameters/3_Loads/GridPointLoad.gh differ diff --git a/GsaGH/Components/0_Model/SaveGsaModel.cs b/GsaGH/Components/0_Model/SaveGsaModel.cs index fa1e625b7..e1099324d 100644 --- a/GsaGH/Components/0_Model/SaveGsaModel.cs +++ b/GsaGH/Components/0_Model/SaveGsaModel.cs @@ -31,6 +31,7 @@ public class SaveGsaModel : GH_OasysDropDownComponent { public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; protected override Bitmap Icon => Resources.SaveGsaModel; private string _fileNameLastSaved; + private bool _saveInputOverride = false; public SaveGsaModel() : base("Save GSA Model", "Save", "Saves your GSA model from this parametric nightmare", CategoryName.Name(), @@ -95,8 +96,9 @@ protected override void SolveInternal(IGH_DataAccess da) { da.GetData(2, ref fileName); bool save = false; - if (da.GetData(1, ref save) && save) { + if (da.GetData(1, ref save) && (save || _saveInputOverride)) { Save(ref gsaModel, fileName); + _saveInputOverride = false; } da.SetData(0, new GsaModelGoo(gsaModel)); @@ -121,7 +123,12 @@ internal void Save(ref GsaModel model, string fileNameAndPath) { } internal void SaveButtonClick() { - UpdateUI(); + if (string.IsNullOrEmpty(_fileNameLastSaved)) { + SaveAsButtonClick(); + return; + } + + _saveInputOverride = true; } internal void SaveAsButtonClick() { @@ -153,9 +160,15 @@ internal void SaveAsButtonClick() { } internal void OpenGsaExe() { - if (!string.IsNullOrEmpty(_fileNameLastSaved)) { - Process.Start(_fileNameLastSaved); + if (string.IsNullOrEmpty(_fileNameLastSaved)) { + Params.Input[0].CollectData(); + var tempModel = (GsaModelGoo)Params.Input[0].VolatileData.AllData(true).First(); + string tempPath = Path.GetTempPath() + tempModel.Value.Guid.ToString() + ".gwb"; + GsaModel gsaModel = tempModel.Value; + Save(ref gsaModel, tempPath); } + + Process.Start(_fileNameLastSaved); } } } diff --git a/GsaGH/Components/3_Loads/CreateGridPointLoad.cs b/GsaGH/Components/3_Loads/CreateGridPointLoad.cs index 0c81cb2e7..7c85efa53 100644 --- a/GsaGH/Components/3_Loads/CreateGridPointLoad.cs +++ b/GsaGH/Components/3_Loads/CreateGridPointLoad.cs @@ -149,22 +149,19 @@ protected override void SolveInternal(IGH_DataAccess da) { GH_Convert.ToPoint3d(ghPt, ref point3d, GH_Conversion.Both); } - gridPointLoad.ApiLoad.X = point3d.X; - gridPointLoad.ApiLoad.Y = point3d.Y; - GsaGridPlaneSurface gridPlaneSurface; Plane plane = Plane.WorldXY; var ghTyp = new GH_ObjectWrapper(); if (da.GetData(2, ref ghTyp)) { switch (ghTyp.Value) { - case GsaGridPlaneSurfaceGoo gridplanesurfacegoo: { + case GsaGridPlaneSurfaceGoo gridplanesurfacegoo: gridPlaneSurface = gridplanesurfacegoo.Value.Duplicate(); gridPointLoad.GridPlaneSurface = gridPlaneSurface; _expansionType = ExpansionType.UseGpsSettings; UpdateMessage(gridPlaneSurface.GridSurface.ElementType == GsaAPI.GridSurface.Element_Type.ONE_DIMENSIONAL ? "1D" : "2D"); break; - } + case GH_Plane pln: plane = pln.Value; gridPlaneSurface = new GsaGridPlaneSurface(plane); @@ -173,7 +170,7 @@ protected override void SolveInternal(IGH_DataAccess da) { == GsaAPI.GridSurface.Element_Type.ONE_DIMENSIONAL ? "1D" : "2D"); break; - default: { + default: if (GH_Convert.ToInt32(ghTyp.Value, out int id, GH_Conversion.Both)) { gridPointLoad.ApiLoad.GridSurface = id; gridPointLoad.GridPlaneSurface = null; @@ -186,11 +183,10 @@ protected override void SolveInternal(IGH_DataAccess da) { } break; - } } } else { plane = Plane.WorldXY; - plane.Origin = point3d; + plane.Origin = new Point3d(0, 0, point3d.Z); gridPlaneSurface = new GsaGridPlaneSurface(plane, true); gridPointLoad.GridPlaneSurface = gridPlaneSurface; @@ -220,6 +216,16 @@ protected override void SolveInternal(IGH_DataAccess da) { } } + var plnNormal = new Vector3d(plane.Normal); + plnNormal.Unitize(); + if (plnNormal.Z != 1) { + this.AddRuntimeRemark("The grid plane basis is not defined in world coordinates. \n" + + "The input point´s X and Y coordinates are use as the grid plane´s local coordiantes."); + } + + gridPointLoad.ApiLoad.X = point3d.X; + gridPointLoad.ApiLoad.Y = point3d.Y; + string dir = "Z"; GsaAPI.Direction direc = GsaAPI.Direction.Z; diff --git a/GsaGH/Components/5_Results/Element2dStresses.cs b/GsaGH/Components/5_Results/Element2dStresses.cs index 767e7a959..34f536721 100644 --- a/GsaGH/Components/5_Results/Element2dStresses.cs +++ b/GsaGH/Components/5_Results/Element2dStresses.cs @@ -63,7 +63,7 @@ protected override void InitialiseDropdowns() { _selectedItems = new List(); _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Stress)); - _selectedItems.Add(_stresshUnit.ToString()); + _selectedItems.Add(Pressure.GetAbbreviation(_stresshUnit)); _isInitialised = true; } diff --git a/GsaGH/Components/5_Results/Element3dDisplacements.cs b/GsaGH/Components/5_Results/Element3dDisplacements.cs index ae7e11d43..6c2f02006 100644 --- a/GsaGH/Components/5_Results/Element3dDisplacements.cs +++ b/GsaGH/Components/5_Results/Element3dDisplacements.cs @@ -75,9 +75,7 @@ protected override void RegisterInputParams(GH_InputParamManager pManager) { protected override void RegisterOutputParams(GH_OutputParamManager pManager) { string unitAbbreviation = Length.GetAbbreviation(_lengthUnit); - string note = ResultNotes.Note2dResults; - pManager.AddGenericParameter("Translations X [" + unitAbbreviation + "]", "Ux", "Translations in X-direction in Global Axis." + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Translations Y [" + unitAbbreviation + "]", "Uy", @@ -86,14 +84,6 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) { "Translations in Z-direction in Global Axis." + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Translations |XYZ| [" + unitAbbreviation + "]", "|U|", "Combined |XYZ| Translations." + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Rotations XX [rad]", "Rxx", - "Rotations around X-axis in Global Axis." + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Rotations YY [rad]", "Ryy", - "Rotations around Y-axis in Global Axiss." + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Rotations ZZ [rad]", "Rzz", - "Rotations around Z-axis in Global Axis." + note, GH_ParamAccess.tree); - pManager.AddGenericParameter("Rotations |XYZ| [rad]", "|R|", - "Combined |XXYYZZ| Rotations." + note, GH_ParamAccess.tree); } protected override void SolveInternal(IGH_DataAccess da) { @@ -105,10 +95,6 @@ protected override void SolveInternal(IGH_DataAccess da) { 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)) { @@ -147,57 +133,26 @@ protected override void SolveInternal(IGH_DataAccess da) { continue; } - Parallel.For(0, 2, thread => // split computation in two for xyz and xxyyzz - { - switch (thread) { - case 0: { - foreach (KeyValuePair> kvp in + 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; - } + 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); + // use ToUnit to capture changes in dropdown + outTransX.AddRange( + res.Select(x => new GH_UnitNumber(x.Value.X.ToUnit(_lengthUnit))), path); + 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); + } } } @@ -205,10 +160,6 @@ protected override void SolveInternal(IGH_DataAccess da) { 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, 3, GsaResultsValues.ResultType.Displacement); } diff --git a/GsaGH/Components/5_Results/Element3dStresses.cs b/GsaGH/Components/5_Results/Element3dStresses.cs index e547b355f..1a60c5225 100644 --- a/GsaGH/Components/5_Results/Element3dStresses.cs +++ b/GsaGH/Components/5_Results/Element3dStresses.cs @@ -63,7 +63,7 @@ protected override void InitialiseDropdowns() { _selectedItems = new List(); _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Stress)); - _selectedItems.Add(_stresshUnit.ToString()); + _selectedItems.Add(Pressure.GetAbbreviation(_stresshUnit)); _isInitialised = true; } diff --git a/GsaGH/Components/5_Results/FootfallResults.cs b/GsaGH/Components/5_Results/FootfallResults.cs index e52646cd6..d094281bf 100644 --- a/GsaGH/Components/5_Results/FootfallResults.cs +++ b/GsaGH/Components/5_Results/FootfallResults.cs @@ -54,7 +54,7 @@ protected override void SolveInstance(IGH_DataAccess da) { case GsaResultGoo goo: { result = goo.Value; - if (result.Type == CaseType.Combination) { + if (result.Type == CaseType.CombinationCase) { this.AddRuntimeError("Footfall Result only available for Analysis Cases"); return; } diff --git a/GsaGH/Components/5_Results/GetResult.cs b/GsaGH/Components/5_Results/GetResult.cs index 9ad3f37dd..1cc6e0a10 100644 --- a/GsaGH/Components/5_Results/GetResult.cs +++ b/GsaGH/Components/5_Results/GetResult.cs @@ -83,7 +83,7 @@ protected override void SolveInstance(IGH_DataAccess da) { if (type.ToUpper().StartsWith("A")) { resultType = CaseType.AnalysisCase; } else if (type.ToUpper().StartsWith("C")) { - resultType = CaseType.Combination; + resultType = CaseType.CombinationCase; } else { this.AddRuntimeError("Error converting input " + Params.Input[1].NickName + " to 'Analysis' or 'Combination'"); @@ -145,7 +145,7 @@ protected override void SolveInstance(IGH_DataAccess da) { break; - case CaseType.Combination: + case CaseType.CombinationCase: if (_combinationCaseResults == null) { _combinationCaseResults = model.Model.CombinationCaseResults(); if (_combinationCaseResults == null || _combinationCaseResults.Count == 0) { @@ -177,8 +177,8 @@ IReadOnlyDictionary> tempNodeCombResult } if (!_result.ContainsKey( - new Tuple(CaseType.Combination, caseId))) { - _result.Add(new Tuple(CaseType.Combination, caseId), + new Tuple(CaseType.CombinationCase, caseId))) { + _result.Add(new Tuple(CaseType.CombinationCase, caseId), new GsaResult(model, _combinationCaseResults[caseId], caseId, permutationIDs)); } diff --git a/GsaGH/Components/5_Results/GlobalPerformanceResults.cs b/GsaGH/Components/5_Results/GlobalPerformanceResults.cs index ca6703d18..7a3ef67e4 100644 --- a/GsaGH/Components/5_Results/GlobalPerformanceResults.cs +++ b/GsaGH/Components/5_Results/GlobalPerformanceResults.cs @@ -168,7 +168,7 @@ protected override void SolveInternal(IGH_DataAccess da) { case GsaResultGoo goo: { result = goo.Value; - if (result.Type == CaseType.Combination) { + if (result.Type == CaseType.CombinationCase) { this.AddRuntimeError("Global Result only available for Analysis Cases"); return; } diff --git a/GsaGH/Components/5_Results/SelectResults.cs b/GsaGH/Components/5_Results/SelectResults.cs index 78b2ff98c..91811d9ef 100644 --- a/GsaGH/Components/5_Results/SelectResults.cs +++ b/GsaGH/Components/5_Results/SelectResults.cs @@ -59,11 +59,11 @@ public override void SetSelected(int i, int j) { } case 0: { if (_selectedItems[i] == _type[1]) { - if (_resultType == CaseType.Combination) { + if (_resultType == CaseType.CombinationCase) { return; } - _resultType = CaseType.Combination; + _resultType = CaseType.CombinationCase; UpdateDropdowns(); } @@ -74,7 +74,7 @@ public override void SetSelected(int i, int j) { string.Join(string.Empty, _selectedItems[i].ToCharArray().Where(char.IsDigit))); if (newId != _caseId) { _caseId = newId; - if (_resultType == CaseType.Combination) { + if (_resultType == CaseType.CombinationCase) { UpdatePermutations(); } } @@ -187,8 +187,8 @@ protected override void SolveInternal(IGH_DataAccess da) { } } else if (type.ToUpper().StartsWith("C")) { _selectedItems[0] = _dropDownItems[0][1]; - if (_resultType != CaseType.Combination) { - _resultType = CaseType.Combination; + if (_resultType != CaseType.CombinationCase) { + _resultType = CaseType.CombinationCase; if (_dropDownItems.Count < 3) { _dropDownItems.Add(new List() { "All", @@ -213,7 +213,7 @@ protected override void SolveInternal(IGH_DataAccess da) { var ghACase = new GH_Integer(); if (da.GetData(2, ref ghACase)) { if (GH_Convert.ToInt32(ghACase, out int analCase, GH_Conversion.Both)) { - if (_resultType == CaseType.Combination && _caseId != analCase) { + if (_resultType == CaseType.CombinationCase && _caseId != analCase) { UpdatePermutations(); } @@ -267,7 +267,7 @@ protected override void SolveInternal(IGH_DataAccess da) { break; - case CaseType.Combination: + case CaseType.CombinationCase: if (_combinationCaseResults == null) { _combinationCaseResults = _gsaModel.Model.CombinationCaseResults(); if (_combinationCaseResults == null || _combinationCaseResults.Count == 0) { @@ -319,7 +319,7 @@ protected override void UpdateUIFromSelectedItems() { if (_selectedItems[0] == _type[0]) { _resultType = CaseType.AnalysisCase; } else if (_selectedItems[0] == _type[1]) { - _resultType = CaseType.Combination; + _resultType = CaseType.CombinationCase; } if (_selectedItems[1].ToLower() == "all") { @@ -363,7 +363,7 @@ private void UpdateDropdowns() { _dropDownItems[1] = cases; _selectedItems[1] = type[0] + _caseId.ToString(); - if (_resultType == CaseType.Combination) { + if (_resultType == CaseType.CombinationCase) { if (_dropDownItems.Count < 3) { _dropDownItems.Add(new List() { "All", @@ -390,7 +390,7 @@ private void UpdateDropdowns() { } private void UpdatePermutations() { - if (_resultType != CaseType.Combination) { + if (_resultType != CaseType.CombinationCase) { return; } diff --git a/GsaGH/Components/5_Results/TotalLoadsAndReactions.cs b/GsaGH/Components/5_Results/TotalLoadsAndReactions.cs index 5a6699801..9413f6514 100644 --- a/GsaGH/Components/5_Results/TotalLoadsAndReactions.cs +++ b/GsaGH/Components/5_Results/TotalLoadsAndReactions.cs @@ -142,7 +142,7 @@ protected override void SolveInternal(IGH_DataAccess da) { case GsaResultGoo goo: { result = goo.Value; - if (result.Type == CaseType.Combination) { + if (result.Type == CaseType.CombinationCase) { this.AddRuntimeError("Global Result only available for Analysis Cases"); return; } diff --git a/GsaGH/Components/6_Display/Contour1dResults.cs b/GsaGH/Components/6_Display/Contour1dResults.cs index 539e4e521..a6d0d74b4 100644 --- a/GsaGH/Components/6_Display/Contour1dResults.cs +++ b/GsaGH/Components/6_Display/Contour1dResults.cs @@ -503,7 +503,7 @@ protected override void SolveInternal(IGH_DataAccess da) { case GsaResultGoo goo: { result = goo.Value; switch (result.Type) { - case CaseType.Combination when result.SelectedPermutationIds.Count > 1: + case CaseType.CombinationCase when result.SelectedPermutationIds.Count > 1: this.AddRuntimeWarning("Combination Case " + result.CaseId + " contains " + result.SelectedPermutationIds.Count + " permutations - only one permutation can be displayed at a time." @@ -512,7 +512,7 @@ protected override void SolveInternal(IGH_DataAccess da) { _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; break; - case CaseType.Combination: + case CaseType.CombinationCase: _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; break; diff --git a/GsaGH/Components/6_Display/Contour2dResults.cs b/GsaGH/Components/6_Display/Contour2dResults.cs index ce6425797..2e79eddbc 100644 --- a/GsaGH/Components/6_Display/Contour2dResults.cs +++ b/GsaGH/Components/6_Display/Contour2dResults.cs @@ -566,7 +566,7 @@ protected override void SolveInternal(IGH_DataAccess da) { result = goo.Value; switch (result.Type) { - case CaseType.Combination when result.SelectedPermutationIds.Count > 1: + case CaseType.CombinationCase when result.SelectedPermutationIds.Count > 1: this.AddRuntimeWarning("Combination Case " + result.CaseId + " contains " + result.SelectedPermutationIds.Count + " permutations - only one permutation can be displayed at a time." @@ -575,7 +575,7 @@ protected override void SolveInternal(IGH_DataAccess da) { _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; break; - case CaseType.Combination: + case CaseType.CombinationCase: _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; break; diff --git a/GsaGH/Components/6_Display/Contour3dResults.cs b/GsaGH/Components/6_Display/Contour3dResults.cs index 57ffa0755..f18324d3b 100644 --- a/GsaGH/Components/6_Display/Contour3dResults.cs +++ b/GsaGH/Components/6_Display/Contour3dResults.cs @@ -399,7 +399,7 @@ protected override void SolveInternal(IGH_DataAccess da) { case GsaResultGoo goo: { result = goo.Value; switch (result.Type) { - case CaseType.Combination when result.SelectedPermutationIds.Count > 1: + case CaseType.CombinationCase when result.SelectedPermutationIds.Count > 1: this.AddRuntimeWarning("Combination Case " + result.CaseId + " contains " + result.SelectedPermutationIds.Count + " permutations - only one permutation can be displayed at a time." @@ -408,7 +408,7 @@ protected override void SolveInternal(IGH_DataAccess da) { _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; break; - case CaseType.Combination: + case CaseType.CombinationCase: _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; break; diff --git a/GsaGH/Components/6_Display/ContourNodeResults.cs b/GsaGH/Components/6_Display/ContourNodeResults.cs index 7c024da99..7e86664ad 100644 --- a/GsaGH/Components/6_Display/ContourNodeResults.cs +++ b/GsaGH/Components/6_Display/ContourNodeResults.cs @@ -429,7 +429,7 @@ protected override void SolveInternal(IGH_DataAccess da) { case GsaResultGoo goo: { result = goo.Value; - if (result.Type == CaseType.Combination + if (result.Type == CaseType.CombinationCase && result.SelectedPermutationIds.Count > 1) { this.AddRuntimeWarning("Combination Case " + result.CaseId + " contains " + result.SelectedPermutationIds.Count @@ -439,7 +439,7 @@ protected override void SolveInternal(IGH_DataAccess da) { _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; } - if (result.Type == CaseType.Combination) { + if (result.Type == CaseType.CombinationCase) { _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; } diff --git a/GsaGH/Components/6_Display/ReactionForceDiagrams.cs b/GsaGH/Components/6_Display/ReactionForceDiagrams.cs index 3c011ad63..da55b3663 100644 --- a/GsaGH/Components/6_Display/ReactionForceDiagrams.cs +++ b/GsaGH/Components/6_Display/ReactionForceDiagrams.cs @@ -227,8 +227,7 @@ GsaResultsValues forceValues }); SetOutputs(da, reactionForceVectors, annotations); - PostHog.Result(result.Type, 0, GsaResultsValues.ResultType.Force, - _selectedDisplayValue.ToString()); + PostHog.Diagram("Result", result.Type, "ReactionForce", _selectedDisplayValue.ToString(), Parameters.EntityType.Node); } private double ComputeAutoScale(GsaResultsValues forceValues, BoundingBox bbox) { diff --git a/GsaGH/Components/6_Display/ResultDiagrams.cs b/GsaGH/Components/6_Display/ResultDiagrams.cs index 9269b8011..3e26c4aba 100644 --- a/GsaGH/Components/6_Display/ResultDiagrams.cs +++ b/GsaGH/Components/6_Display/ResultDiagrams.cs @@ -202,14 +202,14 @@ protected override void SolveInternal(IGH_DataAccess da) { if (ghTyp?.Value is GsaResultGoo goo) { result = goo.Value; switch (result.Type) { - case CaseType.Combination when result.SelectedPermutationIds.Count > 1: + case CaseType.CombinationCase when result.SelectedPermutationIds.Count > 1: string warningText = $"Combination Case {result.CaseId} contains {result.SelectedPermutationIds.Count} permutations - only one permutation can be displayed at a time.{Environment.NewLine}Displaying first permutation; please use the 'Select Results' to select other single permutations"; this.AddRuntimeWarning(warningText); _case = $"C{result.CaseId}"; break; - case CaseType.Combination: + case CaseType.CombinationCase: _case = $"C{result.CaseId}"; break; @@ -306,6 +306,10 @@ private List GenerateAnnotations( = $"{Math.Round(valResult * valueScaleFactor, significantDigits)} {Message}"; } + if (color == Color.Empty) { + color = (Color)annotation.Colour; + } + diagramAnnotations.Add(new GsaAnnotationGoo( new GsaAnnotationDot(location, color, valueToAnnotate))); } diff --git a/GsaGH/Components/GraveyardComp/Elem1dContourResults_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/Elem1dContourResults_OBSOLETE.cs index 7be123586..6728e0a70 100644 --- a/GsaGH/Components/GraveyardComp/Elem1dContourResults_OBSOLETE.cs +++ b/GsaGH/Components/GraveyardComp/Elem1dContourResults_OBSOLETE.cs @@ -356,7 +356,7 @@ protected override void SolveInternal(IGH_DataAccess da) { if (ghTyp.Value is GsaResultGoo goo) { result = goo.Value; switch (result.Type) { - case CaseType.Combination when result.SelectedPermutationIds.Count > 1: + 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 @@ -364,7 +364,7 @@ protected override void SolveInternal(IGH_DataAccess da) { _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; break; - case CaseType.Combination: + case CaseType.CombinationCase: _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; break; diff --git a/GsaGH/Components/GraveyardComp/Elem2dContourResults_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/Elem2dContourResults_OBSOLETE.cs index 39f698d65..f6a46f2b8 100644 --- a/GsaGH/Components/GraveyardComp/Elem2dContourResults_OBSOLETE.cs +++ b/GsaGH/Components/GraveyardComp/Elem2dContourResults_OBSOLETE.cs @@ -431,7 +431,7 @@ protected override void SolveInternal(IGH_DataAccess da) { if (ghTyp.Value is GsaResultGoo goo) { result = goo.Value; switch (result.Type) { - case CaseType.Combination when result.SelectedPermutationIds.Count > 1: + 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 @@ -439,7 +439,7 @@ protected override void SolveInternal(IGH_DataAccess da) { _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; break; - case CaseType.Combination: + case CaseType.CombinationCase: _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; break; diff --git a/GsaGH/Components/GraveyardComp/NodeContourResults_OBSOLETE.cs b/GsaGH/Components/GraveyardComp/NodeContourResults_OBSOLETE.cs index 187660f56..23767a273 100644 --- a/GsaGH/Components/GraveyardComp/NodeContourResults_OBSOLETE.cs +++ b/GsaGH/Components/GraveyardComp/NodeContourResults_OBSOLETE.cs @@ -309,7 +309,7 @@ protected override void SolveInternal(IGH_DataAccess da) { if (ghTyp.Value is GsaResultGoo goo) { result = goo.Value; switch (result.Type) { - case CaseType.Combination when result.SelectedPermutationIds.Count > 1: + 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 @@ -317,7 +317,7 @@ protected override void SolveInternal(IGH_DataAccess da) { _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; break; - case CaseType.Combination: + case CaseType.CombinationCase: _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; break; diff --git a/GsaGH/GsaGHInfo.cs b/GsaGH/GsaGHInfo.cs index b59a903a0..2f3725332 100644 --- a/GsaGH/GsaGHInfo.cs +++ b/GsaGH/GsaGHInfo.cs @@ -121,6 +121,7 @@ var ghLoadingException Instances.ComponentServer.AddCategoryIcon("GSA", Resources.GSALogo); Utility.InitialiseMainMenuAndDefaultUnits(); + RhinoApp.Closing += Helpers.GsaComHelper.Dispose; PostHog.PluginLoaded(PluginInfo.Instance, gsaVersion); diff --git a/GsaGH/Helpers/GsaCOM/GsaComHelper.cs b/GsaGH/Helpers/GsaCOM/GsaComHelper.cs index 4629e53b0..fdc3f3518 100644 --- a/GsaGH/Helpers/GsaCOM/GsaComHelper.cs +++ b/GsaGH/Helpers/GsaCOM/GsaComHelper.cs @@ -7,8 +7,6 @@ namespace GsaGH.Helpers { public sealed class GsaComObject { public static ComAuto Instance => lazy.Value; private static readonly Lazy lazy = new Lazy(() => new ComAuto()); - - private GsaComObject() { } } internal static class GsaComHelper { @@ -27,6 +25,10 @@ internal static ComAuto GetGsaComModel(GsaModel model) { return gsa; } + if (File.Exists(tempPath)) { + File.Delete(tempPath); + } + guid = model.Guid; tempPath = Path.GetTempPath() + guid.ToString() + ".gwb"; @@ -39,11 +41,19 @@ internal static ComAuto GetGsaComModel(GsaModel model) { internal static GsaModel GetGsaGhModel() { ComAuto gsa = GsaComObject.Instance; - gsa.SaveAs(tempPath); var gsaGh = new GsaModel(); gsaGh.Model.Open(tempPath); + return gsaGh; } + + internal static void Dispose(object sender, EventArgs e) { + if (File.Exists(tempPath)) { + File.Delete(tempPath); + } + + GsaComObject.Instance.Close(); + } } } diff --git a/GsaGH/Helpers/PostHog.cs b/GsaGH/Helpers/PostHog.cs index 417db1f6b..305d8ee0e 100644 --- a/GsaGH/Helpers/PostHog.cs +++ b/GsaGH/Helpers/PostHog.cs @@ -31,8 +31,8 @@ internal static void Diagram(string diagramType, CaseType caseType, string type, internal static void Diagram( string diagramType, string caseId, string type, List subTypes, EntityType entityType) { - CaseType caseType = caseId.StartsWith("L") ? CaseType.Load - : caseId.StartsWith("A") ? CaseType.AnalysisCase : CaseType.Combination; + CaseType caseType = caseId.StartsWith("L") ? CaseType.LoadCase + : caseId.StartsWith("A") ? CaseType.AnalysisCase : CaseType.CombinationCase; List subType = subTypes.ConvertAll(x => x.ToString()); Diagram(diagramType, caseType, type, string.Join(";", subTypes), entityType); } diff --git a/GsaGH/Parameters/5_Results/GsaResult.cs b/GsaGH/Parameters/5_Results/GsaResult.cs index 5dc918291..bb4582c22 100644 --- a/GsaGH/Parameters/5_Results/GsaResult.cs +++ b/GsaGH/Parameters/5_Results/GsaResult.cs @@ -344,7 +344,7 @@ internal GsaResult( GsaModel model, CombinationCaseResult result, int caseId, IEnumerable permutations) { Model = model; CombinationCaseResult = result; - Type = CaseType.Combination; + Type = CaseType.CombinationCase; CaseId = caseId; SelectedPermutationIds = permutations.OrderBy(x => x).ToList(); } @@ -360,7 +360,7 @@ public override string ToString() { txt = "A" + CaseId; break; - case CaseType.Combination: { + case CaseType.CombinationCase: { txt = "C" + CaseId; if (SelectedPermutationIds.Count > 0) { txt = SelectedPermutationIds.Count > 1 ? txt + " P:" + SelectedPermutationIds.Count : diff --git a/GsaGH/Parameters/Enums/CaseType.cs b/GsaGH/Parameters/Enums/CaseType.cs index 987871fbc..389b09719 100644 --- a/GsaGH/Parameters/Enums/CaseType.cs +++ b/GsaGH/Parameters/Enums/CaseType.cs @@ -1,7 +1,7 @@ namespace GsaGH.Parameters { public enum CaseType { - Load, + LoadCase, AnalysisCase, - Combination + CombinationCase } } diff --git a/GsaGHTests/3_Components/5_Results/GetResultsTest.cs b/GsaGHTests/3_Components/5_Results/GetResultsTest.cs index a283dff13..50d56087f 100644 --- a/GsaGHTests/3_Components/5_Results/GetResultsTest.cs +++ b/GsaGHTests/3_Components/5_Results/GetResultsTest.cs @@ -61,7 +61,7 @@ public void TestCombinationNoPermutation() { ComponentTestHelper.SetInput(comp, 1, 2); var result = (GsaResultGoo)ComponentTestHelper.GetOutput(comp); - Assert.Equal(CaseType.Combination, result.Value.Type); + Assert.Equal(CaseType.CombinationCase, result.Value.Type); Assert.Equal(1, result.Value.CaseId); Assert.Equal(new List() { 1, @@ -84,7 +84,7 @@ public void TestCombinationWithPermutation() { ComponentTestHelper.SetInput(comp, 1, 3); var result = (GsaResultGoo)ComponentTestHelper.GetOutput(comp); - Assert.Equal(CaseType.Combination, result.Value.Type); + Assert.Equal(CaseType.CombinationCase, result.Value.Type); Assert.Equal(1, result.Value.CaseId); Assert.Equal(new List() { 1, diff --git a/GsaGHTests/3_Components/ComponentsTests.cs b/GsaGHTests/3_Components/ComponentsTests.cs index 624352502..e32a7924b 100644 --- a/GsaGHTests/3_Components/ComponentsTests.cs +++ b/GsaGHTests/3_Components/ComponentsTests.cs @@ -125,10 +125,10 @@ public void WhenInitialiseDropdowns_ThenDropDownItems_ShouldBeNull(Type t) { [InlineData(typeof(Contour2dResults), "Displacement", "Footfall")] [InlineData(typeof(Element2dDisplacements), "mm", "ft")] [InlineData(typeof(Element2dForcesAndMoments), "kN/m", "kipf/ft")] - [InlineData(typeof(Element2dStresses), "Megapascal", "kipf/ft²")] + [InlineData(typeof(Element2dStresses), "MPa", "kipf/ft²")] [InlineData(typeof(Contour3dResults), "Displacement", "Stress")] [InlineData(typeof(Element3dDisplacements), "mm", "ft")] - [InlineData(typeof(Element3dStresses), "Megapascal", "kipf/ft²")] + [InlineData(typeof(Element3dStresses), "MPa", "kipf/ft²")] [InlineData(typeof(GlobalPerformanceResults), "t", "slug")] [InlineData(typeof(ContourNodeResults), "Displacement", "Footfall")] [InlineData(typeof(NodeDisplacements), "mm", "ft")] diff --git a/IntegrationTests/2_Parameters/3_Loads/GridPointLoadTests.cs b/IntegrationTests/2_Parameters/3_Loads/GridPointLoadTests.cs new file mode 100644 index 000000000..64be1e366 --- /dev/null +++ b/IntegrationTests/2_Parameters/3_Loads/GridPointLoadTests.cs @@ -0,0 +1,42 @@ +using System; +using System.IO; +using System.Reflection; +using Grasshopper.Kernel; +using Xunit; + +namespace IntegrationTests.Parameters { + [Collection("GrasshopperFixture collection")] + public class GridPointLoadTests { + public static GH_Document Document => document ?? (document = OpenDocument()); + private static GH_Document document = null; + + [Theory] + [InlineData("LoadIsEqual", 0)] + [InlineData("PointIsEqual", 0)] + public void TestTxtInput(string groupIdentifier, object expected) { + IGH_Param param = Helper.FindParameter(Document, groupIdentifier); + Helper.TestGhPrimitives(param, expected); + } + + private static GH_Document OpenDocument() { + string fileName = MethodBase.GetCurrentMethod().DeclaringType + ".gh"; + fileName = fileName.Replace("IntegrationTests.Parameters.", string.Empty) + .Replace("Tests", string.Empty); + + string solutiondir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent + .Parent.FullName; + string path = Path.Combine(new string[] { + solutiondir, + "ExampleFiles", + "Parameters", + "3_Loads", + }); + var io = new GH_DocumentIO(); + Assert.True(File.Exists(Path.Combine(path, fileName))); + Assert.True(io.Open(Path.Combine(path, fileName))); + io.Document.NewSolution(true); + + return io.Document; + } + } +}