Some updates based on recent project needs - Revised - #11
Open
jjsolly wants to merge 3 commits into
Open
Conversation
Update with assistance of AI to solve internalisable/savable data
There was a problem hiding this comment.
Pull request overview
This PR refactors several Kangaroo goal implementations into a dedicated K2Engineering.Goals namespace and updates multiple DataTypes to inherit from GH_Goo<> with Read/Write serialization support, enabling more native/internal Grasshopper IO usage. It also extends the Cable component with a right-click mode to interpret the optional input as either pretension force or tightening action.
Changes:
- Moved multiple
GoalObjectimplementations out of component classes intoK2Engineering.Goals(same files), updating components tousing K2Engineering.Goals. - Converted several
DataTypes/*Dataclasses toGH_Goo<>with casting and GH_IO serialization (Read/Write). - Added a Cable context-menu toggle for “Pretension Force [N]” vs “Tightening Action [mm/m]”, persisted via
GH_IWriter/GH_IReader.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| K2Engineering/K2Engineering/Support6DOF.cs | Moves Support6DOFGoal into K2Engineering.Goals and updates component accordingly. |
| K2Engineering/K2Engineering/Support.cs | Moves SupportGoal into K2Engineering.Goals and updates component accordingly. |
| K2Engineering/K2Engineering/Rod.cs | Moves RodGoal into K2Engineering.Goals and updates component accordingly. |
| K2Engineering/K2Engineering/Pressure.cs | Moves PressureGoal into K2Engineering.Goals and updates component accordingly. |
| K2Engineering/K2Engineering/Load.cs | Moves LoadGoal into K2Engineering.Goals and updates component accordingly. |
| K2Engineering/K2Engineering/Beam.cs | Moves BeamGoal into K2Engineering.Goals and updates component accordingly. |
| K2Engineering/K2Engineering/Bar.cs | Moves BarGoal into K2Engineering.Goals and updates component accordingly. |
| K2Engineering/K2Engineering/Cable.cs | Adds pretension vs tightening mode UI + persistence; updates goal constructor signature. |
| K2Engineering/K2Engineering/K2Engineering.csproj | Updates Rhino/Grasshopper reference hint paths and post-build copy behavior. |
| K2Engineering/K2Engineering/DataTypes/SupportData.cs | Converts to GH_Goo<> with serialization + casting. |
| K2Engineering/K2Engineering/DataTypes/Support6DOFData.cs | Converts to GH_Goo<> with serialization + casting. |
| K2Engineering/K2Engineering/DataTypes/RodData.cs | Converts to GH_Goo<> with serialization + casting. |
| K2Engineering/K2Engineering/DataTypes/PressureData.cs | Converts to GH_Goo<> with serialization + casting. |
| K2Engineering/K2Engineering/DataTypes/PointLoadData.cs | Converts to GH_Goo<> with serialization + casting. |
| K2Engineering/K2Engineering/DataTypes/BeamData.cs | Converts to GH_Goo<> with serialization + casting. |
| K2Engineering/K2Engineering/DataTypes/BarData.cs | Converts to GH_Goo<> with serialization + casting. |
Suppressed comments (1)
K2Engineering/K2Engineering/DataTypes/PressureData.cs:183
- Same issue as above: when casting from a GH_ObjectWrapper, Locations/Loads are only overwritten if non-null, otherwise previous values remain. Clear the fields when the wrapped data has null arrays to avoid stale state.
if (pdWrapper.Locations != null)
{
Locations = new Point3d[pdWrapper.Locations.Length];
Array.Copy(pdWrapper.Locations, Locations, pdWrapper.Locations.Length);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+117
to
121
| double val = 0.0; | ||
| if (this.Params.Input[3].SourceCount != 0) | ||
| { | ||
| DA.GetData(3, ref preStress); | ||
| DA.GetData(3, ref val); | ||
| } |
Comment on lines
46
to
+50
| <Reference Include="GH_IO"> | ||
| <HintPath>..\..\..\..\..\..\..\Program Files\Rhino 6\Plug-ins\Grasshopper\GH_IO.dll</HintPath> | ||
| <HintPath>C:\Program Files\Rhino 7\Plug-ins\Grasshopper\GH_IO.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="Grasshopper"> | ||
| <HintPath>..\..\..\..\..\..\..\Program Files\Rhino 6\Plug-ins\Grasshopper\Grasshopper.dll</HintPath> | ||
| <HintPath>C:\Program Files\Rhino 7\Plug-ins\Grasshopper\Grasshopper.dll</HintPath> |
Comment on lines
+137
to
+141
| double axialStiffness = (E * A) / restLength; //Unit: N/m | ||
| int axialDigits = axialStiffness.ToString().Split('.')[0].Length; | ||
|
|
||
| //Local end planes | ||
| P0 = startPlane; | ||
| P1 = endPlane; | ||
| P0R = P0; | ||
| P1R = P1; | ||
| double bendingStiffness = E * Math.Max(Iy, Iz); | ||
| bendingStiffness *= 0.001; //Still needs some adjustment to improve convergence speed |
Comment on lines
+158
to
+167
| if (pd.Locations != null) | ||
| { | ||
| Locations = new Point3d[pd.Locations.Length]; | ||
| Array.Copy(pd.Locations, Locations, pd.Locations.Length); | ||
| } | ||
| if (pd.Loads != null) | ||
| { | ||
| Loads = new Vector3d[pd.Loads.Length]; | ||
| Array.Copy(pd.Loads, Loads, pd.Loads.Length); | ||
| } |
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.
Hi @CecilieBrandt - long time no speak!
We were recently working with K2E and needed to store some results data via internalising or native gh DataInput or DataOutput components.
So we used a bit of thought (and some AI assistance) to do a few updates:
Inherited from GH_Goo and added the methods required for serialisation
Updated some of the data type names to make them more consistent.
Updated the cable goal to give an option where we can define pretension either by a force or an explicit length change via right click context menu.
Take a look and let us know what you think.
James