Script To Generate Parallel Lines in Photoshop
How can I generate parallel lines so that each line is spaced uniformly as it fills up the entire document? In the simple script below, I used the underscore to create the line. My problem seems to be that the succeeding lines (layers) are always aligned to the first layer in the iteration. How can that be fixed? Thanks in advanced.
// This script will create parallel lines which can be used for designing pages with lines
var defaultRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
bgLine = new SolidColor();
bgLine.rgb.red = 255;
bgLine.rgb.green = 255;
bgLine.rgb.blue = 255;
backgroundColor = bgLine;
var newDocumentRef = documents.add(600,1000, 72.0, "Parallel Lines Generator");
newDocumentRef = null;
var textArray = [
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________",
"_____________________________________________________________________________________"
] ;
//if additional lines are needed, it can be just added to the array
var AD = activeDocument ;
for(a=1;a<=textArray.length;a++){
var TextLayer = AD.artLayers.add();
TextLayer.kind = LayerKind.TEXT;
TextLayer.opacity = 100;
var txtRef = TextLayer.textItem;
txtRef.font = "Arial";
txtRef.contents = textArray[a-1];
txtRef.size = 12;
var textPosition = [30, 20]; // 30 is the margin and 20 is distance from top. The next text line should be 20 + 20 (can be any uniform increment desired)
txtRef.position = textPosition; // I cannot seem to get the next layer move down by a uniform increment, let us say 20 pixels
}
/*
// Merge all the Text Layers and leave the entire file unflattened
var background = AD.layers[AD.layers.length -1];
if (background.isBackgroundLayer) {
background.visible = false;
AD.mergeVisibleLayers();
background.visible = true;
}
// At this point, I like to rename the merged text layer with a layer name "Parallel Lines" before saving it as psd file.
*/
preferences.rulerUnits = defaultRulerUnits;
