From bb4e3ccf00c924ac722244b28664d21cf081a97a Mon Sep 17 00:00:00 2001 From: Tilman Reinhardt Date: Thu, 5 Oct 2023 14:28:22 +0200 Subject: [PATCH 1/2] GSAGH-384 ListSeparator --- GsaGH/Parameters/3_Loads/GridLoadHelper.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/GsaGH/Parameters/3_Loads/GridLoadHelper.cs b/GsaGH/Parameters/3_Loads/GridLoadHelper.cs index 611ec4516..08e5f8ee7 100644 --- a/GsaGH/Parameters/3_Loads/GridLoadHelper.cs +++ b/GsaGH/Parameters/3_Loads/GridLoadHelper.cs @@ -1,10 +1,14 @@ -using OasysUnits; +using System.Globalization; +using System; +using OasysUnits; using Rhino.Collections; using Rhino.Geometry; using LengthUnit = OasysUnits.Units.LengthUnit; namespace GsaGH.Parameters { internal static class GridLoadHelper { + private static readonly char ListSeparator = Convert.ToChar(CultureInfo.CurrentCulture.TextInfo.ListSeparator); + internal static string CreateDefinition(Point3dList controlPoints, Plane plane) { string desc = string.Empty; for (int i = 0; i < controlPoints.Count; i++) { @@ -32,8 +36,8 @@ internal static Point3dList ConvertPoints(string definition, LengthUnit desiredU foreach (string ptStr in pts) { if (ptStr != string.Empty) { string pt = ptStr.Replace("(", string.Empty).Trim(); - var x = new Length(double.Parse(pt.Split(',')[0]), lengthUnit); - var y = new Length(double.Parse(pt.Split(',')[1]), lengthUnit); + var x = new Length(double.Parse(pt.Split(ListSeparator)[0]), lengthUnit); + var y = new Length(double.Parse(pt.Split(ListSeparator)[1]), lengthUnit); var point = new Point3d(x.As(desiredUnit), y.As(desiredUnit), 0); point.Transform(map); points.Add(point); From 26ff33035c2f382ec3eba893a61fbce31d78da70 Mon Sep 17 00:00:00 2001 From: Tilman Reinhardt Date: Thu, 5 Oct 2023 14:50:03 +0200 Subject: [PATCH 2/2] GSAGH-384 GridLoadHelper.ListSeparator --- GsaGH/Parameters/3_Loads/GridLoadHelper.cs | 13 ++++++++++--- .../3_Components/3_Loads/CreateGridLineLoadTests.cs | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/GsaGH/Parameters/3_Loads/GridLoadHelper.cs b/GsaGH/Parameters/3_Loads/GridLoadHelper.cs index 08e5f8ee7..7fb455c00 100644 --- a/GsaGH/Parameters/3_Loads/GridLoadHelper.cs +++ b/GsaGH/Parameters/3_Loads/GridLoadHelper.cs @@ -1,5 +1,4 @@ -using System.Globalization; -using System; +using GsaAPI; using OasysUnits; using Rhino.Collections; using Rhino.Geometry; @@ -7,7 +6,7 @@ namespace GsaGH.Parameters { internal static class GridLoadHelper { - private static readonly char ListSeparator = Convert.ToChar(CultureInfo.CurrentCulture.TextInfo.ListSeparator); + internal static char ListSeparator = GetListSeparator(); internal static string CreateDefinition(Point3dList controlPoints, Plane plane) { string desc = string.Empty; @@ -67,5 +66,13 @@ private static (LengthUnit lengthUnit, string def) ClearDefGetUnit(string defini definition = definition.Replace("(m)", string.Empty); return (lengthUnit, definition); } + + internal static char GetListSeparator() { + // this is a hack, because GSA doesn´t use CultureInfo.CurrentCulture.TextInfo.ListSeparator + var gridLineLoad = new GridLineLoad { + PolyLineDefinition = "(0, 0) (1, 0) (m)" + }; + return gridLineLoad.PolyLineDefinition[2]; + } } } diff --git a/GsaGHTests/3_Components/3_Loads/CreateGridLineLoadTests.cs b/GsaGHTests/3_Components/3_Loads/CreateGridLineLoadTests.cs index ca8af7a44..49cc9ece1 100644 --- a/GsaGHTests/3_Components/3_Loads/CreateGridLineLoadTests.cs +++ b/GsaGHTests/3_Components/3_Loads/CreateGridLineLoadTests.cs @@ -21,7 +21,7 @@ public void CreateGridLineLoadTest() { var output = (GsaLoadGoo)ComponentTestHelper.GetOutput(comp); var load = (GsaGridLineLoad)output.Value; Assert.Equal(7, load.LoadCase.Id); - Assert.Equal("(10,5) (20,6)(m)", load.ApiLoad.PolyLineDefinition); + Assert.Equal("(10" + GridLoadHelper.ListSeparator + "5) (20" + GridLoadHelper.ListSeparator + "6)(m)", load.ApiLoad.PolyLineDefinition); Assert.Equal(0, load.ApiLoad.PolyLineReference); Assert.Equal("myGridLineLoad", load.ApiLoad.Name); Assert.Equal(-5000, load.ApiLoad.ValueAtStart);