Skip to content
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

simplified #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Examples/Grids_LINK Example.gh
Binary file not shown.
65 changes: 59 additions & 6 deletions Grasshopper_Doodles_Public/DataAccessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace Grasshopper_Doodles_Public
/// </summary>
static class DataAccessHelper
{

static string msg = "\nThis might be because your component is outdated. Try to drag a new component of this type to the canvas and see if it helps :-)";
// Source: https://github.com/arendvw/clipper/tree/master/ClipperComponents/Helpers
// Author: Arend van Waart [email protected]

Expand Down Expand Up @@ -44,7 +46,15 @@ public static T Fetch<T>(this IGH_DataAccess da, int position)
{

var temp = default(T);
da.GetData(position, ref temp);
try
{
da.GetData(position, ref temp);

}
catch (System.IndexOutOfRangeException e)
{
throw new IndexOutOfRangeException($"Input parameter not found at position {position}" + msg, e);
}
return temp;
}
/// <summary>
Expand All @@ -57,7 +67,15 @@ public static T Fetch<T>(this IGH_DataAccess da, int position)
public static T Fetch<T>(this IGH_DataAccess da, string name)
{
var temp = default(T);
da.GetData(name, ref temp);
try
{
da.GetData(name, ref temp);

}
catch (System.IndexOutOfRangeException e)
{
throw new IndexOutOfRangeException($"Input parameter not found: {name}" + msg, e);
}
return temp;
}

Expand All @@ -71,7 +89,15 @@ public static T Fetch<T>(this IGH_DataAccess da, string name)
public static List<T> FetchList<T>(this IGH_DataAccess da, int position)
{
var temp = new List<T>();
da.GetDataList(position, temp);
try
{
da.GetDataList(position, temp);

}
catch (System.IndexOutOfRangeException e)
{
throw new IndexOutOfRangeException($"Input parameter not found at position {position}" + msg, e);
}
return temp;
}

Expand All @@ -85,7 +111,15 @@ public static List<T> FetchList<T>(this IGH_DataAccess da, int position)
public static List<T> FetchList<T>(this IGH_DataAccess da, string name)
{
var temp = new List<T>();
da.GetDataList(name, temp);
try
{
da.GetDataList(name, temp);

}
catch (System.IndexOutOfRangeException e)
{
throw new IndexOutOfRangeException($"Input parameter not found: {name}" + msg, e);
}
return temp;
}
/// <summary>
Expand All @@ -97,7 +131,16 @@ public static List<T> FetchList<T>(this IGH_DataAccess da, string name)
/// <returns></returns>
public static GH_Structure<T> FetchTree<T>(this IGH_DataAccess da, int position) where T : IGH_Goo
{
da.GetDataTree(position, out GH_Structure<T> temp);
GH_Structure<T> temp = default(GH_Structure<T>);
try
{

da.GetDataTree(position, out temp);
}
catch (System.IndexOutOfRangeException e)
{
throw new IndexOutOfRangeException($"Input parameter not found at position {position}" + msg, e);
}
return temp;
}

Expand All @@ -110,7 +153,17 @@ public static GH_Structure<T> FetchTree<T>(this IGH_DataAccess da, int position)
/// <returns></returns>
public static GH_Structure<T> FetchTree<T>(this IGH_DataAccess da, string name) where T : IGH_Goo
{
da.GetDataTree(name, out GH_Structure<T> temp);

GH_Structure<T> temp = default(GH_Structure<T>);
try
{
da.GetDataTree(name, out temp);

}
catch (System.IndexOutOfRangeException e)
{
throw new IndexOutOfRangeException($"Input parameter not found: {name}" + msg, e);
}
return temp;
}
}
Expand Down
8 changes: 6 additions & 2 deletions Grasshopper_Doodles_Public/GH_Grid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class GhcGrid : GH_Component
/// </summary>
public GhcGrid()
: base("Grid", "Grid",
"GraceHopper Grid\nUse this for analysis (Doodles_HLA).\nTodo:Use Clipper for offset and self intersect.",
"GraceHopper Grid\nUse this for analysis (Doodles_HLA). Based on https://github.com/HenningLarsenArchitects/Grasshopper_Doodles_Public",
Constants.GH_TAB, Constants.GH_GENERIC_SUBTAB)
{
}
Expand All @@ -44,6 +44,8 @@ protected override void RegisterInputParams(GH_Component.GH_InputParamManager pM
pManager[ps].Optional = true;
// TODO: https://discourse.ladybug.tools/t/none-uniform-grid/2361/11

pManager.AddBooleanParameter("GoLarge", "GoLarge", "Set to true if you accept grids larger than 60000 points. This is a safety check.", GH_ParamAccess.item, false);




Expand All @@ -57,6 +59,7 @@ protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager
pManager.AddGenericParameter("Grids", "G", "Output grids. GreenScenario.Geometry.Grid class", GH_ParamAccess.list);
pManager.AddMeshParameter("Mesh", "M", "Meshes", GH_ParamAccess.list);
pManager.AddGenericParameter("Points", "Pt", "Simulation points (center of each face)", GH_ParamAccess.tree);

//pManager.AddTextParameter("msg", "m", "msg", GH_ParamAccess.item);
}

Expand All @@ -73,6 +76,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
var offset = Units.ConvertFromMeter(DA.Fetch<double>("Vertical Offset [m]"));
var useCenters = DA.Fetch<bool>("IsoCurves");
var geometries = DA.FetchList<IGH_GeometricGoo>("Geometry");
var goLarge = DA.Fetch<bool>("GoLarge");

DataTree<Point3d> centers = new DataTree<Point3d>();
List<Grid> myGrids = new List<Grid>();
Expand Down Expand Up @@ -126,7 +130,7 @@ protected override void SolveInstance(IGH_DataAccess DA)

for (int i = 0; i < breps.Count; i++)
{
myGrids.Add(new Grid(breps[i], gridSize, useCenters: useCenters));
myGrids.Add(new Grid(breps[i], gridSize, useCenters: useCenters, goLarge));
}

for (int i = 0; i < myGrids.Count; i++)
Expand Down
Loading