From 2471a50d84f5cd5722089705315d2543cdb397df Mon Sep 17 00:00:00 2001 From: BHoMBot Date: Tue, 30 Sep 2025 11:03:29 -0400 Subject: [PATCH 01/24] Update assembly file version to 9.0.0.0 and AssemblyVersion to 9.0.0.0 --- .ci/unit-tests/RFEM_Toolkit_Test/RFEM_Toolkit_Test.csproj | 4 ++-- RFEM6_Adapter/RFEM6_Adapter.csproj | 4 ++-- RFEM6_Engine/RFEM6_Engine.csproj | 4 ++-- RFEM6_oM/RFEM6_oM.csproj | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.ci/unit-tests/RFEM_Toolkit_Test/RFEM_Toolkit_Test.csproj b/.ci/unit-tests/RFEM_Toolkit_Test/RFEM_Toolkit_Test.csproj index 5077ec17..eb77ccd9 100644 --- a/.ci/unit-tests/RFEM_Toolkit_Test/RFEM_Toolkit_Test.csproj +++ b/.ci/unit-tests/RFEM_Toolkit_Test/RFEM_Toolkit_Test.csproj @@ -2,14 +2,14 @@ net6.0 - 8.0.0.0 + 9.0.0.0 https://github.com/BHoM/RFEM6_Toolkit enable enable false true - 8.3.0.0 + 9.0.0.0 diff --git a/RFEM6_Adapter/RFEM6_Adapter.csproj b/RFEM6_Adapter/RFEM6_Adapter.csproj index 1c395a19..5bbc5b2c 100644 --- a/RFEM6_Adapter/RFEM6_Adapter.csproj +++ b/RFEM6_Adapter/RFEM6_Adapter.csproj @@ -2,12 +2,12 @@ net48 - 8.0.0.0 + 9.0.0.0 https://github.com/BHoM/RFEM6_Toolkit RFEM6_Adapter BH.Adapter.RFEM6 true - 8.3.0.0 + 9.0.0.0 ..\Build\ diff --git a/RFEM6_Engine/RFEM6_Engine.csproj b/RFEM6_Engine/RFEM6_Engine.csproj index 072506d0..bba3994a 100644 --- a/RFEM6_Engine/RFEM6_Engine.csproj +++ b/RFEM6_Engine/RFEM6_Engine.csproj @@ -2,12 +2,12 @@ net48 - 8.0.0.0 + 9.0.0.0 https://github.com/BHoM/RFEM6_Toolkit 5.0.0 Copyright © https://github.com/BHoM BH.Engine.Adapters.RFEM6 - 8.3.0.0 + 9.0.0.0 diff --git a/RFEM6_oM/RFEM6_oM.csproj b/RFEM6_oM/RFEM6_oM.csproj index 0fec6ffd..199dc305 100644 --- a/RFEM6_oM/RFEM6_oM.csproj +++ b/RFEM6_oM/RFEM6_oM.csproj @@ -2,12 +2,12 @@ net48 - 8.0.0.0 + 9.0.0.0 https://github.com/BHoM/RFEM6_Toolkit 5.0.0 Copyright © https://github.com/BHoM BH.oM.Adapters.RFEM6 - 8.3.0.0 + 9.0.0.0 From 7a3d46e893f05f6eb7dc9d94e1b48fd224d8595d Mon Sep 17 00:00:00 2001 From: Arnaud Declercq Date: Thu, 2 Oct 2025 17:27:43 +0100 Subject: [PATCH 02/24] Removing Previous Version attribute for 8.3 --- RFEM6_Adapter/RFEM6Adapter.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/RFEM6_Adapter/RFEM6Adapter.cs b/RFEM6_Adapter/RFEM6Adapter.cs index 6d61bcb7..c6e45271 100644 --- a/RFEM6_Adapter/RFEM6Adapter.cs +++ b/RFEM6_Adapter/RFEM6Adapter.cs @@ -60,7 +60,6 @@ public partial class RFEM6Adapter : BHoMAdapter [Description("Adapter for RFEM6.")] [Input("filePath", "Input the optional file path to RFEM model. Default is to use the currently running instance")] [Output("The created RFEM6 adapter.")] - [PreviousVersion("8.3", "BH.Adapter.RFEM6.RFEM6Adapter(System.Boolean)")] public RFEM6Adapter(string filePath = "", bool active = false) { From 694fcf3dc2dd2849525d0710e6fdcbaf173c78e3 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Thu, 16 Oct 2025 08:59:24 +0200 Subject: [PATCH 03/24] Update node access in Bar geometry reader Replaced usage of rfMember.nodes[0] and rfMember.nodes[1] with rfMember.node_start and rfMember.node_end for improved clarity and consistency with the data structure. --- RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Geometry/Bar.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Geometry/Bar.cs b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Geometry/Bar.cs index 54a30e6e..bc98d71d 100644 --- a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Geometry/Bar.cs +++ b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Geometry/Bar.cs @@ -63,11 +63,12 @@ private List ReadBars(List ids = null) foreach (var rfMember in allRfMembers) { + Node node0 = null; - nodes.TryGetValue(rfMember.nodes[0], out node0); + nodes.TryGetValue(rfMember.node_start, out node0); Node node1 = null; - nodes.TryGetValue(rfMember.nodes[1], out node1); + nodes.TryGetValue(rfMember.node_end, out node1); ISectionProperty section = null; sections.TryGetValue(rfMember.section_end, out section); From 02bf14609dfdd53fe0a7fb8072759c0205b4b658 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Mon, 20 Oct 2025 11:38:44 +0200 Subject: [PATCH 04/24] Refactor BarResults test and adapter logic Improved formatting and readability in BarResultTestClass, added a new test method for reading results with multiple load combinations, and refactored ReadResults in RFEM6Adapter for better error handling and member length retrieval. These changes enhance maintainability and robustness of result extraction from RFEM6. --- .../BHoMDataStructure/Result/BarResults.cs | 86 +++--- .../BHoMDataStructure/Result/BarResults.cs | 260 ++++++++++-------- 2 files changed, 194 insertions(+), 152 deletions(-) diff --git a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Result/BarResults.cs b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Result/BarResults.cs index f1dfd6c4..a2a7bbb8 100644 --- a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Result/BarResults.cs +++ b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Result/BarResults.cs @@ -36,52 +36,74 @@ namespace RFEM_Toolkit_Test.Elements { - public class BarResultTestClass + public class BarResultTestClass - { + { - RFEM6Adapter adapter; + RFEM6Adapter adapter; - //[TearDown] - //public void TearDown() - //{ - // adapter.Wipeout(); - //} + //[TearDown] + //public void TearDown() + //{ + // adapter.Wipeout(); + //} - [OneTimeSetUp] - public void InitializeRFEM6Adapter() - { - adapter = new RFEM6Adapter(active:true); + [OneTimeSetUp] + public void InitializeRFEM6Adapter() + { + adapter = new RFEM6Adapter(active: true); - } + } - [Test] - public void ReadResult() - { - List loadCombList = adapter.Pull(new FilterRequest() { Type = typeof(LoadCombination) }).Select(l=> l as LoadCombination).ToList(); + [Test] + public void ReadResult() + { + List loadCombList = adapter.Pull(new FilterRequest() { Type = typeof(LoadCombination) }).Select(l => l as LoadCombination).ToList(); - Loadcase loadcase1 = new Loadcase() { Name = "LC1", Nature = LoadNature.Dead, Number = 1 }; - LoadCombination loadCombination = new LoadCombination { Name = "LoadCombination1", Number = 1 }; + Loadcase loadcase1 = new Loadcase() { Name = "LC1", Nature = LoadNature.Dead, Number = 1 }; + LoadCombination loadCombination = new LoadCombination { Name = "LoadCombination1", Number = 1 }; - BarResultRequest request = new BarResultRequest(); + BarResultRequest request = new BarResultRequest(); - request.ResultType = BarResultType.BarForce; - request.DivisionType = DivisionType.EvenlyDistributed; - request.Divisions = 3; - request.Cases = new List { loadCombList.First() }; - //request.Cases = new List {1}; - request.Modes = new List(); - request.ObjectIds = new List {1}; - //request.ObjectIds = new List {1,2,3,4}; + request.ResultType = BarResultType.BarForce; + request.DivisionType = DivisionType.EvenlyDistributed; + request.Divisions = 3; + request.Cases = new List { loadCombList.First() }; + //request.Cases = new List {1}; + request.Modes = new List(); + request.ObjectIds = new List { 1 }; + //request.ObjectIds = new List {1,2,3,4}; - var obj = adapter.Pull(request); + var obj = adapter.Pull(request); - obj.First(); + obj.First(); - } + } + [Test] + public void ReadResult2() + { + List loadCombList = adapter.Pull(new FilterRequest() { Type = typeof(LoadCombination) }).Select(l => l as LoadCombination).ToList(); + List relevantLoadComb = loadCombList.Take(38).ToList(); + BarResultRequest request = new BarResultRequest(); - } + request.ResultType = BarResultType.BarForce; + request.DivisionType = DivisionType.EvenlyDistributed; + request.Divisions = 2; + request.Cases = new List {relevantLoadComb.First()}; + request.Modes = new List(); + //request.ObjectIds = new List { 1 }; + //request.ObjectIds = new List {1,2,3,4}; + + var obj = adapter.Pull(request); + + + var obj_first = obj.First(); + } + + + + } } diff --git a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Result/BarResults.cs b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Result/BarResults.cs index fce63245..48800d2c 100644 --- a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Result/BarResults.cs +++ b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Result/BarResults.cs @@ -19,171 +19,191 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - +using BH.Engine.Base; +using BH.Engine.Spatial; using BH.oM.Adapter; -using BH.oM.Structure.Elements; -using BH.oM.Structure.Constraints; - -using rfModel = Dlubal.WS.Rfem6.Model; using BH.oM.Adapters.RFEM6; -using BH.oM.Structure.Loads; -using Dlubal.WS.Rfem6.Model; -using System.Xml.Linq; -using BH.Engine.Base; using BH.oM.Analytical.Results; +using BH.oM.Structure.Constraints; +using BH.oM.Structure.Elements; +using BH.oM.Structure.Loads; +using BH.oM.Structure.MaterialFragments; using BH.oM.Structure.Requests; using BH.oM.Structure.Results; +using Dlubal.WS.Rfem6.Model; +using System; +using System.Collections.Generic; +using System.ComponentModel; using System.Configuration; using System.Globalization; -using System.ComponentModel; +using System.Linq; using System.Linq.Expressions; +using System.Text; +using System.Xml.Linq; +using rfModel = Dlubal.WS.Rfem6.Model; namespace BH.Adapter.RFEM6 { - public partial class RFEM6Adapter - { - - public IEnumerable ReadResults(BarResultRequest request, ActionConfig actionConfig) - { - - - //Warnings - BH.Engine.Base.Compute.RecordWarning($"Divisions are set to {request.Divisions}. Division functionality has not been implemented yet in RFEM6_Toolkit. Currently, the number of divisions depends solely on what RFEM6 provides and can vary significantly based on the load type on the corresponding Bar/Member and the DivisionType."); - - if (request.Cases.Where(c=> c is string).ToList().Count>0) { BH.Engine.Base.Compute.RecordWarning("At least one instance of the Case input is neither of type LoadCase nor LoadCombination. The set CaseIds will be assumed to be LoadCase IDs for now."); }; - - //RFEM Specific Stuff - m_Model.use_detailed_member_results(true); + public partial class RFEM6Adapter + { - // Loading of Member And LoadCase Ids - List memberIds = request.ObjectIds.Select(s => Int32.Parse(s.ToString())).ToList(); + public IEnumerable ReadResults(BarResultRequest request, ActionConfig actionConfig) + { + - // Definition of Object Locations for Members - object_location[] objectLocations = memberIds.Select(n => new object_location() { type = object_types.E_OBJECT_TYPE_MEMBER, no = n, parent_no = 0 }).ToArray(); + //Warnings + BH.Engine.Base.Compute.RecordWarning($"Divisions are set to {request.Divisions}. Division functionality has not been implemented yet in RFEM6_Toolkit. Currently, the number of divisions depends solely on what RFEM6 provides and can vary significantly based on the load type on the corresponding Bar/Member and the DivisionType."); - //ResultList - List resultList = new List(); + if (request.Cases.Where(c => c is string).ToList().Count > 0) { BH.Engine.Base.Compute.RecordWarning("At least one instance of the Case input is neither of type LoadCase nor LoadCombination. The set CaseIds will be assumed to be LoadCase IDs for now."); } + ; + //RFEM Specific Stuff + m_Model.use_detailed_member_results(true); - foreach (var c in request.Cases) - { - int cId = 0; + // Loading of Member And LoadCase Ids + List memberIds = request.ObjectIds.Select(s => Int32.Parse(s.ToString())).ToList(); - if (c is Loadcase) - { - cId = (c as Loadcase).Number; + // Definition of Object Locations for Members + object_location[] objectLocations = memberIds.Select(n => new object_location() { type = object_types.E_OBJECT_TYPE_MEMBER, no = n, parent_no = 0 }).ToArray(); - } - else if (c is LoadCombination) - { + //ResultList + List resultList = new List(); - cId = (c as LoadCombination).Number; - } - else - { + foreach (var c in request.Cases) + { + int cId = 0; - cId = Int32.Parse(c.ToString()); - } + if (c is Loadcase) + { + cId = (c as Loadcase).Number; + } + else if (c is LoadCombination) + { + cId = (c as LoadCombination).Number; - //Loading resulst from RFEM - INotifyPropertyChanged[] barResults = new INotifyPropertyChanged[1]; + } + else + { - var loadingType = c is LoadCombination ? case_object_types.E_OBJECT_TYPE_LOAD_COMBINATION : case_object_types.E_OBJECT_TYPE_LOAD_CASE; - switch (request.ResultType) - { + cId = Int32.Parse(c.ToString()); + } - case BarResultType.BarForce: - barResults = m_Model.get_results_for_members_internal_forces(loadingType, cId, objectLocations, axes_type.MEMBER_AXES); - break; - case BarResultType.BarDisplacement: - barResults = m_Model.get_results_for_members_global_deformations(loadingType, cId, objectLocations); - break; - case BarResultType.BarDeformation: - barResults = m_Model.get_results_for_members_local_deformations(loadingType, cId, objectLocations, axes_type.MEMBER_AXES); - break; - case BarResultType.BarStrain: - barResults = m_Model.get_results_for_members_strains(loadingType, cId, objectLocations, axes_type.MEMBER_AXES); - break; - default: - BH.Engine.Base.Compute.RecordError($"The pull result types of type {request.ResultType} has not been developed Yet"); - return null; - } - //Grouping of Internal Forces grouped by Member No - var memberInternalForceGroup = barResults.GroupBy(r => Int32.Parse(r.PropertyValue("row.member_no").ToString())); + //Loading resulst from RFEM + INotifyPropertyChanged[] barResults = new INotifyPropertyChanged[1]; + var loadingType = c is LoadCombination ? case_object_types.E_OBJECT_TYPE_LOAD_COMBINATION : case_object_types.E_OBJECT_TYPE_LOAD_CASE; + switch (request.ResultType) + { + + case BarResultType.BarForce: + barResults = m_Model.get_results_for_members_internal_forces(loadingType, cId, objectLocations, axes_type.MEMBER_AXES); + break; + case BarResultType.BarDisplacement: + barResults = m_Model.get_results_for_members_global_deformations(loadingType, cId, objectLocations); + break; + case BarResultType.BarDeformation: + barResults = m_Model.get_results_for_members_local_deformations(loadingType, cId, objectLocations, axes_type.MEMBER_AXES); + break; + case BarResultType.BarStrain: + barResults = m_Model.get_results_for_members_strains(loadingType, cId, objectLocations, axes_type.MEMBER_AXES); + break; + default: + BH.Engine.Base.Compute.RecordError($"The pull result types of type {request.ResultType} has not been developed Yet"); + return null; - //Results processing memberwise - foreach (IGrouping member in memberInternalForceGroup) - { - //Ignore Results that do now have a valied ID - if (member.Key == 0) continue; + } - //Determine Member length - String lengthAsString = member.ToList()[0].PropertyValue("row.specification").ToString().Split(new[] { "L : ", " m" }, StringSplitOptions.None)[1]; - double memberLength = double.Parse(lengthAsString, CultureInfo.InvariantCulture);// Member Length in SI unit m; + //Grouping of Internal Forces grouped by Member No + var memberInternalForceGroup = barResults.GroupBy(r => Int32.Parse(r.PropertyValue("row.member_no").ToString())); - var memberSegmentValues = member.ToList(); - //If we are looking for exterme Values - if (request.DivisionType == DivisionType.ExtremeValues) - { + //Results processing memberwise + foreach (IGrouping member in memberInternalForceGroup) + { + //Ignore Results that do now have a valied ID + if (member.Key == 0) continue; - memberSegmentValues = member.SkipWhile(m => !m.PropertyValue("description").ToString().Contains("Extremes")).ToList(); - memberSegmentValues = memberSegmentValues.TakeWhile(m => !m.PropertyValue("description").ToString().Contains("Total")).ToList(); + //Determine Member length + Dictionary barDictionary = new Dictionary(); + double memberLength = 0; + try + { - } + if (barDictionary.Keys.Contains(member.Key)) + { + memberLength = barDictionary[member.Key].Length(); + continue; + } - else - { - memberSegmentValues = memberSegmentValues.TakeWhile(m => !m.PropertyValue("description").ToString().Contains("Extremes")).ToList(); + String lengthAsString = member.ToList()[0].PropertyValue("row.specification").ToString().Split(new[] { "L : ", " m" }, StringSplitOptions.None)[1]; + memberLength = double.Parse(lengthAsString, CultureInfo.InvariantCulture);// Member Length in SI unit m; + } + catch + { + barDictionary = this.GetCachedOrReadAsDictionary(); + memberLength = barDictionary[member.Key].Length(); + } - } - int corrective = (request.ResultType == BarResultType.BarDisplacement || request.ResultType == BarResultType.BarDeformation) ? 0 : 2; - // important do to enable processing of Deformations due to the |u| - if (memberSegmentValues?.First()?.PropertyValue("row.deformation_label")?.ToString()?.Contains("|u|") ?? false) - { - memberSegmentValues = memberSegmentValues.Skip(2).ToList(); - //corrective = 0; - } - //Conversion for every segment of member - foreach (var e in memberSegmentValues) - { + var memberSegmentValues = member.ToList(); - var location = Double.Parse(e.PropertyValue("row.location").ToString()); - var memberNumber = Int32.Parse(e.PropertyValue("row.member_no").ToString()); - var props = e.PropertyValue("row").GetType().GetProperties(); - List accesList = new List() { 10 - corrective, 12 - corrective, 14 - corrective, 16 - corrective, 18 - corrective, 20 - corrective }; - var accessedlist = accesList.Select(a => props.ToList()[a]); - Dictionary val = new[] { - (10-corrective, "x"), (12-corrective, "y"), (14-corrective, "z"), - (16-corrective, "rx"), (18-corrective, "ry"), (20-corrective, "rz") - }.ToDictionary(p => p.Item2, p => Double.Parse( - e.PropertyValue($"row.{props[p.Item1].Name}").ToString() - )); + //If we are looking for exterme Values + if (request.DivisionType == DivisionType.ExtremeValues) + { - var result = val.Values.ToList().FromRFEM(cId, memberLength, location, memberNumber, request.ResultType); - resultList.Add(result); - } + memberSegmentValues = member.SkipWhile(m => !m.PropertyValue("description").ToString().Contains("Extremes")).ToList(); + memberSegmentValues = memberSegmentValues.TakeWhile(m => !m.PropertyValue("description").ToString().Contains("Total")).ToList(); - } - } + } - return resultList; + else + { + memberSegmentValues = memberSegmentValues.TakeWhile(m => !m.PropertyValue("description").ToString().Contains("Extremes")).ToList(); - } + } - } + int corrective = (request.ResultType == BarResultType.BarDisplacement || request.ResultType == BarResultType.BarDeformation) ? 0 : 2; + // important do to enable processing of Deformations due to the |u| + if (memberSegmentValues?.First()?.PropertyValue("row.deformation_label")?.ToString()?.Contains("|u|") ?? false) + { + memberSegmentValues = memberSegmentValues.Skip(2).ToList(); + //corrective = 0; + } + + //Conversion for every segment of member + foreach (var e in memberSegmentValues) + { + + var location = Double.Parse(e.PropertyValue("row.location").ToString()); + var memberNumber = Int32.Parse(e.PropertyValue("row.member_no").ToString()); + var props = e.PropertyValue("row").GetType().GetProperties(); + List accesList = new List() { 10 - corrective, 12 - corrective, 14 - corrective, 16 - corrective, 18 - corrective, 20 - corrective }; + var accessedlist = accesList.Select(a => props.ToList()[a]); + Dictionary val = new[] { + (10-corrective, "x"), (12-corrective, "y"), (14-corrective, "z"), + (16-corrective, "rx"), (18-corrective, "ry"), (20-corrective, "rz") + }.ToDictionary(p => p.Item2, p => Double.Parse( + e.PropertyValue($"row.{props[p.Item1].Name}").ToString() + )); + + var result = val.Values.ToList().FromRFEM(cId, memberLength, location, memberNumber, request.ResultType); + resultList.Add(result); + } + + } + } + + return resultList; + + } + + } } From b921cad75f48d4f6e4e01f0d881c8e44ba38af50 Mon Sep 17 00:00:00 2001 From: Arne Martensen Date: Mon, 27 Oct 2025 18:10:47 +0100 Subject: [PATCH 05/24] 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 06/24] 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 07/24] 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 08/24] 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 09/24] 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 10/24] 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 11/24] 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 12/24] 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 13/24] 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 14/24] 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 15/24] 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 16/24] 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 17/24] 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 18/24] 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 19/24] 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 20/24] 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 21/24] 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 22/24] 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 23/24] 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 24/24] 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,