Skip to content

Commit

Permalink
GSAGH-384-Import-gridload-for-certain-locale-settings-fails (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlmnrnhrdt authored Oct 6, 2023
2 parents 59a1b0d + de6fc80 commit 362cef2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions GsaGH/Parameters/3_Loads/GridLoadHelper.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using OasysUnits;
using GsaAPI;
using OasysUnits;
using Rhino.Collections;
using Rhino.Geometry;
using LengthUnit = OasysUnits.Units.LengthUnit;

namespace GsaGH.Parameters {
internal static class GridLoadHelper {
internal static char ListSeparator = GetListSeparator();

internal static string CreateDefinition(Point3dList controlPoints, Plane plane) {
string desc = string.Empty;
for (int i = 0; i < controlPoints.Count; i++) {
Expand Down Expand Up @@ -32,8 +35,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);
Expand Down Expand Up @@ -63,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];
}
}
}
2 changes: 1 addition & 1 deletion GsaGHTests/3_Components/3_Loads/CreateGridLineLoadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 362cef2

Please sign in to comment.