= new Point3d(0, 0, 0); b = new Point3d(0, 0, l); Line x = new Line(a, b); Curve m = x.ToNurbsCurve();
if (x == null) return;
Point3d[] points; m.DivideByCount(50, true, out points);
//for (double itr = 0; itr < 50; itr = itr + 0.01) //{ double frac = 50 / 230; int itr = 0; foreach (Point3d point in points) { while (true) { double imtr = (50 - itr) / frac; itr++; Color colour = ColorFromHSV(imtr, 1, 0.5); int rgb = colour.ToArgb(); if (_hash.Contains(rgb)) continue;
_hash.Add(rgb); _points.Add(point); _colours.Add(colour); break; } //} } for (int i = 0; i < _points.Count; i++) cd.AddPoint(_points[i], _colours[i]); }
// <Custom additional code> private readonly HashSet<int> _hash = new HashSet<int>(); private readonly List<Point3d> _points = new List<Point3d>(); private readonly List<Color> _colours = new List<Color>();
/// <summary> /// This method will be called once every solution, before any calls to RunScript. /// </summary> public override void BeforeRunScript() { _hash.Clear(); _points.Clear(); _colours.Clear(); } public static Color ColorFromHSV(double hue, double saturation, double value) { int hi = Convert.ToInt32(Math.Floor(hue / 60)) % 6; double f = hue / 60 - Math.Floor(hue / 60);
value = value * 255; int v = Convert.ToInt32(value); int p = Convert.ToInt32(value * (1 - saturation)); int q = Convert.ToInt32(value * (1 - f * saturation)); int t = Convert.ToInt32(value * (1 - (1 - f) * saturation));
if (hi == 0) return Color.FromArgb(255, v, t, p); else if (hi == 1) return Color.FromArgb(255, q, v, p); else if (hi == 2) return Color.FromArgb(255, p, v, t); else if (hi == 3) return Color.FromArgb(255, p, q, v); else if (hi == 4) return Color.FromArgb(255, t, p, v); else return Color.FromArgb(255, v, p, q); }
Gives this error
1. Value was either too large or too small for an Int32. (line: 0)
…