using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using Rhino; using Grasshopper.Kernel; using Grasshopper.Kernel.Types; using Rhino.Geometry; namespace TEST { public class TrialComponent : GH_Component { //Constructor initializes component details public TrialComponent() : base("TEST", "TEST", "TEST", "TEST", "TEST") { } //Register input parameters of component protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.Register_IntegerParam("Number", "No", "Number of additional inputs required"); } //Register output parameters of component protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) { pManager.Register_GenericParam("Output", "O", "Output"); } //Solver protected override void SolveInstance(IGH_DataAccess DA) { //Declare input variables int number = 0; //Get input data if (!DA.GetData(0, ref number)) return; //Assuming that input contains the number of additional input parameters required while (Params.Input.Count <= number) { for (int i = Params.Input.Count; i <= number; i++) { Grasshopper.Kernel.Parameters.Param_GenericObject paramIn = new Grasshopper.Kernel.Parameters.Param_GenericObject(); paramIn.Optional = true; paramIn.MutableNickName = true; paramIn.Access = GH_ParamAccess.tree; paramIn.Name = "Input " + (i).ToString(); paramIn.NickName = "I" + (i).ToString(); paramIn.Description = "Input #" + (i).ToString(); Params.RegisterInputParam(paramIn); Params.OnParametersChanged(); } } //Declare output variable List output = new List(); for (int i = 1; i < Params.Input.Count; i++) { //Declare input variables Grasshopper.Kernel.Data.GH_Structure data = null; //Get input data DA.GetDataTree(i, out data); //ERROR HERE!!! if (data == null) continue; output.AddRange(data); } //Set output data DA.SetDataList(0, output); } //Guid of component public override Guid ComponentGuid { get { return new Guid("C98E5EA4-5715-47DD-A7CD-48192EA7F57B"); } } //Icon of component protected override Bitmap Icon { get { return new Bitmap(Tool.Properties.Resources.AdaptabilityRater); } } //Exposure of component public override GH_Exposure Exposure { get { return GH_Exposure.primary; } } } }