/*This script works with a Rhino script to combine exported curves into one document. Cobbled together by Chris Reilly [creilly 4T saic D0T edu] in 2007. This script is distributed under a Creative CommonsAttribution-Noncommercial-Share Alike 3.0 Licensesee http://creativecommons.org/licenses/by-nc-sa/3.0/ for details*/// JavaScript Document//read number of curves from 'Curve_Count.txt' which was output by Rhino. alert ("Select the file 'Curve_Count.txt'");var textFilePath = File.openDialog("Select the file 'Curve_Count'");var fileRef = new File(textFilePath);fileRef.open("r");var curveCount = fileRef.readln(0);//locate and open the laser cutter template filealert ("Select the laser cutter template file");var templateFilePath = File.openDialog("Select the laser cutter template file");var laserFile = new File(templateFilePath);open (laserFile);//cycle through the source curve filesfor (var count = 0; count < curveCount; count++) {		var curvePath = new File (fileRef.parent + "/" + count + ".ai"); //the slash may have to be changed for Windows	open (curvePath);//open the curve source file count.ai	var curvePathConverted = curvePath.name.substr(0,(curvePath.name.length - 3)) + " [Converted].ai";	doc = app.documents.getByName(curvePathConverted); //bring <count>.ai to front. refer to as documents[1] since illustrator does a stupid renaming thing when opening the Rhino curves	// = app.activeDocument; 		//select all paths in curve source files and move to laser cutter template	if ( doc.pathItems.length > 0 ) { 				//cycles through each pathitem in curve source file		for ( i = doc.pathItems.length - 1; i >= 0; i-- ) { 			pathArt = doc.pathItems[i];  			pathArt.selected = true; 						var my_object = doc.pathItems[i];			app.activeDocument = documents[laserFile.name];			var destination_layer = app.activeDocument.layers["Layer " + parseFloat(count + 1)]; 			my_object.move(destination_layer,ElementPlacement.PLACEATEND);		} 	} 		//close the last curve source document w/o saving	app.activeDocument = app.documents.getByName(curvePathConverted);	aiDocument = app.activeDocument; 	aiDocument.close( SaveOptions.DONOTSAVECHANGES ); 	aiDocument = null; 		//create the next layer in the laser cutter template	app.activeDocument = documents[laserFile.name];	app.activeDocument.layers.add();	} 
