using System;
using System.Collections.Generic;
using System.ComponentModel;
using Grasshopper.Kernel;
using Rhino.FileIO;
using Rhino.Geometry;
namespace Communication_Test
{
public class Component2 : GH_Component
{
///
/// Initializes a new instance of the Component2 class.
///
public Component2()
: base("Component 2",
"C2",
"Description",
"Utils",
"Testing")
{
}
///
/// Registers all the input parameters for this component.
///
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddNumberParameter("Input1", "Input1", "Input1", GH_ParamAccess.item);
pManager.AddNumberParameter("Input2", "Input2", "Input2", GH_ParamAccess.item);
}
///
/// Registers all the output parameters for this component.
///
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddNumberParameter("Output", "Output", "Output", GH_ParamAccess.item);
}
public double storedOutputVariable;
public double variableToPass;
///
/// This is the method that actually does the work.
///
/// The DA object is used to retrieve from inputs and store in outputs.
///
public void FirstRun(IGH_DataAccess DA)
{
DA.GetData("Input1",ref storedOutputVariable);
DA.GetData("Input2",ref variableToPass);
Communicator.data = variableToPass;
}
public void SecondRun(IGH_DataAccess DA)
{
DA.SetData("Output", storedOutputVariable);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
if(Communicator.runnum %2 != 0)
{
FirstRun(DA);
}
else
{
SecondRun(DA);
}
}
///
/// Provides an Icon for the component.
///
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;
}
}
///
/// Gets the unique ID for this component. Do not change this ID after release.
///
public override Guid ComponentGuid
{
get { return new Guid("52e1d421-33bd-4f72-8859-b7a0f7747f22"); }
}
}
}