Skip to content
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d67a0fd
Initial plan
Copilot Aug 21, 2025
f50a1a8
Implement proper update functionality for LoadCombinations
Copilot Aug 21, 2025
76a6e23
Add null check and warning for empty LoadCases in update method
Copilot Aug 21, 2025
bfb1008
Fix compilation error: Replace CaseFactors.Clear() with individual De…
Copilot Aug 21, 2025
ed3ac69
Fix update method to use Number property and add fallback to Create f…
Copilot Aug 21, 2025
3a19af3
Fix Create method logic and remove fallback behavior from Update method
Copilot Aug 21, 2025
ff4fa73
Revert Create method logic and simplify Update method lookup
Copilot Aug 21, 2025
51c170a
Fix LoadCombination Update method and restore Create method functiona…
Chrisshort92 Aug 21, 2025
204ade8
Initial plan
Copilot Nov 13, 2025
1ced695
Add RobotId and Number validation to LoadCombination update
Copilot Nov 13, 2025
c9e9b24
Changed to error instead of warning
staintono Nov 13, 2025
8b43266
Add validation check for RobotId and Number mismatch in LoadCombinati…
staintono Nov 13, 2025
f2e3614
Initial plan
Copilot Nov 13, 2025
0e0d306
Updates PR Description (#575)
staintono Nov 13, 2025
05ec678
Initial plan
Copilot Nov 13, 2025
3bde84e
Assign RobotId from LoadCombinationNumber when RobotId is 0
Copilot Nov 13, 2025
72779ff
Add informative message when RobotId is assigned from LoadCombination…
Copilot Nov 13, 2025
77a8ff3
Assign RobotId from LoadCombinationNumber when missing during update …
staintono Nov 13, 2025
ef8c872
Update Robot_Adapter/CRUD/Update/Loads/LoadCombinations.cs
Chrisshort92 Dec 12, 2025
72d31d4
Update Robot_Adapter/CRUD/Update/Loads/LoadCombinations.cs
Chrisshort92 Dec 12, 2025
33592c8
Update Robot_Adapter/CRUD/Update/Loads/LoadCombinations.cs
Chrisshort92 Dec 12, 2025
e7f4bcc
Update Robot_Adapter/CRUD/Update/Loads/LoadCombinations.cs
Chrisshort92 Dec 12, 2025
b13b29c
Update Robot_Adapter/CRUD/Update/Loads/LoadCombinations.cs
Chrisshort92 Dec 12, 2025
4070270
Update to compliance checks
Chrisshort92 Dec 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 83 additions & 8 deletions Robot_Adapter/CRUD/Update/Loads/LoadCombinations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using System;
using System.Collections.Generic;
using BH.oM.Base;
using BH.oM.Structure.Elements;
using BH.oM.Structure.SectionProperties;
using BH.oM.Structure.SurfaceProperties;
using BH.oM.Structure.Constraints;
using BH.oM.Structure.Loads;
using BH.oM.Physical.Materials;
using BH.oM.Adapter;
using BH.Engine.Base;
using BH.oM.Base;
using BH.oM.Structure;
using BH.oM.Adapters.Robot;
using BH.Engine.Adapter;
using BH.oM.Base.Debugging;
using RobotOM;

namespace BH.Adapter.Robot
Expand All @@ -42,7 +42,82 @@ public partial class RobotAdapter
protected bool Update(IEnumerable<LoadCombination> loadCombinations)
{
bool success = true;
success = ICreate(loadCombinations);

m_RobotApplication.Project.Structure.Cases.BeginMultiOperation();

foreach (LoadCombination lComb in loadCombinations)
{
//Check combination itself is not null
if(!CheckNotNull(lComb))
{
Compute.RecordError("LoadCombination is null.");
return false;
}

// Use the Number property directly and try to get the combination
int combinationId = lComb.Number;

// Check if the RobotId matches the LoadCombination Number
int robotId = Engine.Adapter.Query.HasAdapterIdFragment(lComb, typeof(RobotId)) ? GetAdapterId<int>(lComb) : 0;

// If the LoadCombination doesn't have a RobotId, assign it from the Number
if (robotId == 0)
{
this.SetAdapterId(lComb, combinationId);
robotId = combinationId;
Compute.RecordWarning($"LoadCombination with number {combinationId} did not have a RobotId. RobotId has been set to the LoadCombination number.");
}
else if (robotId != combinationId)
{
Compute.RecordWarning($"Load combination has mismatched IDs: RobotId = {robotId}, Number = {combinationId}. Using Number property for update.");
}

// Get the existing combination from Robot (following pattern from Loadcases Update method)
RobotCaseCombination rCaseCombination = m_RobotApplication.Project.Structure.Cases.Get(combinationId) as RobotCaseCombination;
if (rCaseCombination == null)
{
Compute.RecordError("Load combination with number " + combinationId.ToString() + " does not exist in Robot. Load combination could not be updated!");
return false;
}

// Update the combination name if provided
if (!string.IsNullOrWhiteSpace(lComb.Name))
rCaseCombination.Name = lComb.Name;

// Clear existing case factors by deleting them individually
// Note: Robot API requires deleting case factors in reverse order to avoid index shifting
for (int i = rCaseCombination.CaseFactors.Count; i >= 1; i--)
{
rCaseCombination.CaseFactors.Delete(i);
}

// Add new case factors from the BHoM LoadCombination
if (lComb.LoadCases != null && lComb.LoadCases.Count > 0)
{
for (int i = rCaseCombination.CaseFactors.Count; i >= 1; i--)
{
rCaseCombination.CaseFactors.Delete(i);
}
for (int i = 0; i < lComb.LoadCases.Count; i++)
{
//Check tuple as well as case not null
if (CheckNotNull(lComb.LoadCases[i], EventType.Error, typeof(LoadCombination)) &&
CheckNotNull(lComb.LoadCases[i].Item2, EventType.Error, typeof(LoadCombination)))
{
System.Tuple<double, ICase> loadcase = lComb.LoadCases[i];
rCaseCombination.CaseFactors.New(lComb.LoadCases[i].Item2.Number, lComb.LoadCases[i].Item1);
}
}
}
else
{
Compute.RecordWarning("Load combination with number " + combinationId.ToString() + " has no load cases.");
}

}

m_RobotApplication.Project.Structure.Cases.EndMultiOperation();

return success;
}

Expand Down