-
Notifications
You must be signed in to change notification settings - Fork 4
Add update load combination to adapter push #565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Add update load combination to adapter push #565
Conversation
Co-authored-by: Chrisshort92 <[email protected]>
Co-authored-by: Chrisshort92 <[email protected]>
…lete() calls Co-authored-by: Chrisshort92 <[email protected]>
…or non-existent combinations Co-authored-by: Chrisshort92 <[email protected]>
Co-authored-by: Chrisshort92 <[email protected]>
Co-authored-by: Chrisshort92 <[email protected]>
…lity in Robot_Adapter (#564)
staintono
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested using the provided test script, load combinations are updated as expected based on the combination number. Error is thrown if combination does not yet exist in the model, as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the title, folder for the test script and the text for the PR. The body mentions Create methods breaking but does not address it in the PR. Similar for the Fixed Update Method and Technical Improvements, not sure how much it relates to the PR changes. I would keep the change log and description to a minimum for clarity.
I ran the script, but it just tried to update the RobotId for LoadCombination to 100, but it's already set as 100 so it doesn't really test the Update. I tried changing it to 200 and nothing happens:
In your script I would also want to a case that updates the factors, a case that updates the Loadcase and a case that tries to update with empty cases (prompting the error).
|
@copilot update the PR description to summarise the current state of the changes. |
|
@staintono I've opened a new pull request, #575, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: staintono <[email protected]>
|
@BHoMBot Check Compliance |
|
I have just re-tested this functionality and works as expected with the update functions @staintono states above. @peterjamesnugent can you re-review ready for merge? |
peterjamesnugent
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes that were not covered in the test scripts, handling of null and where to exit the routine as well as warning and error messaging.
| int combinationId = lComb.Number; | ||
|
|
||
| // Check if the RobotId matches the LoadCombination Number | ||
| int robotId = GetAdapterId<int>(lComb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| { | ||
| this.SetAdapterId(lComb, combinationId); | ||
| robotId = combinationId; | ||
| Engine.Base.Compute.RecordNote($"LoadCombination with number {combinationId} did not have a RobotId. RobotId has been set to the LoadCombination number."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Engine.Base.Compute.RecordNote($"LoadCombination with number {combinationId} did not have a RobotId. RobotId has been set to the LoadCombination number."); | |
| Engine.Base.Compute.RecordWarning($"LoadCombination with number {combinationId} did not have a RobotId. RobotId has been set to the LoadCombination number."); |
Warning given you have made changes to the users object.
| Engine.Base.Compute.RecordWarning("Load combination with number " + combinationId.ToString() + " does not exist in Robot. Load combination could not be updated!"); | ||
| success = false; | ||
| continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Engine.Base.Compute.RecordWarning("Load combination with number " + combinationId.ToString() + " does not exist in Robot. Load combination could not be updated!"); | |
| success = false; | |
| continue; | |
| Engine.Base.Compute.RecordError("Load combination with number " + combinationId.ToString() + " does not exist in Robot. Load combination could not be updated!"); | |
| return false; |
Suggest we return an error here and exit the method given you cannot do anything with a null rCaseCombination.
| for (int i = rCaseCombination.CaseFactors.Count; i >= 1; i--) | ||
| { | ||
| rCaseCombination.CaseFactors.Delete(i); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not put this inside the if statement below? That way you don't clear all the factors of a LoadCombination that has no Loadcases.
| } | ||
| else | ||
| { | ||
| Engine.Base.Compute.RecordWarning("Load combination with number " + combinationId.ToString() + " has no load cases. The combination has been cleared of all case factors."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Engine.Base.Compute.RecordWarning("Load combination with number " + combinationId.ToString() + " has no load cases. The combination has been cleared of all case factors."); | |
| Engine.Base.Compute.RecordWarning("Load combination with number " + combinationId.ToString() + " has no load cases."); |
Then we don't delete the factors.
| //Check combination itself is not null | ||
| if (!CheckNotNull(lComb)) | ||
| continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's null don't we want to return a error stating as such - and then returning false?
| } | ||
| else if (robotId != combinationId) | ||
| { | ||
| Engine.Base.Compute.RecordError($"Load combination has mismatched IDs: RobotId = {robotId}, Number = {combinationId}. Using Number property for update."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Engine.Base.Compute.RecordError($"Load combination has mismatched IDs: RobotId = {robotId}, Number = {combinationId}. Using Number property for update."); | |
| Engine.Base.Compute.RecordWarning($"Load combination has mismatched IDs: RobotId = {robotId}, Number = {combinationId}. Using Number property for update."); |
I would make this a warning, to make the user aware of a change of approach. Errors are usually when something is not going to work.
| for (int i = 0; i < lComb.LoadCases.Count; i++) | ||
| { | ||
| //Check tuple as well as case not null | ||
| if (CheckNotNull(lComb.LoadCases[i], oM.Base.Debugging.EventType.Error, typeof(LoadCombination)) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add a using BH.oM.Base.Debugging; statement you can simplify this.
I would also add using
using BH.oM.Adapters.Robot; using BH.Engine.Adapter;
| } | ||
|
|
||
| // Set the adapter ID to maintain the connection between BHoM and Robot objects | ||
| this.SetAdapterId(lComb, lComb.Number); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this line needed? You have already updated the object id when it didn't match the load combination number?


NOTE: Depends on
Issues addressed by this PR
Closes #563
Implements
Updatefunctionality forLoadCombinationsin Robot_Adapter. The Update method now:Numberproperty via directGet()call (following Loadcases pattern)Test files
https://burohappold.sharepoint.com/:f:/r/sites/BHoM/02_Current/12_Scripts/02_Pull%20Request/BHoM/Robot_Toolkit/%23565-add-update-load-combination-to-adapter-push?csf=1&web=1&e=GLPz1q
Changelog
Updatefunctionality forLoadCombinationsinRobot_AdapterAdditional comments