Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Bug fixes, added Compiled folder with Complied GH Assembly, removed redundancies and problematic components
  • Loading branch information
dominikreisach committed Nov 3, 2023
1 parent 42a455b commit 7a21f62
Show file tree
Hide file tree
Showing 116 changed files with 373 additions and 2,073 deletions.
Binary file removed .vs/SpruceBeetle/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file removed .vs/SpruceBeetle/v16/.suo
Binary file not shown.
722 changes: 0 additions & 722 deletions Alignment/DirectAlignment_GH.cs

This file was deleted.

6 changes: 2 additions & 4 deletions Alignment/IntersectionJoints_GH.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ protected override void RegisterInputParams(GH_Component.GH_InputParamManager pM
pManager.AddGenericParameter("First Alignment", "FA", "First list of aligned Offcuts", GH_ParamAccess.list);
pManager.AddGenericParameter("Second Alignment", "SA", "Second list of aligned Offcuts", GH_ParamAccess.list);
pManager.AddPointParameter("Intersection Point", "IP", "Intersection point between the two alignments", GH_ParamAccess.item);
pManager.AddNumberParameter("Rotate Joint", "RJ", "Rotate the joint the alter its direction", GH_ParamAccess.item, 0.0);
pManager.AddNumberParameter("Rotate Joint", "RJ", "Rotate the joint to alter its direction", GH_ParamAccess.item, 0.0);
pManager.AddNumberParameter("Width", "W", "The width of the lap joint", GH_ParamAccess.item, 1.0);
pManager.AddIntegerParameter("Joint Type", "JT", "Adds the specified joint type: 0 = spline joint, 1 = cross-lap joint", GH_ParamAccess.item, 0);
pManager.AddIntegerParameter("Joint Type", "JT", "Adds the specified joint type: 0 = spline joint, 1 = cross-lap joint", GH_ParamAccess.item, 1);

for (int i = 0; i < pManager.ParamCount; i++)
pManager[i].WireDisplay = GH_ParamWireDisplay.faint;
Expand All @@ -63,7 +63,6 @@ protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager
{
pManager.AddGenericParameter("Offcuts", "Oc", "List of aligned and intersected Offcuts", GH_ParamAccess.tree);
pManager.AddGenericParameter("Intersection Offcuts", "IOc", "List of intersecting Offcuts", GH_ParamAccess.tree);
pManager.AddBrepParameter("B", "B", "B", GH_ParamAccess.list);

for (int i = 0; i < pManager.ParamCount; i++)
pManager[i].WireDisplay = GH_ParamWireDisplay.faint;
Expand Down Expand Up @@ -217,7 +216,6 @@ protected override void SolveInstance(IGH_DataAccess DA)
// access output parameters
DA.SetDataTree(0, offcutGHList);
DA.SetDataTree(1, intOffcutGHList);
DA.SetDataList(2, joints);
}


Expand Down
2 changes: 1 addition & 1 deletion Alignment/OptimizedAlignment_GH.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
SecondPlane = planeList[1],
AveragePlane = planeList[2],
MovedAveragePlane = planeList[3],
BasePlane = Offcut.ComputeBasePlane(planeList[4], offcutData[maxIndex].X, offcutData[maxIndex].Y, offcutData[maxIndex].Z),
BasePlane = Offcut.ComputeBasePlane(planeList[2], offcutData[maxIndex].X, offcutData[maxIndex].Y, offcutData[maxIndex].Z),
PositionIndex = ocBaseIndex
};

Expand Down
28 changes: 13 additions & 15 deletions Alignment/TenonJoints_GH.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ protected override void RegisterInputParams(GH_Component.GH_InputParamManager pM
pManager.AddTextParameter("Joint Type", "JT", "Adds the specified joint type", GH_ParamAccess.item);
pManager.AddIntegerParameter("Tenon Count", "TC", "The number of tenons to be created", GH_ParamAccess.item, 1);

//pManager.AddCurveParameter("Custom Shape", "CS", "Creates a custom tenon from the specifc shape of a closed planar curve", GH_ParamAccess.item);
//pManager[7].Optional = true;

// pManager[7].Optional = true;

pManager.AddCurveParameter("Custom Shape", "CS", "Creates a custom tenon from the specifc shape of a closed planar curve", GH_ParamAccess.item);
pManager[7].Optional = true;

parameter = pManager[5];

for (int i = 0; i < pManager.ParamCount; i++)
Expand Down Expand Up @@ -138,16 +136,16 @@ protected override void SolveInstance(IGH_DataAccess DA)
if (!DA.GetData(4, ref jointZ)) return;
if (!DA.GetData(5, ref jointKey)) return;
if (!DA.GetData(6, ref tenonCount)) return;
//if (!DA.GetData(7, ref jointShape)) return;

//// check if the curve is closed and planar
//if (jointShape != null)
//{
// if (!jointShape.IsClosed)
// AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The curve is not closed!");
// else if (!jointShape.IsPlanar())
// AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The curve is not planar!");
//}
DA.GetData(7, ref jointShape);

// check if the curve is closed and planar
if (jointShape != null)
{
if (!jointShape.IsClosed)
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The curve is not closed!");
else if (!jointShape.IsPlanar())
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The curve is not planar!");
}

// get joint type
Dictionary<string, int> jointDict = Joint.GetJointType();
Expand Down
Binary file added Compiled/SpruceBeetle/SpruceBeetle.gha
Binary file not shown.
147 changes: 147 additions & 0 deletions Create/AssembleOffcut_GH.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/*
* MIT License
*
* Copyright (c) 2022 Dominik Reisach
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/


using System;
using System.Collections.Generic;
using Grasshopper.Kernel;
using Rhino.Geometry;


namespace SpruceBeetle.Create
{
public class AssembleOffcut_GH : GH_Component
{
public AssembleOffcut_GH()
: base("Assemble Offcut", "Asmbl", "Assemble Offcut(s) by providing the necessary data.", "Spruce Beetle", " Create")
{
}


// parameter inputs
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddNumberParameter("Index", "i", "Index of the Offcut", GH_ParamAccess.list);
pManager.AddNumberParameter("x-Dimension", "x", "x-Dimension of the Offcut", GH_ParamAccess.list);
pManager.AddNumberParameter("y-Dimension", "y", "y-Dimension of the Offcut", GH_ParamAccess.list);
pManager.AddNumberParameter("z-Dimension", "z", "z-Dimension of the Offcut", GH_ParamAccess.list);

pManager.AddNumberParameter("Volume", "vol", "Volume of the Offcut", GH_ParamAccess.list);
pManager.AddNumberParameter("Fabricated Volume", "fvol", "Volume post fabrication", GH_ParamAccess.list);

pManager.AddBrepParameter("Breps", "B", "Offcuts as Breps", GH_ParamAccess.list);

pManager.AddPlaneParameter("First Plane", "fp", "First plane of the Offcut", GH_ParamAccess.list);
pManager.AddPlaneParameter("Second Plane", "sp", "Second plane of the Offcut", GH_ParamAccess.list);
pManager.AddPlaneParameter("Average Plane", "ap", "Average plane of the Offcut", GH_ParamAccess.list);
pManager.AddPlaneParameter("Moved Average Plane", "map", "Moved average plane of the Offcut", GH_ParamAccess.list);
pManager.AddPlaneParameter("Base Plane", "bp", "Base plane of the Offcut", GH_ParamAccess.list);

pManager.AddIntegerParameter("Position Index", "pi", "Index of the base position", GH_ParamAccess.list);

for (int i = 0; i < pManager.ParamCount; i++)
pManager[i].WireDisplay = GH_ParamWireDisplay.faint;
}


// parameter outputs
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddGenericParameter("Offcut", "Oc", "Assembled Offcut", GH_ParamAccess.list);

pManager[0].WireDisplay = GH_ParamWireDisplay.faint;
}


// main
protected override void SolveInstance(IGH_DataAccess DA)
{
// variables to reference the input parameters to
List<double> indexList = new List<double>();
List<double> xList = new List<double>();
List<double> yList = new List<double>();
List<double> zList = new List<double>();
List<double> volList = new List<double>();
List<double> fabvolList = new List<double>();
List<Brep> brepList = new List<Brep>();
List<Plane> fpList = new List<Plane>();
List<Plane> spList = new List<Plane>();
List<Plane> avrgpList = new List<Plane>();
List<Plane> mavrgpList = new List<Plane>();
List<Plane> bpList = new List<Plane>();
List<int> posList = new List<int>();

// access input parameters
if (!DA.GetDataList(0, indexList)) return;
if (!DA.GetDataList(1, xList)) return;
if (!DA.GetDataList(2, yList)) return;
if (!DA.GetDataList(3, zList)) return;
if (!DA.GetDataList(4, volList)) return;
if (!DA.GetDataList(5, fabvolList)) return;
if (!DA.GetDataList(6, brepList)) return;
if (!DA.GetDataList(7, fpList)) return;
if (!DA.GetDataList(8, spList)) return;
if (!DA.GetDataList(9, avrgpList)) return;
if (!DA.GetDataList(10, mavrgpList)) return;
if (!DA.GetDataList(11, bpList)) return;
if (!DA.GetDataList(12, posList)) return;

// initialise list to store the Offcuts
List<Offcut_GH> offcutGHList = new List<Offcut_GH>();

if (indexList.Count == xList.Count && indexList.Count == yList.Count && indexList.Count == zList.Count && indexList.Count == volList.Count && indexList.Count == fabvolList.Count
&& indexList.Count == brepList.Count && indexList.Count == fpList.Count && indexList.Count == spList.Count && indexList.Count == avrgpList.Count && indexList.Count == mavrgpList.Count
&& indexList.Count == bpList.Count && indexList.Count == posList.Count)
{
for (int i = 0; i < xList.Count; i++)
{
Offcut offcut = new Offcut(brepList[i], indexList[i], xList[i], yList[i], zList[i], volList[i], fabvolList[i], fpList[i], spList[i], avrgpList[i],
mavrgpList[i], bpList[i], posList[i]);
Offcut_GH offcutGH = new Offcut_GH(offcut);
offcutGHList.Add(offcutGH);
}
}
else
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Different amount of data provided");

// access output parameters
DA.SetDataList(0, offcutGHList);
}


//------------------------------------------------------------
// Else
//------------------------------------------------------------

// exposure property
public override GH_Exposure Exposure => GH_Exposure.primary;

// add icon
protected override System.Drawing.Bitmap Icon => Properties.Resources._24x24_ConstructOffcut;

// component giud
public override Guid ComponentGuid => new Guid("17F06CE5-B12C-48FB-8E00-E35DA303FE52");
}

}
92 changes: 92 additions & 0 deletions Fabricate/JSONOffcut_GH.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* MIT License
*
* Copyright (c) 2022 Dominik Reisach
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/


using System;
using System.IO;
using System.Collections.Generic;
using Newtonsoft.Json;
using Grasshopper.Kernel;

namespace SpruceBeetle.Fabricate
{
public class JSONOffcut_GH : GH_Component
{
public JSONOffcut_GH() : base("JSON to Offcut", "To Offcut", "Deserialize the Offcut data from a JSON file", "Spruce Beetle", " Fabricate")
{
}


// parameter inputs
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddTextParameter("File Path", "file", "File path to a JSON file with Offcut data", GH_ParamAccess.item);

pManager[0].WireDisplay = GH_ParamWireDisplay.faint;
}


// parameter outputs
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddGenericParameter("Offcut Data", "OcD", "Deserialized Offcut data", GH_ParamAccess.list);

pManager[0].WireDisplay = GH_ParamWireDisplay.faint;
}


// main
protected override void SolveInstance(IGH_DataAccess DA)
{
// variable to reference the input parameters to
string filePath = "";

// access input parameters
if (!DA.GetData(0, ref filePath)) return;

// read the JSON file
string json = File.ReadAllText(filePath);

// deserialize JSON
List<Offcut> offcutData = JsonConvert.DeserializeObject<List<Offcut>>(json);

// return offcut data
DA.SetDataList(0, offcutData);
}


//------------------------------------------------------------
// Else
//------------------------------------------------------------

// exposure property
public override GH_Exposure Exposure => GH_Exposure.secondary;

// add icon
protected override System.Drawing.Bitmap Icon => Properties.Resources._24x24_JSONOffcut;

// component giud
public override Guid ComponentGuid => new Guid("DC0F4AFA-363F-4363-8837-8A9A2983116A");
}
}
Loading

0 comments on commit 7a21f62

Please sign in to comment.