/// <summary> /// Randomly move a point or list of points along a curve within a given percentage range. /// </summary> /// <param name="point"></param> /// <param name="polycurve"></param> /// <param name="percentage"></param> /// <search></search> public static dynamic RandomlyMoveAlongCurve(this DSGeom.Point point, DSGeom.PolyCurve polycurve, double percentage) { if (percentage > 100 || percentage < 0) { return("Select a percentage number between 0-100."); } else { double param = polycurve.ParameterAtPoint(point); double start = param - (percentage / 100); double end = param + (percentage / 100); if (start < 0) { start = 0; } if (end > 1) { end = 1; } double i; List <double> range = new List <double>(); for (i = start; i <= end; i += 0.01) { range.Add(i); } var random = new Random(); int index = random.Next(range.Count); double item = range[index]; Autodesk.DesignScript.Geometry.Point newPoint = polycurve.PointAtParameter(item); return(newPoint); } }