// draws random lines between points at a set distance along a path to make a spider web// I used the wonderfully documented wallblazer2.0 script from // the mighty graf salamander as a starting point.// I was trying to recreate the nodebox script "spider".// this version is much simpler in the way it passes all selected objects to the startWeb functionpointDist = 10; // distance between pointsuseCurve = false; //use a curve instead of a straight linerandomize = false; // randomize the distance between points on original pathkillbase = false; // if used on objects, keep the object/base (false --> kill the base)strokeRand = false; //used to check if the stroke should be randomizedminStroke = .5; // minstroke and maxstroke define the range for the randomized strokemaxStroke = 3;var clr = new CMYKColor(0,0,0,1); // set stroke color to black, if the selected objects already have a strok color, that will be used. values = Dialog.prompt("set Spider Web values", [	{ value: pointDist, description: "point distance", width: 50 },	{ value: useCurve, description: "use curves", width: 50 },	//{ value: randomize, description: "randomize distance", width: 50 },	{ value: killbase, description: "remove original path", width: 50 },	{ value: strokeRand, description: "use random stroke widths", width: 50 },	{ value: minStroke, description: "minimum stroke width", width: 50 },	{ value: maxStroke, description: "maximum stroke width", width: 50 }]);if (values != null ) {	pointDist = values[0];	useCurve = values[1];	killbase = values[2];	strokeRand = values[3];	minStroke = values[4];	maxStroke = values[5];	//randomize = values[6];	var sel = activeDocument.getMatchingItems(Path, { selected: true }); 	for (var i = 0; i < sel.length; i++) {			art = sel[i];			startWeb(art);	}}function startWeb(webObj){	base = webObj.clone(); // create a clone of the webObj in case you would keep the base object	if (webObj.style.stroke.color != null) clr = base.style.stroke.color; //if webObj has a stroke colour, use it. doesn't work with spot colors.	if (randomize == true){		var length = webObj.getLength();		//for (var i = 0; i < length){			// I want to add code here to add new anchor points at random intervals around the path.			// not sure how to do it. Anyone's suggestions would be welcome :)					//}	} else{		webObj.curvesToPoints(pointDist, 10000); // creates anchorpoints on the webObj, the distance between the points is set in the options dialog	}	var group = new Group();  // a new empty group		var count = webObj.curves.length-1; // get the count of anchorpoints	//print (count);	for (var j = 0; j < count; j++)	{		//print ("in j loop");		var path = new Path(); // create a new path element		path.moveTo(webObj.curves[j].getPoint1()); // set the start point of the path (the anchotpoint on the webObj)		//path.moveTo(webObj.getPoint(j));		path.style.stroke.color = clr;		if (strokeRand == true){			path.style.stroke.width = minStroke + Math.random() * (maxStroke - minStroke); // sets a random stroke		}		var rpoint = webObj.curves[Math.round(Math.random()*count)].getPoint1(); //choose a point randomly on the webObj path		if (useCurve == true){			var cpoint1 = webObj.curves[Math.round(Math.random()*count)].getPoint1();			var cpoint2 = webObj.curves[Math.round(Math.random()*count)].getPoint1();			path.curveTo(cpoint1, cpoint2, rpoint);		} else {			path.lineTo(rpoint);			//path.lineTo(webObj.curves[rpoint].getPoint1()); //draw a line from the current point to a random point		}		group.appendChild(path); // add the path to a group			}	//print ("out of j loop");	webObj.remove();	if (killbase == true){		base.remove();	} else {		var maingroup = new Group();		maingroup.appendChild(base);		maingroup.appendChild(group);	}		//print ("done with startWeb");	return webObj;	}	
