Hello
It’s a question that I followed up on my post last time. I wanted to bake curves from grasshopper to Rhino. This time I want to add and select the color of that curve on grasshopper. I wrote the following code but could not implement it.
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddBooleanParameter(“Boolean”, “B”, “True or False”, GH_ParamAccess.item);
pManager.AddCurveParameter(“Curve”, “C”, “Bake curves”, GH_ParamAccess.list);
pManager.AddColourParameter(“Colour”, “C”, “Objects colour”, GH_ParamAccess.list);
}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
}
protected override void SolveInstance(IGH_DataAccess DA)
{
List<Curve> crv = new List<Curve>();
if (!DA.GetDataList(1, crv)) return;
List<Color> colors = new List<Color>();
if (!DA.GetDataList(2, colors)) return;
var objAttr = new ObjectAttributes();
objAttr.ColorSource = ObjectColorSource.ColorFromObject;
objAttr.ObjectColor = Color.Red;
var t = true;
if (!DA.GetData(0, ref t)) return;
Rhino.DocObjects.Tables.ObjectTable ot = Rhino.RhinoDoc.ActiveDoc.Objects;
if (t)
{
foreach(Curve c in crv)
{
ot.Add(c, objAttr);
}
}
}
What code do I need to rewrite to allow the colors to be selected on grasshopper?