Copy link to clipboard
Copied
Copy link to clipboard
Copied
//This is just a test script
#target photoshop
//bring application forward for double-click event
app.bringToFront();
var current_units = preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS
documents.add(1920,1080)
//create a new art layer at the beginning of the current document
var layerRef = app.activeDocument.artLayers.add()
layerRef.name = "Background2"
layerRef.blendMode = BlendMode.NORMAL
//Set opacity of new layer
layerRef.opacity=60;
//Select all so we can apply a fill to the selection
app.activeDocument.selection.selectAll
//create a color to used with the fill command
var colorRef = new SolidColor
colorRef.rgb.red = 0
colorRef.rgb.green = 0
colorRef.rgb.blue = 0
//Now apply fill to current selection
app.activeDocument.selection.fill(colorRef);
app.activeDocument.selection.deselect();
preferences.rulerUnits = current_units;
Copy link to clipboard
Copied
I wonder if there's an option that if there's no Document, it will just stop running the script.
Something like:
if (!documents.length) {
alerts ("There are no Documents");
Exit (); // A function that stops the script
}
Has anyone succeeded doing it?
Thanks.
Copy link to clipboard
Copied
function main() {
if (app.documents.length == 0) {
return;
}
var doc = app.activeDocument;
// insert code here
};
main()
Copy link to clipboard
Copied
.
Message was edited by: xbytor2 dupe.