using System;
using System.Collections.Generic;
using Grasshopper.Kernel;
using Rhino.Geometry;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;
namespace AndersPointTest
{
public class AndersPointTestComponent : GH_Component
{
///
/// Each implementation of GH_Component must provide a public
/// constructor without any arguments.
/// Category represents the Tab in which the component will appear,
/// Subcategory the panel. If you use non-existing tab or panel names,
/// new tabs/panels will automatically be created.
///
public AndersPointTestComponent()
: base("AndersPointTest", "Nickname",
"Test made up by Anders",
"Tests", "Anders")
{
}
///
/// Registers all the input parameters for this component.
///
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddIntegerParameter("Count", "X", "count", GH_ParamAccess.item);
}
///
/// Registers all the output parameters for this component.
///
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddPointParameter("Points", "P", "Points", GH_ParamAccess.tree);
}
///
/// This is the method that actually does the work.
///
/// The DA object can be used to retrieve data from input parameters and
/// to store data in output parameters.
protected override void SolveInstance(IGH_DataAccess DA)
{
int x = 0;
if (!DA.GetData(0, ref x)) return;
var t = new GH_Structure();
var branch = t.EnsurePath(0);
branch.Capacity = x;
for (int i = 0; i < x; i++)
{
branch.Add(new GH_Point(new Point3d(i, i + 1, i + 2)));
}
DA.SetDataTree(0, t);
}
///
/// Provides an Icon for every component that will be visible in the User Interface.
/// Icons need to be 24x24 pixels.
///
protected override System.Drawing.Bitmap Icon
{
get
{
// You can add image files to your project resources and access them like this:
//return Resources.IconForThisComponent;
return null;
}
}
///
/// Each component must have a unique Guid to identify it.
/// It is vital this Guid doesn't change otherwise old ghx files
/// that use the old ID will partially fail during loading.
///
public override Guid ComponentGuid
{
get { return new Guid("{9fc581a9-d605-4df5-b0ac-dc90febe2991}"); }
}
}
}