From b921cad75f48d4f6e4e01f0d881c8e44ba38af50 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Mon, 27 Oct 2025 18:10:47 +0100 Subject: [PATCH 01/20] Add support for RFEM6 free polygon loads Implemented reading and conversion of RFEM6 free polygon loads as AreaUniformlyDistributedLoad objects. Added ReadPolygonLoad method and FromRFEM conversion for free_polygon_load, including handling of load direction, axis, and projection. Updated unit test to enable pulling panels for verification. --- .../BHoMDataStructure/Geometry/Panel/Panel.cs | 8 +-- .../Read/BHoMDataStructure/Loading/Load.cs | 61 +++++++++++++++- .../BHoMDataStructure/Loading/Load.cs | 69 +++++++++++++++++++ 3 files changed, 132 insertions(+), 6 deletions(-) diff --git a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Geometry/Panel/Panel.cs b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Geometry/Panel/Panel.cs index 214edfa1..aeba99d2 100644 --- a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Geometry/Panel/Panel.cs +++ b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Geometry/Panel/Panel.cs @@ -116,12 +116,12 @@ public void InitializeOpenings() public void PushPullPanel() { - adapter.Push(new List() { panel1}); + //adapter.Push(new List() { panel1}); //// Pull it - //FilterRequest panelFilter = new FilterRequest() { Type = typeof(Panel) }; - //var panelPulled = adapter.Pull(panelFilter).ToList(); - //Panel pp = (Panel)panelPulled[0]; + FilterRequest panelFilter = new FilterRequest() { Type = typeof(Panel) }; + var panelPulled = adapter.Pull(panelFilter).ToList(); + Panel pp = (Panel)panelPulled[0]; //// Check //Assert.IsNotNull(pp); diff --git a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs index ea43e64b..79991fbc 100644 --- a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs @@ -117,6 +117,7 @@ private List ReadPointLoad(List ids = null) private List ReadAreaLoad(List ids = null) { + List loads = new List(); //Find all possible Load cases @@ -144,10 +145,66 @@ private List ReadAreaLoad(List ids = null) } - return loads; + + rfModel.object_with_children[] numbers_ = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_FREE_POLYGON_LOAD); + + //IEnumerable foundSurfaceLoad = numbers.ToList().Select(n => m_Model.get_surface_load(n.children[0], n.no)); + IEnumerable foundPolygonLoad_ = numbers_.SelectMany(n => n.children.Select(child => m_Model.get_free_polygon_load(child, n.no))); + + foundPolygonLoad_ = foundPolygonLoad_.OrderBy(n => n.load_case).ThenBy(t => t.no); + foreach (rfModel.free_polygon_load polygonLoad in foundPolygonLoad_) + { + List panels = polygonLoad.surfaces.ToList().Select(s => panelMap[s]).ToList(); + Loadcase loadcase = loadCaseMap[polygonLoad.load_case]; + + if (!(polygonLoad.load_distribution is rfModel.free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM) + { + Engine.Base.Compute.RecordNote("The current RFEM6 includes Surfaceloads with a non-uniformal load distributeion, these Loads will not be pulled."); + continue; + } + + loads.Add(polygonLoad.FromRFEM(loadCaseMap[polygonLoad.load_case], panels)); + + } + + + return loads; } - private List ReadFreeLineLoad(List ids = null) + private List ReadPolygonLoad(List ids = null) + { + List loads = new List(); + + //Find all possible Load cases + Dictionary loadCaseMap = this.GetCachedOrReadAsDictionary(); + Dictionary panelMap = this.GetCachedOrReadAsDictionary(); + + rfModel.object_with_children[] numbers = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_FREE_POLYGON_LOAD); + + //IEnumerable foundSurfaceLoad = numbers.ToList().Select(n => m_Model.get_surface_load(n.children[0], n.no)); + IEnumerable foundPolygonLoad = numbers.SelectMany(n => n.children.Select(child => m_Model.get_free_polygon_load(child, n.no))); + + foundPolygonLoad = foundPolygonLoad.OrderBy(n => n.load_case).ThenBy(t => t.no); + foreach (rfModel.free_polygon_load polLoad in foundPolygonLoad) + { + List panels = polLoad.surfaces.ToList().Select(s => panelMap[s]).ToList(); + Loadcase loadcase = loadCaseMap[polLoad.load_case]; + + if (!(polLoad.load_distribution is rfModel.free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM)) + { + Engine.Base.Compute.RecordNote("The current RFEM6 includes Surfaceloads with a non-uniformal load distributeion, these Loads will not be pulled."); + continue; + } + + loads.Add(polLoad.FromRFEM(loadCaseMap[polLoad.load_case], panels)); + + } + + return loads; + } + + + private List ReadFreeLineLoad(List ids = null) { List loads = new List(); diff --git a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs index 82220a9e..b8de3b54 100644 --- a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs @@ -185,6 +185,75 @@ public static PointLoad FromRFEM(this rfModel.nodal_load nodeLoad, List bh return bhLoad; } + public static AreaUniformlyDistributedLoad FromRFEM(this rfModel.free_polygon_load polygonLoad, Loadcase loadcase, List panels) + { + + Vector forceDirection; + bool isProjected = false; + LoadAxis axis = LoadAxis.Global; + + switch (polygonLoad.load_direction) + { + //case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE: + case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_X_TRUE: + forceDirection = BH.Engine.Geometry.Create.Vector(polygonLoad.magnitude_uniform, 0, 0); + break; + //case surface_load_load_direction.LOAD_DIRECTION_LOCAL_X: + case free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_X: + forceDirection = BH.Engine.Geometry.Create.Vector(polygonLoad.magnitude_uniform, 0, 0); + axis = LoadAxis.Local; + break; + + //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_OR_USER_DEFINED_V_TRUE: + case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_TRUE: + forceDirection = BH.Engine.Geometry.Create.Vector(0, polygonLoad.magnitude_uniform, 0); + break; + //case surface_load_load_direction.LOAD_DIRECTION_LOCAL_Y: + case free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Y: + forceDirection = BH.Engine.Geometry.Create.Vector(0, polygonLoad.magnitude_uniform, 0); + axis = LoadAxis.Local; + break; + + //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_OR_USER_DEFINED_W_TRUE: + case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_TRUE: + forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform); + break; + //case surface_load_load_direction.LOAD_DIRECTION_LOCAL_Z: + case free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Z: + forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform); + axis = LoadAxis.Local; + break; + + //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_PROJECTED: + case free_polygon_load_load_direction.LOAD_DIRECTION_USER_DEFINED_U_PROJECTED: + forceDirection = BH.Engine.Geometry.Create.Vector(polygonLoad.magnitude_uniform, 0, 0); + isProjected = true; + break; + + //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_OR_USER_DEFINED_V_PROJECTED: + case free_polygon_load_load_direction.LOAD_DIRECTION_USER_DEFINED_V_PROJECTED: + forceDirection = BH.Engine.Geometry.Create.Vector(0, polygonLoad.magnitude_uniform, 0); + isProjected = true; + break; + + //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_OR_USER_DEFINED_W_PROJECTED: + case free_polygon_load_load_direction.LOAD_DIRECTION_USER_DEFINED_W_PROJECTED: + forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform); + isProjected = true; + break; + + default: + forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform); + break; + } + + + AreaUniformlyDistributedLoad bhAreaload = BH.Engine.Structure.Create.AreaUniformlyDistributedLoad(loadcase, forceDirection, panels, axis, isProjected, polygonLoad.comment); + bhAreaload.SetHashFragment(); + + return bhAreaload; + } + public static AreaUniformlyDistributedLoad FromRFEM(this rfModel.surface_load surfaceload, Loadcase loadcase, List panels) { From 5be0779405daf1eaa1fd1ac00ad8b5286ec7c571 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Tue, 28 Oct 2025 10:40:12 +0100 Subject: [PATCH 02/20] Support polygon geometry for area loads in RFEM6 adapter Added logic to extract and construct polygon geometry from RFEM6 polygon load data, handling different projection types. The resulting polygon is now attached to AreaUniformlyDistributedLoad objects. Also added a unit test for pulling uniformly distributed area loads and commented out a redundant panel push in test setup. --- .../Loading/UniformlyDistributedAreaLoad.cs | 14 +++++- .../Read/BHoMDataStructure/Loading/Load.cs | 2 +- .../BHoMDataStructure/Loading/Load.cs | 50 ++++++++++++++++++- 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Loading/UniformlyDistributedAreaLoad.cs b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Loading/UniformlyDistributedAreaLoad.cs index 5d1cb238..62b61e10 100644 --- a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Loading/UniformlyDistributedAreaLoad.cs +++ b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Loading/UniformlyDistributedAreaLoad.cs @@ -142,7 +142,7 @@ public void InitializeOpenings() [SetUp] public void SetUp() { - adapter.Push(new List() { panel1, panel2, panel3 }); + //adapter.Push(new List() { panel1, panel2, panel3 }); } @@ -268,7 +268,19 @@ public void PushOfReversedAreaUniformlyDistributedLoad() Assert.True(this.reverseAreaLoadList[i].Axis.Equals(areaLoadList[i].Axis)); } + [Test] + public void PullUniformlyDistributedLoad() + { + + //Act + + // Push + // Pull + FilterRequest loadFilter = new FilterRequest() { Type = typeof(AreaUniformlyDistributedLoad) }; + List areaLoadList = adapter.Pull(loadFilter).ToList().Select(p => (AreaUniformlyDistributedLoad)p).ToList(); + var a = areaLoadList.First(); + } } diff --git a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs index 79991fbc..7f4ce080 100644 --- a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs @@ -157,7 +157,7 @@ private List ReadAreaLoad(List ids = null) List panels = polygonLoad.surfaces.ToList().Select(s => panelMap[s]).ToList(); Loadcase loadcase = loadCaseMap[polygonLoad.load_case]; - if (!(polygonLoad.load_distribution is rfModel.free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM) + if (!(polygonLoad.load_distribution is rfModel.free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM)) { Engine.Base.Compute.RecordNote("The current RFEM6 includes Surfaceloads with a non-uniformal load distributeion, these Loads will not be pulled."); continue; diff --git a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs index b8de3b54..1f574bf8 100644 --- a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs @@ -191,6 +191,51 @@ public static AreaUniformlyDistributedLoad FromRFEM(this rfModel.free_polygon_lo Vector forceDirection; bool isProjected = false; LoadAxis axis = LoadAxis.Global; + List firstCoordinate = polygonLoad.load_location.ToList().Select(r => r.row.first_coordinate).ToList(); + List secondCoordinate = polygonLoad.load_location.ToList().Select(r => r.row.second_coordinate).ToList(); + List thirdCoordinate = Enumerable.Repeat(0.0, firstCoordinate.Count).ToList(); + List loadPolygon = new List(); + + switch (polygonLoad.load_projection) + { + case free_polygon_load_load_projection.LOAD_PROJECTION_XY_OR_UV: + + loadPolygon = firstCoordinate.Select((x, i) => new Point() + { + X = x, + Y = secondCoordinate[i], + Z = thirdCoordinate[i] + }).ToList(); + + + break; + + case free_polygon_load_load_projection.LOAD_PROJECTION_YZ_OR_VW: + + loadPolygon = firstCoordinate.Select((x, i) => new Point() + { + X = thirdCoordinate[i], + Y = x, + Z = secondCoordinate[i] + }).ToList(); + + break; + + default: + + loadPolygon = firstCoordinate.Select((x, i) => new Point() + { + X = secondCoordinate[i], + Y = thirdCoordinate[i], + Z = x + }).ToList(); + + break; + + + } + + var polygon = BH.Engine.Geometry.Create.Polygon(loadPolygon); switch (polygonLoad.load_direction) { @@ -221,7 +266,7 @@ public static AreaUniformlyDistributedLoad FromRFEM(this rfModel.free_polygon_lo //case surface_load_load_direction.LOAD_DIRECTION_LOCAL_Z: case free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Z: forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform); - axis = LoadAxis.Local; + axis = LoadAxis.Local; break; //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_PROJECTED: @@ -249,7 +294,8 @@ public static AreaUniformlyDistributedLoad FromRFEM(this rfModel.free_polygon_lo AreaUniformlyDistributedLoad bhAreaload = BH.Engine.Structure.Create.AreaUniformlyDistributedLoad(loadcase, forceDirection, panels, axis, isProjected, polygonLoad.comment); - bhAreaload.SetHashFragment(); + bhAreaload = bhAreaload.SetHashFragment("Polygon"); + bhAreaload.SetPropertyValue("Polygon", polygon); return bhAreaload; } From 790185718844ef7060d8504adc77f8d7dd67168f Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Tue, 28 Oct 2025 16:22:42 +0100 Subject: [PATCH 03/20] Add support for polygon area loads in RFEM6 adapter Introduces handling of AreaUniformlyDistributedLoad objects with Polygon custom data. Adds CreateLoad_Polygon method and ToRFEM6_Polygon extension to convert and assign polygonal area loads to RFEM6, supporting different plane orientations and load directions. --- .../Create/BHoMDataStructure/Loading/Load.cs | 17 +++ .../ToRFEM6/BHoMDataStructure/Loading/Load.cs | 133 ++++++++++++++++++ 2 files changed, 150 insertions(+) diff --git a/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs index 1a9ce6de..c2874a94 100644 --- a/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs @@ -61,6 +61,10 @@ private bool CreateCollection(IEnumerable bhLoads) if (bhLoad is AreaUniformlyDistributedLoad) { + if (bhLoad.CustomData.Values.Any(l=>l is Polygon)) { + CreateLoad_Polygon(bhLoad as AreaUniformlyDistributedLoad); + continue; + } CreateLoad(bhLoad as AreaUniformlyDistributedLoad); continue; } @@ -233,6 +237,19 @@ private void CreateLoad(AreaUniformlyDistributedLoad bhLoad) } + private void CreateLoad_Polygon(AreaUniformlyDistributedLoad bhLoad) + { + UpdateLoadIdDictionary(bhLoad); + //Call Panel Load Methond to update the Panel ID Dictionary + this.GetCachedOrReadAsDictionary(); + int id = m_LoadcaseLoadIdDict[bhLoad.Loadcase][bhLoad.GetType().Name]; + free_polygon_load rfemAreaLoad = (bhLoad as AreaUniformlyDistributedLoad).ToRFEM6_Polygon(id); + var currrSurfaceIds = (bhLoad as AreaUniformlyDistributedLoad).Objects.Elements.ToList().Select(e => m_PanelIDdict[e as Panel]).ToArray(); + rfemAreaLoad.surfaces = currrSurfaceIds; + m_Model.set_free_polygon_load(bhLoad.Loadcase.Number, rfemAreaLoad); + + } + private void CreateLoad(BarUniformlyDistributedLoad bhLoad) { diff --git a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs index 6c4b2380..841c4340 100644 --- a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs @@ -36,6 +36,8 @@ using Dlubal.WS.Rfem6.Model; using BH.Engine.Geometry; using BH.oM.Geometry; +using BH.Engine.Spatial; +using System.Transactions; namespace BH.Adapter.RFEM6 { @@ -263,6 +265,137 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA } + public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistributedLoad bhAreaLoad, int loadCaseSpecificLoadId) + { + + Polygon polgon = (Polygon)bhAreaLoad.CustomData.Values.First(p => p is Polygon); + List polygonValues = new List(); + var fitPlane=polgon.IFitPlane(); + if (fitPlane.Normal.CrossProduct(Plane.XY.Normal).Length() < 0.01) + { + polygonValues=polgon.Vertices.Select(v => new double[] { v.X, v.Y }).ToList(); + } + else if (fitPlane.Normal.CrossProduct(Plane.XZ.Normal).Length() < 0.01) + { + polygonValues=polgon.Vertices.Select(v => new double[] { v.X, v.Z }).ToList(); + + } + else { + polygonValues=polgon.Vertices.Select(v => new double[] { v.Y, v.Z }).ToList(); + + } + + free_polygon_load_load_location k = new free_polygon_load_load_location() { first_coordinate = 10, second_coordinate = 100 }; + free_polygon_load_load_location_row r = new free_polygon_load_load_location_row() { row = k }; + free_polygon_load_load_location_row[] locationPolygons = polygonValues.Select((v, i) => new free_polygon_load_load_location_row() + { + no = (i+1), + description=(i+1)+"", + row = new free_polygon_load_load_location() + { + magnitude=0, + magnitudeSpecified=false, + first_coordinate = v[0], + first_coordinateSpecified = true, + second_coordinate = v[1], + second_coordinateSpecified = true + + } + } + + ).ToArray(); + + double loadMagintude; + free_polygon_load_load_direction loadDirection; + Vector orientationVector = bhAreaLoad.Pressure; + + if (bhAreaLoad.Projected && bhAreaLoad.Axis == LoadAxis.Local) + { + BH.Engine.Base.Compute.RecordWarning("Projected Area Load is not supported for Local Axis. The Load will be projected to the Global Axis"); + } + + // Checkinf if Load is Orientied in X directin + if (orientationVector.X != 0) + { + // If the load Axis in slocal the load direction is local x + if (bhAreaLoad.Axis.Equals(LoadAxis.Local)) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_X; + } + else if (bhAreaLoad.Projected) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_X_PROJECTED; + } + else + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_X_TRUE; + } + loadMagintude = orientationVector.X; + + } + else if (orientationVector.Y != 0) + { + if (bhAreaLoad.Axis.Equals(LoadAxis.Local)) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Y; + } + else if (bhAreaLoad.Projected) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_PROJECTED; + } + else + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_TRUE; + } + loadMagintude = orientationVector.Y; + + } + else + { + if (bhAreaLoad.Axis.Equals(LoadAxis.Local)) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Z; + } + else if (bhAreaLoad.Projected) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_PROJECTED; + } + else + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_TRUE; + } + loadMagintude = orientationVector.Z; + } + + + + free_polygon_load rfSurfaceLoad = new rfModel.free_polygon_load() + { + no = loadCaseSpecificLoadId, + comment = bhAreaLoad.Name, + surfaces = bhAreaLoad.Objects.Elements.ToList().Select(x => (x as Panel).GetRFEM6ID()).ToArray(), + load_case = bhAreaLoad.Loadcase.Number, + load_caseSpecified = true, + load_distribution = free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM, + load_distributionSpecified = true, + magnitude_linear_1 = loadMagintude, + magnitude_linear_1Specified = true, + magnitude_uniform = loadMagintude, + magnitude_uniformSpecified = true, + is_generated = false, + is_generatedSpecified = true, + load_direction = loadDirection, + load_directionSpecified = true, + load_location = locationPolygons, + load_projection = free_polygon_load_load_projection.LOAD_PROJECTION_XY_OR_UV, + load_projectionSpecified = true + }; + + + return rfSurfaceLoad; + + } + public static rfModel.free_line_load ToRFEM6(this GeometricalLineLoad bhLineLoad, int loadCaseSpecificID, int[] surfaceIds) { From 673f5d29ef1e519fe16740363bdcdf79dbab4629 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Tue, 28 Oct 2025 17:08:51 +0100 Subject: [PATCH 04/20] Set load projection dynamically based on polygon plane Updated the logic to assign the load_projection value according to the orientation of the polygon's fit plane, ensuring correct projection for XY, XZ, or YZ planes. This replaces the previous hardcoded value and improves accuracy for different polygon orientations. --- .../Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs index 841c4340..54e68395 100644 --- a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs @@ -270,18 +270,21 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri Polygon polgon = (Polygon)bhAreaLoad.CustomData.Values.First(p => p is Polygon); List polygonValues = new List(); + var loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XZ_OR_UW; var fitPlane=polgon.IFitPlane(); if (fitPlane.Normal.CrossProduct(Plane.XY.Normal).Length() < 0.01) { polygonValues=polgon.Vertices.Select(v => new double[] { v.X, v.Y }).ToList(); + loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XY_OR_UV; } else if (fitPlane.Normal.CrossProduct(Plane.XZ.Normal).Length() < 0.01) { polygonValues=polgon.Vertices.Select(v => new double[] { v.X, v.Z }).ToList(); - + loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XZ_OR_UW; } else { polygonValues=polgon.Vertices.Select(v => new double[] { v.Y, v.Z }).ToList(); + loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_YZ_OR_VW; } @@ -387,7 +390,7 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri load_direction = loadDirection, load_directionSpecified = true, load_location = locationPolygons, - load_projection = free_polygon_load_load_projection.LOAD_PROJECTION_XY_OR_UV, + load_projection = loadProjection, load_projectionSpecified = true }; From 94fc3b7969e01ce060b8028b0d591a44ec227d84 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Tue, 28 Oct 2025 17:22:39 +0100 Subject: [PATCH 05/20] Add error handling to CreateLoad_Polygon method Wrapped the CreateLoad_Polygon logic in a try-catch block to record errors when load creation fails, such as when the polygon is non-planar or not parallel to principal planes. This improves robustness and provides clearer error reporting. --- .../Create/BHoMDataStructure/Loading/Load.cs | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs index c2874a94..966825ba 100644 --- a/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs @@ -239,15 +239,20 @@ private void CreateLoad(AreaUniformlyDistributedLoad bhLoad) private void CreateLoad_Polygon(AreaUniformlyDistributedLoad bhLoad) { - UpdateLoadIdDictionary(bhLoad); - //Call Panel Load Methond to update the Panel ID Dictionary - this.GetCachedOrReadAsDictionary(); - int id = m_LoadcaseLoadIdDict[bhLoad.Loadcase][bhLoad.GetType().Name]; - free_polygon_load rfemAreaLoad = (bhLoad as AreaUniformlyDistributedLoad).ToRFEM6_Polygon(id); - var currrSurfaceIds = (bhLoad as AreaUniformlyDistributedLoad).Objects.Elements.ToList().Select(e => m_PanelIDdict[e as Panel]).ToArray(); - rfemAreaLoad.surfaces = currrSurfaceIds; - m_Model.set_free_polygon_load(bhLoad.Loadcase.Number, rfemAreaLoad); - + try + { + UpdateLoadIdDictionary(bhLoad); + //Call Panel Load Methond to update the Panel ID Dictionary + this.GetCachedOrReadAsDictionary(); + int id = m_LoadcaseLoadIdDict[bhLoad.Loadcase][bhLoad.GetType().Name]; + free_polygon_load rfemAreaLoad = (bhLoad as AreaUniformlyDistributedLoad).ToRFEM6_Polygon(id); + var currrSurfaceIds = (bhLoad as AreaUniformlyDistributedLoad).Objects.Elements.ToList().Select(e => m_PanelIDdict[e as Panel]).ToArray(); + rfemAreaLoad.surfaces = currrSurfaceIds; + m_Model.set_free_polygon_load(bhLoad.Loadcase.Number, rfemAreaLoad); + + } catch { + BH.Engine.Base.Compute.RecordError($"The creation of {bhLoad} failed.\nA potential cause is that the applied polygon is non-planar or not parallel to the XY, YZ, or ZX plane."); + } } private void CreateLoad(BarUniformlyDistributedLoad bhLoad) From dc91c7879f3f36fb8ac74ed0bce46cfea3da4c47 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Mon, 3 Nov 2025 12:15:08 +0100 Subject: [PATCH 06/20] Add warnings for unsupported 'Projected' option with Local axis Added warnings in Load.cs to notify users when the 'Projected' option is set for area loads with the Local axis, as this combination is not supported and will be ignored. Also removed commented-out code in Panel.cs and filtered out invalid line numbers in RFEMLine.cs. --- RFEM6_Adapter/CRUD/Read/IntermediateDatastructure/RFEMLine.cs | 2 +- .../Convert/FromRFEM6/BHoMDataStructure/Geometry/Panel.cs | 4 ---- .../Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs | 4 ++++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/RFEM6_Adapter/CRUD/Read/IntermediateDatastructure/RFEMLine.cs b/RFEM6_Adapter/CRUD/Read/IntermediateDatastructure/RFEMLine.cs index 188a1a96..b35d04c8 100644 --- a/RFEM6_Adapter/CRUD/Read/IntermediateDatastructure/RFEMLine.cs +++ b/RFEM6_Adapter/CRUD/Read/IntermediateDatastructure/RFEMLine.cs @@ -43,7 +43,7 @@ private List ReadLines(List ids = null) List lineList = new List(); - var lineNumbers = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_LINE); + var lineNumbers = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_LINE).Where(l => l.no > 0); var allRfLInes = lineNumbers.ToList().Select(n => m_Model.get_line(n.no)); //var lineSupportNumbers = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_LINE); diff --git a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Geometry/Panel.cs b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Geometry/Panel.cs index a5033c4b..72c76db5 100644 --- a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Geometry/Panel.cs +++ b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Geometry/Panel.cs @@ -45,10 +45,6 @@ public static partial class Convert public static Panel FromRFEM(this rfModel.surface rfSurface, Dictionary edgeDict, Dictionary surfaceProperty, HashSet openingIDs, Dictionary surfaceOpening) { - //HashSet openingIDs = new HashSet(); - - //openingIDDict.TryGetValue(rfPanelNo,out openingIDs); - List rfEdgeNumbers = rfSurface.boundary_lines.ToList(); List bhEdges = rfEdgeNumbers.Select(n => edgeDict[n]).ToList(); diff --git a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs index 54e68395..da3a5769 100644 --- a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs @@ -324,6 +324,8 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri if (bhAreaLoad.Axis.Equals(LoadAxis.Local)) { loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_X; + if (bhAreaLoad.Projected) BH.Engine.Base.Compute.RecordWarning($"The 'Projected' option for {bhAreaLoad} is not supported when the Axis is set to Local and will therefore be ignored."); + } else if (bhAreaLoad.Projected) { @@ -341,6 +343,7 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri if (bhAreaLoad.Axis.Equals(LoadAxis.Local)) { loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Y; + if (bhAreaLoad.Projected) BH.Engine.Base.Compute.RecordWarning($"The 'Projected' option for {bhAreaLoad} is not supported when the Axis is set to Local and will therefore be ignored."); } else if (bhAreaLoad.Projected) { @@ -358,6 +361,7 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri if (bhAreaLoad.Axis.Equals(LoadAxis.Local)) { loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Z; + if (bhAreaLoad.Projected) BH.Engine.Base.Compute.RecordWarning($"The 'Projected' option for {bhAreaLoad} is not supported when the Axis is set to Local and will therefore be ignored."); } else if (bhAreaLoad.Projected) { From 14343b2d6f6860dbb996df0cebc1b6884c6f0c58 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Mon, 3 Nov 2025 13:31:26 +0100 Subject: [PATCH 07/20] Warn if load direction is not axis-aligned Adds a warning if the AreaUniformlyDistributedLoad pressure vector is not parallel to any global axis, prompting users to verify the load direction. --- .../Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs index da3a5769..eaab31af 100644 --- a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs @@ -268,6 +268,13 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistributedLoad bhAreaLoad, int loadCaseSpecificLoadId) { + if (bhAreaLoad.Pressure.IsParallel(BH.oM.Geometry.Vector.XAxis)==0 + && bhAreaLoad.Pressure.IsParallel(BH.oM.Geometry.Vector.YAxis) == 0 + && bhAreaLoad.Pressure.IsParallel(BH.oM.Geometry.Vector.ZAxis) == 0) + { + BH.Engine.Base.Compute.RecordWarning($"Please make sure that the direction of {bhAreaLoad} is axis-aligned."); + } + Polygon polgon = (Polygon)bhAreaLoad.CustomData.Values.First(p => p is Polygon); List polygonValues = new List(); var loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XZ_OR_UW; From 6256d15840eb5bc7d0cf450d37f8bb14619f7d66 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Wed, 5 Nov 2025 10:46:59 +0100 Subject: [PATCH 08/20] Update RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs index eaab31af..b7a2810b 100644 --- a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs @@ -37,7 +37,6 @@ using BH.Engine.Geometry; using BH.oM.Geometry; using BH.Engine.Spatial; -using System.Transactions; namespace BH.Adapter.RFEM6 { From 56d3f535b59490afec431b28d3f2b42ee8ea9214 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Wed, 5 Nov 2025 10:47:14 +0100 Subject: [PATCH 09/20] Update RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs index b7a2810b..9099eb55 100644 --- a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs @@ -274,22 +274,22 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri BH.Engine.Base.Compute.RecordWarning($"Please make sure that the direction of {bhAreaLoad} is axis-aligned."); } - Polygon polgon = (Polygon)bhAreaLoad.CustomData.Values.First(p => p is Polygon); + Polygon polygon = (Polygon)bhAreaLoad.CustomData.Values.First(p => p is Polygon); List polygonValues = new List(); var loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XZ_OR_UW; - var fitPlane=polgon.IFitPlane(); + var fitPlane=polygon.IFitPlane(); if (fitPlane.Normal.CrossProduct(Plane.XY.Normal).Length() < 0.01) { - polygonValues=polgon.Vertices.Select(v => new double[] { v.X, v.Y }).ToList(); + polygonValues=polygon.Vertices.Select(v => new double[] { v.X, v.Y }).ToList(); loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XY_OR_UV; } else if (fitPlane.Normal.CrossProduct(Plane.XZ.Normal).Length() < 0.01) { - polygonValues=polgon.Vertices.Select(v => new double[] { v.X, v.Z }).ToList(); + polygonValues=polygon.Vertices.Select(v => new double[] { v.X, v.Z }).ToList(); loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XZ_OR_UW; } else { - polygonValues=polgon.Vertices.Select(v => new double[] { v.Y, v.Z }).ToList(); + polygonValues=polygon.Vertices.Select(v => new double[] { v.Y, v.Z }).ToList(); loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_YZ_OR_VW; } From 6557de186aa7a2fb909438a8984b51521b403875 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Wed, 5 Nov 2025 10:48:46 +0100 Subject: [PATCH 10/20] Update RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../ToRFEM6/BHoMDataStructure/Loading/Load.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs index 9099eb55..cd6041d5 100644 --- a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs @@ -276,21 +276,17 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri Polygon polygon = (Polygon)bhAreaLoad.CustomData.Values.First(p => p is Polygon); List polygonValues = new List(); - var loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XZ_OR_UW; - var fitPlane=polygon.IFitPlane(); + var fitPlane=polgon.IFitPlane(); if (fitPlane.Normal.CrossProduct(Plane.XY.Normal).Length() < 0.01) { - polygonValues=polygon.Vertices.Select(v => new double[] { v.X, v.Y }).ToList(); - loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XY_OR_UV; + polygonValues=polgon.Vertices.Select(v => new double[] { v.X, v.Y }).ToList(); } else if (fitPlane.Normal.CrossProduct(Plane.XZ.Normal).Length() < 0.01) { - polygonValues=polygon.Vertices.Select(v => new double[] { v.X, v.Z }).ToList(); - loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XZ_OR_UW; + polygonValues=polgon.Vertices.Select(v => new double[] { v.X, v.Z }).ToList(); } else { - polygonValues=polygon.Vertices.Select(v => new double[] { v.Y, v.Z }).ToList(); - loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_YZ_OR_VW; + polygonValues=polgon.Vertices.Select(v => new double[] { v.Y, v.Z }).ToList(); } From 13118ef7f7cfecbb2bdfce15045cca20fab7b32a Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Wed, 5 Nov 2025 10:49:04 +0100 Subject: [PATCH 11/20] Update RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs index cd6041d5..3715c143 100644 --- a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs @@ -275,7 +275,7 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri } Polygon polygon = (Polygon)bhAreaLoad.CustomData.Values.First(p => p is Polygon); - List polygonValues = new List(); + List polygonValues; var fitPlane=polgon.IFitPlane(); if (fitPlane.Normal.CrossProduct(Plane.XY.Normal).Length() < 0.01) { From 9d09184ec6e67c0308bf1d191e77fe9824468beb Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Wed, 5 Nov 2025 10:49:15 +0100 Subject: [PATCH 12/20] Update RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs index 7f4ce080..093a05b9 100644 --- a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs @@ -155,8 +155,6 @@ private List ReadAreaLoad(List ids = null) foreach (rfModel.free_polygon_load polygonLoad in foundPolygonLoad_) { List panels = polygonLoad.surfaces.ToList().Select(s => panelMap[s]).ToList(); - Loadcase loadcase = loadCaseMap[polygonLoad.load_case]; - if (!(polygonLoad.load_distribution is rfModel.free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM)) { Engine.Base.Compute.RecordNote("The current RFEM6 includes Surfaceloads with a non-uniformal load distributeion, these Loads will not be pulled."); From fba38dec4c3ceb14645cc8b8e7d50926f715453f Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Wed, 5 Nov 2025 10:49:50 +0100 Subject: [PATCH 13/20] Update RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs index 093a05b9..d6baf83b 100644 --- a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs @@ -186,7 +186,6 @@ private List ReadPolygonLoad(List ids = null) foreach (rfModel.free_polygon_load polLoad in foundPolygonLoad) { List panels = polLoad.surfaces.ToList().Select(s => panelMap[s]).ToList(); - Loadcase loadcase = loadCaseMap[polLoad.load_case]; if (!(polLoad.load_distribution is rfModel.free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM)) { From 7f69ab58caf4deb79b180bb6e8ea6f46517e050f Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Wed, 5 Nov 2025 10:49:59 +0100 Subject: [PATCH 14/20] Update RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs index 1f574bf8..7486cffe 100644 --- a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs @@ -194,7 +194,7 @@ public static AreaUniformlyDistributedLoad FromRFEM(this rfModel.free_polygon_lo List firstCoordinate = polygonLoad.load_location.ToList().Select(r => r.row.first_coordinate).ToList(); List secondCoordinate = polygonLoad.load_location.ToList().Select(r => r.row.second_coordinate).ToList(); List thirdCoordinate = Enumerable.Repeat(0.0, firstCoordinate.Count).ToList(); - List loadPolygon = new List(); + List loadPolygon; switch (polygonLoad.load_projection) { From 51100f6aeac5cbd4efed99c1721a7dbcd68489a8 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Wed, 5 Nov 2025 11:11:18 +0100 Subject: [PATCH 15/20] Fix variable name typo and add loadProjection assignment Corrected the typo from 'polgon' to 'polygon' in multiple places and added assignment of 'loadProjection' based on the polygon's fit plane orientation. --- .../ToRFEM6/BHoMDataStructure/Loading/Load.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs index 3715c143..a54512b3 100644 --- a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs @@ -266,6 +266,7 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistributedLoad bhAreaLoad, int loadCaseSpecificLoadId) { + free_polygon_load_load_projection loadProjection; if (bhAreaLoad.Pressure.IsParallel(BH.oM.Geometry.Vector.XAxis)==0 && bhAreaLoad.Pressure.IsParallel(BH.oM.Geometry.Vector.YAxis) == 0 @@ -276,18 +277,21 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri Polygon polygon = (Polygon)bhAreaLoad.CustomData.Values.First(p => p is Polygon); List polygonValues; - var fitPlane=polgon.IFitPlane(); + var fitPlane=polygon.IFitPlane(); if (fitPlane.Normal.CrossProduct(Plane.XY.Normal).Length() < 0.01) { - polygonValues=polgon.Vertices.Select(v => new double[] { v.X, v.Y }).ToList(); + polygonValues= polygon.Vertices.Select(v => new double[] { v.X, v.Y }).ToList(); + loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XY_OR_UV; } else if (fitPlane.Normal.CrossProduct(Plane.XZ.Normal).Length() < 0.01) { - polygonValues=polgon.Vertices.Select(v => new double[] { v.X, v.Z }).ToList(); + polygonValues= polygon.Vertices.Select(v => new double[] { v.X, v.Z }).ToList(); + loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XZ_OR_UW; } else { - polygonValues=polgon.Vertices.Select(v => new double[] { v.Y, v.Z }).ToList(); - + polygonValues= polygon.Vertices.Select(v => new double[] { v.Y, v.Z }).ToList(); + loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_YZ_OR_VW; + } free_polygon_load_load_location k = new free_polygon_load_load_location() { first_coordinate = 10, second_coordinate = 100 }; From 8c5befa318344b55d346a6b4728d02f93ca15d27 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Wed, 5 Nov 2025 15:34:27 +0100 Subject: [PATCH 16/20] Fix typos and variable naming in Load.cs files Corrected spelling errors in log messages and standardized the variable name from 'loadMagintude' to 'loadMagnitude' in the Load.cs files for improved code clarity and consistency. --- .../CRUD/Read/BHoMDataStructure/Loading/Load.cs | 6 +++--- .../ToRFEM6/BHoMDataStructure/Loading/Load.cs | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs index d6baf83b..1e0903c0 100644 --- a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs @@ -137,7 +137,7 @@ private List ReadAreaLoad(List ids = null) if (!(surfaceLoad.load_distribution is rfModel.surface_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM)) { - Engine.Base.Compute.RecordNote("The current RFEM6 includes Surfaceloads with a non-uniformal load distributeion, these Loads will not be pulled."); + Engine.Base.Compute.RecordNote("The current RFEM6 includes Surface loads with a non-uniformal load distributeion, these Loads will not be pulled."); continue; } @@ -157,7 +157,7 @@ private List ReadAreaLoad(List ids = null) List panels = polygonLoad.surfaces.ToList().Select(s => panelMap[s]).ToList(); if (!(polygonLoad.load_distribution is rfModel.free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM)) { - Engine.Base.Compute.RecordNote("The current RFEM6 includes Surfaceloads with a non-uniformal load distributeion, these Loads will not be pulled."); + Engine.Base.Compute.RecordNote("The current RFEM6 includes Surface loads with a non-uniformal load distributeion, these Loads will not be pulled."); continue; } @@ -189,7 +189,7 @@ private List ReadPolygonLoad(List ids = null) if (!(polLoad.load_distribution is rfModel.free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM)) { - Engine.Base.Compute.RecordNote("The current RFEM6 includes Surfaceloads with a non-uniformal load distributeion, these Loads will not be pulled."); + Engine.Base.Compute.RecordNote("The current RFEM6 includes Surface loads with a non-uniformal load distributeion, these Loads will not be pulled."); continue; } diff --git a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs index a54512b3..15fa9fcc 100644 --- a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs @@ -274,7 +274,7 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri { BH.Engine.Base.Compute.RecordWarning($"Please make sure that the direction of {bhAreaLoad} is axis-aligned."); } - + Polygon polygon = (Polygon)bhAreaLoad.CustomData.Values.First(p => p is Polygon); List polygonValues; var fitPlane=polygon.IFitPlane(); @@ -314,7 +314,7 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri ).ToArray(); - double loadMagintude; + double loadMagnitude; free_polygon_load_load_direction loadDirection; Vector orientationVector = bhAreaLoad.Pressure; @@ -341,7 +341,7 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri { loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_X_TRUE; } - loadMagintude = orientationVector.X; + loadMagnitude = orientationVector.X; } else if (orientationVector.Y != 0) @@ -359,7 +359,7 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri { loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_TRUE; } - loadMagintude = orientationVector.Y; + loadMagnitude = orientationVector.Y; } else @@ -377,7 +377,7 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri { loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_TRUE; } - loadMagintude = orientationVector.Z; + loadMagnitude = orientationVector.Z; } @@ -391,9 +391,9 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri load_caseSpecified = true, load_distribution = free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM, load_distributionSpecified = true, - magnitude_linear_1 = loadMagintude, + magnitude_linear_1 = loadMagnitude, magnitude_linear_1Specified = true, - magnitude_uniform = loadMagintude, + magnitude_uniform = loadMagnitude, magnitude_uniformSpecified = true, is_generated = false, is_generatedSpecified = true, From 2dec64a59d7e70af77b09f46d60c836417abfe94 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Wed, 5 Nov 2025 15:36:52 +0100 Subject: [PATCH 17/20] Remove unused ReadPolygonLoad method Deleted the ReadPolygonLoad method from Load.cs as it is no longer needed. This helps clean up the codebase and removes dead code. --- .../Read/BHoMDataStructure/Loading/Load.cs | 32 +------------------ 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs index 1e0903c0..4175c759 100644 --- a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs @@ -169,37 +169,7 @@ private List ReadAreaLoad(List ids = null) return loads; } - private List ReadPolygonLoad(List ids = null) - { - List loads = new List(); - - //Find all possible Load cases - Dictionary loadCaseMap = this.GetCachedOrReadAsDictionary(); - Dictionary panelMap = this.GetCachedOrReadAsDictionary(); - - rfModel.object_with_children[] numbers = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_FREE_POLYGON_LOAD); - - //IEnumerable foundSurfaceLoad = numbers.ToList().Select(n => m_Model.get_surface_load(n.children[0], n.no)); - IEnumerable foundPolygonLoad = numbers.SelectMany(n => n.children.Select(child => m_Model.get_free_polygon_load(child, n.no))); - - foundPolygonLoad = foundPolygonLoad.OrderBy(n => n.load_case).ThenBy(t => t.no); - foreach (rfModel.free_polygon_load polLoad in foundPolygonLoad) - { - List panels = polLoad.surfaces.ToList().Select(s => panelMap[s]).ToList(); - - if (!(polLoad.load_distribution is rfModel.free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM)) - { - Engine.Base.Compute.RecordNote("The current RFEM6 includes Surface loads with a non-uniformal load distributeion, these Loads will not be pulled."); - continue; - } - - loads.Add(polLoad.FromRFEM(loadCaseMap[polLoad.load_case], panels)); - - } - - return loads; - } - + private List ReadFreeLineLoad(List ids = null) { From b5d3cbe433e06fc18292a4d0aad8fa426dd06454 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Wed, 5 Nov 2025 15:38:32 +0100 Subject: [PATCH 18/20] Update RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs index 966825ba..9659a7c9 100644 --- a/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs @@ -250,8 +250,8 @@ private void CreateLoad_Polygon(AreaUniformlyDistributedLoad bhLoad) rfemAreaLoad.surfaces = currrSurfaceIds; m_Model.set_free_polygon_load(bhLoad.Loadcase.Number, rfemAreaLoad); - } catch { - BH.Engine.Base.Compute.RecordError($"The creation of {bhLoad} failed.\nA potential cause is that the applied polygon is non-planar or not parallel to the XY, YZ, or ZX plane."); + } catch (Exception ex) { + BH.Engine.Base.Compute.RecordError($"The creation of {bhLoad} failed.\nA potential cause is that the applied polygon is non-planar or not parallel to the XY, YZ, or ZX plane.\nException: {ex.Message}\nStackTrace: {ex.StackTrace}"); } } From 621a5bd5c4de1a1e2856583536db2ace3c35354d Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Wed, 5 Nov 2025 15:40:36 +0100 Subject: [PATCH 19/20] Update Load.cs --- RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs index 15fa9fcc..7902bc6a 100644 --- a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs @@ -294,8 +294,6 @@ public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistri } - free_polygon_load_load_location k = new free_polygon_load_load_location() { first_coordinate = 10, second_coordinate = 100 }; - free_polygon_load_load_location_row r = new free_polygon_load_load_location_row() { row = k }; free_polygon_load_load_location_row[] locationPolygons = polygonValues.Select((v, i) => new free_polygon_load_load_location_row() { no = (i+1), From 0d3782769aa1f8baa9b46bd1c88700b4a98e5471 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Wed, 5 Nov 2025 15:43:17 +0100 Subject: [PATCH 20/20] Update Load.cs --- .../ToRFEM6/BHoMDataStructure/Loading/Load.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs index 7902bc6a..e53c1f81 100644 --- a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs @@ -48,7 +48,7 @@ public static rfModel.member_load ToRFEM6(this BarUniformlyDistributedLoad bhBar //var i = bhBarLoad.Objects.Elements.ToList().Select(x => x.GetRFEM6ID()).ToList(); - double loadMagintude; + double loadMagnitude; member_load_load_direction loadDirecteion; Vector orientationVector = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force : bhBarLoad.Moment; @@ -73,7 +73,7 @@ public static rfModel.member_load ToRFEM6(this BarUniformlyDistributedLoad bhBar { loadDirecteion = member_load_load_direction.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE; } - loadMagintude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.X : bhBarLoad.Moment.X; + loadMagnitude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.X : bhBarLoad.Moment.X; } @@ -91,7 +91,7 @@ public static rfModel.member_load ToRFEM6(this BarUniformlyDistributedLoad bhBar { loadDirecteion = member_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_OR_USER_DEFINED_V_TRUE; } - loadMagintude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.Y : bhBarLoad.Moment.Y; + loadMagnitude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.Y : bhBarLoad.Moment.Y; } else @@ -108,7 +108,7 @@ public static rfModel.member_load ToRFEM6(this BarUniformlyDistributedLoad bhBar { loadDirecteion = member_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_OR_USER_DEFINED_W_TRUE; } - loadMagintude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.Z : bhBarLoad.Moment.Z; + loadMagnitude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.Z : bhBarLoad.Moment.Z; } member_load rfLoadCase = new rfModel.member_load() @@ -122,7 +122,7 @@ public static rfModel.member_load ToRFEM6(this BarUniformlyDistributedLoad bhBar load_typeSpecified = true, load_direction = loadDirecteion, load_directionSpecified = true, - magnitude = loadMagintude, + magnitude = loadMagnitude, magnitudeSpecified = true, load_is_over_total_length = true, load_is_over_total_lengthSpecified = true, @@ -175,7 +175,7 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA { - double loadMagintude; + double loadMagnitude; surface_load_load_direction loadDirection; Vector orientationVector = bhAreaLoad.Pressure; @@ -200,7 +200,7 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA { loadDirection = surface_load_load_direction.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE; } - loadMagintude = orientationVector.X; + loadMagnitude = orientationVector.X; } else if (orientationVector.Y != 0) @@ -217,7 +217,7 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA { loadDirection = surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_OR_USER_DEFINED_V_TRUE; } - loadMagintude = orientationVector.Y; + loadMagnitude = orientationVector.Y; } else @@ -234,7 +234,7 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA { loadDirection = surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_OR_USER_DEFINED_W_TRUE; } - loadMagintude = orientationVector.Z; + loadMagnitude = orientationVector.Z; } @@ -247,9 +247,9 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA load_caseSpecified = true, load_distribution = surface_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM, load_distributionSpecified = true, - magnitude_force_u = loadMagintude, + magnitude_force_u = loadMagnitude, magnitude_force_uSpecified = true, - uniform_magnitude = loadMagintude, + uniform_magnitude = loadMagnitude, uniform_magnitudeSpecified = true, is_generated = false, is_generatedSpecified = true,