public GradientParser(GH_GradientControl gradientControl = null) { if (gradientControl != null) { Gradient = gradientControl.Gradient; } else { Gradient = GH_Gradient.Heat(); } List <double> gripsParameters; List <Color> gripsColourLeft; List <Color> gripsColourRight; try { //this.Params.Input[0].Sources[0].Sources[0]; var param = (GH_PersistentParam <GH_Number>)gradientControl.Params.Input[2]; if (param.VolatileData.IsEmpty) { param.PersistentData.Append(new GH_Number(1.0)); param.ExpireSolution(true); return; } bool isLinear = Gradient.Linear; bool isLocked = Gradient.Locked; int gripCount = Gradient.GripCount; var parameters = new List <double>(); var colourLeft = new List <Color>(); var colourRight = new List <Color>(); for (var i = 0; i < Gradient.GripCount; i++) { parameters.Add(Gradient[i].Parameter); colourLeft.Add(Gradient[i].ColourLeft); colourRight.Add(Gradient[i].ColourRight); } gripsParameters = parameters; gripsColourLeft = colourLeft; gripsColourRight = colourRight; } catch { } }
public GradientParser(GH_GradientControl gradientControl = null) { if (gradientControl != null) { Gradient = gradientControl.Gradient; } else { Gradient = GH_Gradient.Heat(); } List <double> gripsParameters; List <Color> gripsColourLeft; List <Color> gripsColourRight; try { //this.Params.Input[0].Sources[0].Sources[0]; var param = (GH_PersistentParam <GH_Number>)gradientControl.Params.Input[2]; if (param.VolatileData.IsEmpty) { param.PersistentData.Append(new GH_Number(1.0)); param.ExpireSolution(true); return; } GH_Structure <GH_Number> gradientFirstInput = (GH_Structure <GH_Number>)gradientControl.Params.Input[0].VolatileData; Min = gradientFirstInput[0][0].Value; GH_Structure <GH_Number> gradientSecondInput = (GH_Structure <GH_Number>)gradientControl.Params.Input[1].VolatileData; Max = gradientSecondInput[0][0].Value; //GH_PersistentParam<GH_Number> minCast = (GH_PersistentParam<GH_Number>)gradientControl.Params.Input[0].VolatileData.AllData(false).First(); //foreach (var item in minCast.VolatileData.AllData(false)) //{ // bool casted = item.CastTo(out GH_Number number); // if (casted) Min = number.Value; //} //GH_PersistentParam<GH_Number> maxCast = (GH_PersistentParam<GH_Number>)gradientControl.Params.Input[1].VolatileData.AllData(false).First(); //foreach (var item in maxCast.VolatileData.AllData(false)) //{ // bool casted = item.CastTo(out GH_Number number); // if (casted) Max = number.Value; //} bool isLinear = Gradient.Linear; bool isLocked = Gradient.Locked; int gripCount = Gradient.GripCount; var parameters = new List <double>(); var colourLeft = new List <Color>(); var colourRight = new List <Color>(); for (var i = 0; i < Gradient.GripCount; i++) { parameters.Add(Gradient[i].Parameter); colourLeft.Add(Gradient[i].ColourLeft); colourRight.Add(Gradient[i].ColourRight); } gripsParameters = parameters; gripsColourLeft = colourLeft; gripsColourRight = colourRight; } catch { } }