-
Notifications
You must be signed in to change notification settings - Fork 15
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
BHoM_Engine: Add and Query Fragments #1185
BHoM_Engine: Add and Query Fragments #1185
Conversation
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 is not the right place for a method which will be needed by so many disciplines. This will result in duplicated code in every engine.
ok, I implemented comments and moved to the correct place as advice |
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.
PR
- Change PR title to reflect the actual engine being modified and to correctly identify the change
- Bullet point the change log as there are 2 changes here
Code
- See comments on the code
BHoM_Engine/Modify/AddFragment.cs
Outdated
[Input("iBHoMObject", "Any object implementing the IBHoMObject interface that can have fragment properties appended to it")] | ||
[Input("fragment", "Any fragment object implementing the IBHoMFragment interface to append to the object")] | ||
[Output("iBHoMObject", "The BHoM object with the added fragment")] | ||
public static IBHoMObject AddFragment(this IBHoMObject iBHoMObject, IBHoMFragment fragment) |
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.
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.
Another thing on this method, You will need to clone the object to be changed as well as its list before modifying it. Either use the DeepClone method in the BHoMEngine, or shallow clone the object, and copy the fragment list. Right now, the incoming objects will be changed, changing things upstream in an visual programming workflow.
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.
added comment
BHoM_Engine/Modify/AddFragment.cs
Outdated
[Input("iBHoMObject", "Any object implementing the IBHoMObject interface that can have fragment properties appended to it")] | ||
[Input("fragment", "Any fragment object implementing the IBHoMFragment interface to append to the object")] | ||
[Output("iBHoMObject", "The BHoM object with the added fragment")] | ||
public static IBHoMObject AddFragment(this IBHoMObject iBHoMObject, IBHoMFragment fragment) |
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.
Another thing on this method, You will need to clone the object to be changed as well as its list before modifying it. Either use the DeepClone method in the BHoMEngine, or shallow clone the object, and copy the fragment list. Right now, the incoming objects will be changed, changing things upstream in an visual programming workflow.
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.
My previous comments have not yet been addressed. Requesting changes to ensure they are addressed before this is merged.
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 is a good improvement, some minor comments relating to style and documentation in the code (functionality is good). See below.
PR
- Change PR title to reflect the actual engine being modified and to correctly identify the change
- Bullet point the change log as there are 2 changes here
Code
- See comments on the code
BHoM_Engine/Modify/AddFragment.cs
Outdated
if(o.Fragments.Contains(fragment)) | ||
{ | ||
if(replace) | ||
{ |
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.
Use single line if
statements given these are single line operations
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.
done
BHoM_Engine/Modify/AddFragment.cs
Outdated
} | ||
else | ||
{ | ||
Reflection.Compute.RecordError("Fragment already exists"); |
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 we expand this error message to tell the user something like "That fragment already exists on this object. If you would like to replace the existing fragment set the 'replace' input to 'true'"
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.
done
BHoM_Engine/Modify/AddFragment.cs
Outdated
[Description("Appends a Fragment Property to a given BHoM Object")] | ||
[Input("iBHoMObject", "Any object implementing the IBHoMObject interface that can have fragment properties appended to it")] | ||
[Input("fragment", "Any fragment object implementing the IBHoMFragment interface to append to the object")] | ||
[Input("replace", "If true will replace exisiting fragments ")] |
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.
Expand the description to be more informative for the user, Something like "If set to true and the object already contains a fragment of the type being added, the fragment will be replaced by this instance"
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.
done
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.
Finally LGTM
While this LGTM now and will be merged in to unblock on the workflows, @michaldengusiak please can you raise issues to deprecate the existing methods within the Environment Engine which do similar functionality. Please assign to me and put on the 2.4RC milestone. Cheers! |
NOTE: Depends on
Issues addressed by this PR
Closes #1184
Add Modify AddFragments
Test files
N/A
Changelog
AddFragments
FindFragment
Additional comments