diff --git a/.ci/code/BHoM_Adapter_Tests/Objects/StructuralAdapter.cs b/.ci/code/BHoM_Adapter_Tests/Objects/StructuralAdapter.cs index dccf3907..24d60c2c 100644 --- a/.ci/code/BHoM_Adapter_Tests/Objects/StructuralAdapter.cs +++ b/.ci/code/BHoM_Adapter_Tests/Objects/StructuralAdapter.cs @@ -71,7 +71,8 @@ public StructuralAdapter() {typeof(RigidLink), new List { typeof(LinkConstraint), typeof(Node) } }, {typeof(FEMesh), new List { typeof(Node), typeof(ISurfaceProperty)} }, { typeof(IElementLoad), new List{ typeof(Bar)} }, - { typeof(IElementLoad), new List{ typeof(Node)} } + { typeof(IElementLoad), new List{ typeof(Node)} }, + { typeof(GravityLoad), new List{ typeof(Bar), typeof(Panel), typeof(FEMesh)} } }; AdapterIdFragmentType = typeof(StructuralAdapterId); diff --git a/.ci/code/BHoM_Adapter_Tests/PushTests.cs b/.ci/code/BHoM_Adapter_Tests/PushTests.cs index 8c16df72..f77a0cb8 100644 --- a/.ci/code/BHoM_Adapter_Tests/PushTests.cs +++ b/.ci/code/BHoM_Adapter_Tests/PushTests.cs @@ -223,5 +223,41 @@ public void DependencyOrder_CreateLoadHalfObjectsWithIds() Assert.AreEqual(withoutIdCount, barCreationCount, "Wrong number of bars created."); } + + [Test] + public void DependencyOrder_CreateGravityLoadHalfObjectsWithIds() + { + int objectCount = 10; + List bars = Create.RandomObjects(objectCount); + List panels = Create.RandomObjects(objectCount); + int withIdCount = objectCount / 2; + int withoutIdCount = objectCount - withIdCount; + for (int i = 0; i < withIdCount; i++) + { + Engine.Adapter.Modify.SetAdapterId(bars[i], new StructuralAdapterId { Id = i + 1 }); + Engine.Adapter.Modify.SetAdapterId(panels[i], new StructuralAdapterId { Id = i + 1 }); + } + + //Shuffle the order fo the bars. + //Doing this to test that the order of bars with and without Id does not matter + Random random = new Random(2); + bars = bars.OrderBy(x => random.Next()).ToList(); + panels = panels.OrderBy(x => random.Next()).ToList(); + + GravityLoad load = Create.RandomObject(); + load.Objects.Elements = bars.Cast().Concat(panels).ToList(); + + sa.Push(new List { load }); + + Assert.IsTrue(sa.Created.Any(x => x.Item1 == typeof(Bar)), "No bars created."); + int barCreationCount = sa.Created.First(x => x.Item1 == typeof(Bar)).Item2.Count(); + + Assert.AreEqual(withoutIdCount, barCreationCount, "Wrong number of bars created."); + + Assert.IsTrue(sa.Created.Any(x => x.Item1 == typeof(Panel)), "No Panels created."); + int panelsCreationCount = sa.Created.First(x => x.Item1 == typeof(Panel)).Item2.Count(); + + Assert.AreEqual(withoutIdCount, panelsCreationCount, "Wrong number of Panels created."); + } } } \ No newline at end of file diff --git a/Structure_AdapterModules/ModuleLoader.cs b/Structure_AdapterModules/ModuleLoader.cs index 1f812945..3adb37b3 100644 --- a/Structure_AdapterModules/ModuleLoader.cs +++ b/Structure_AdapterModules/ModuleLoader.cs @@ -45,7 +45,8 @@ public static void LoadModules(this BHoMAdapter adapter) adapter.AdapterModules.Add(new GetLoadElementsWithoutID(adapter)); adapter.AdapterModules.Add(new GetLoadElementsWithoutID(adapter)); adapter.AdapterModules.Add(new GetGravityLoadElementsWithoutID(adapter)); - adapter.AdapterModules.Add(new GetGravityLoadElementsWithoutID(adapter)); + adapter.AdapterModules.Add(new GetGravityLoadElementsWithoutID(adapter)); + adapter.AdapterModules.Add(new GetGravityLoadElementsWithoutID(adapter)); } } }