Update with assistance of AI to solve internalisable/savable data - #5
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates K2Engineering’s custom Grasshopper data types so they can be properly internalised/serialised (persist through saving/reopening .gh files) by converting them to GH_Goo<T> types with explicit Write/Read implementations. It also refactors several Kangaroo GoalObject helper classes out of component classes into a dedicated K2Engineering.Goals namespace to support cleaner reuse and naming consistency.
Changes:
- Converted 7 custom data containers in
DataTypes/toGH_Goo<T>withWrite/Read,Duplicate, and casting support for Grasshopper persistence. - Refactored multiple
GoalObjectimplementations intonamespace K2Engineering.Goalsand updated components to reference them viausing K2Engineering.Goals;. - Performed minor tidying (including naming/structure reshuffles) alongside the persistence changes.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| K2Engineering/K2Engineering/Support6DOF.cs | Moves Support6DOFGoal into K2Engineering.Goals and updates component to reference it. |
| K2Engineering/K2Engineering/Support.cs | Moves SupportGoal into K2Engineering.Goals and updates component to reference it. |
| K2Engineering/K2Engineering/Rod.cs | Moves RodGoal into K2Engineering.Goals and updates component to reference it. |
| K2Engineering/K2Engineering/Pressure.cs | Moves PressureGoal into K2Engineering.Goals and updates component to reference it. |
| K2Engineering/K2Engineering/Load.cs | Moves LoadGoal into K2Engineering.Goals and updates component to reference it. |
| K2Engineering/K2Engineering/Cable.cs | Moves CableGoal into K2Engineering.Goals and updates component to reference it. |
| K2Engineering/K2Engineering/Beam.cs | Moves BeamGoal into K2Engineering.Goals and updates component to reference it. |
| K2Engineering/K2Engineering/Bar.cs | Moves BarGoal into K2Engineering.Goals and updates component to reference it. |
| K2Engineering/K2Engineering/DataTypes/SupportData.cs | Converts SupportData to GH_Goo<SupportData> with persistence and casting. |
| K2Engineering/K2Engineering/DataTypes/Support6DOFData.cs | Converts Support6DOFData to GH_Goo<Support6DOFData> with plane/force/moment persistence. |
| K2Engineering/K2Engineering/DataTypes/RodData.cs | Converts RodData to GH_Goo<RodData> with plane + scalar persistence. |
| K2Engineering/K2Engineering/DataTypes/PressureData.cs | Converts PressureData to GH_Goo<PressureData> and adds array serialisation logic. |
| K2Engineering/K2Engineering/DataTypes/PointLoadData.cs | Converts PointLoadData to GH_Goo<PointLoadData> with persistence and casting. |
| K2Engineering/K2Engineering/DataTypes/BeamData.cs | Converts BeamData to GH_Goo<BeamData> with plane + scalar persistence. |
| K2Engineering/K2Engineering/DataTypes/BarData.cs | Converts BarData to GH_Goo<BarData> with line + scalar persistence and casting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+88
to
+103
| public class BarGoal : GoalObject | ||
| { | ||
| double restLenght; | ||
| bool isCompressionMember; | ||
| double area; | ||
|
|
||
| public BarGoal(Line L, double E, double A) | ||
| { | ||
| restLenght = L.From.DistanceTo(L.To); | ||
| isCompressionMember = true; | ||
| area = A; | ||
|
|
||
| PPos = new Point3d[2] { L.From, L.To }; | ||
| Move = new Vector3d[2]; | ||
| Weighting = new double[2] { (2 * E * A) / restLenght, (2 * E * A) / restLenght }; // Units: [N/m] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Primary change - Made the data types inherent from GH_Goo so that data from K2E can be internalised and accessed after .gh is saved and reopened. Also lets K2E data be stored and accessed with the native GH DataInput and DataOutput components.
All 7 custom data classes in DataTypes/ now inherit from Grasshopper.Kernel.Types.GH_Goo and implement GH_IO.Serialization
At the same time did a bit of data-type tidying to give more consistent naming.
None of this should affect backwards-compatibility of the plugin.