protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddNumberParameter("MyNumber", "N", "A single number input", GH_ParamAccess.item); } protected override void SolveInstance(IGH_DataAccess DA) { double myNumber; if (!DA.GetData(0, ref myNumber)) return; DA.SetData(0, myNumber * 2); }
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddNumberParameter("MyNumbers", "N", "Multiple numbers input", GH_ParamAccess.tree); } protected override void SolveInstance(IGH_DataAccess DA) { GH_StructureIn this example, the component defines an input parameter "MyNumbers" that accepts multiple values stored in a data tree. The "GetDataTree" method retrieves the entire data tree and stores it in a variable called "myNumbers". The "SolveInstance" method then iterates through each branch of the data tree and multiplies each value by 2. The output data tree is then constructed using the "SetDataTree" method. Package Library: RhinoCommon.myNumbers = new GH_Structure (); if (!DA.GetDataTree(0, out myNumbers)) return; GH_Structure doubledNumbers = new GH_Structure (); foreach (var branch in myNumbers.Branches) { var doubledBranch = new List (); foreach (var number in branch) { doubledBranch.Add(new GH_Number(number.Value * 2)); } doubledNumbers.AppendRange(doubledBranch, myNumbers.Paths[myNumbers.Paths.IndexOf(branch)]); } DA.SetDataTree(0, doubledNumbers); }