Skip to content

Some updates based on recent project needs - Revised - #11

Open
jjsolly wants to merge 3 commits into
CecilieBrandt:masterfrom
jjsolly:master
Open

Some updates based on recent project needs - Revised#11
jjsolly wants to merge 3 commits into
CecilieBrandt:masterfrom
jjsolly:master

Conversation

@jjsolly

@jjsolly jjsolly commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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

Copilot AI lite review requested due to automatic review settings August 7, 2026 12:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GoalObject implementations out of component classes into K2Engineering.Goals (same files), updating components to using K2Engineering.Goals.
  • Converted several DataTypes/*Data classes to GH_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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants