Question
Stop a loop and go to next task
Hi everyone, Im working on a script where it unlocks and hide all layers on a loop. After the loop, it will show the ARTWORK and Dieline layer and perform the next task. However, Im stuck on the loop and wasnt able to execute the next task (starting line 16)
thank you in advance!
main();
function main() {
var myDoc=app.activeDocument;
var layerCount=myDoc.layers.length;
for (var ii = layerCount - 1; ii >= 0; ii--) {
var currentLayer = myDoc.layers[ii];
currentLayer.locked = false;
currentLayer.visible = false;
if ((currentLayer.locked == true) || (currentLayer.visible == true)){
currentLayer.locked = false;
currentLayer.visible = false;
}
}
};
// IM STUCK HERE!! it always go back to the loop
if (layerCount = 1) {
app.documents.everyItem().layers.itemByName("ARTWORK").visible = true;
app.documents.everyItem().layers.itemByName("Dieline").visible = true;
app.activeDocument.groups.everyItem().ungroup();
alert('Please Select Object "DIECUT"');
var doc = app.activeDocument;
var al = doc.layers.itemByName("Dieline");
var dl = doc.layers.itemByName("ARTWORK");
var col = doc.swatches.itemByName("PRINT FILE WHITE");
try {
var sel = app.selection[0];
sel.strokeColor = col;
sel.strokeWeight = "0.0125 pt";
sel.itemLayer = dl;
app.documents.everyItem().layers.itemByName("Dieline").visible = false;
} catch(e) { }
if (!col.isValid) {
col = doc.colors.add({
colorValue: [0,0,0,0],
space: ColorSpace.CMYK,
name: "PRINT FILE WHITE",
});
}
};