Skip to content

Commit 8874ffa

Browse files
committed
v.1.8 — Input placed → run script or action
``` inputPlaced_runScript: '$/Input placed script.jsx', inputPlaced_runAction: ['Default Actions', 'Gradient Map'], // ['folder name', 'action name'] ```
1 parent e0bbe60 commit 8874ffa

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

script/Batch Mockup Smart Object Replacement.jsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
// v.1.7.
2+
// v.1.8.
33
// Batch Mockup Smart Object Replacement.jsx
44

55
// You'll need to incplude this file to another script file:
@@ -36,6 +36,13 @@ mockups([
3636

3737
// CHANGELOG
3838

39+
// v.1.8.
40+
// - Added 2 new options that allow you to edit input files on the fly, which could potentially eliminate the need to batch process input files before running this mockup script.
41+
// - These options are specific to each smart object in the mockup.
42+
// - Usage example:
43+
// inputPlaced_runScript: '$/Input placed script.jsx',
44+
// inputPlaced_runAction: ['Default Actions', 'Gradient Map'], // ['folder name', 'action name']
45+
3946
// v.1.7.
4047
// - Added folder structure capabilities to output.filename, which allows you to create a folder
4148
// structure dynamically using the filename. For example filename: '@input/@mockup - @input'.
@@ -387,6 +394,8 @@ function replaceLoopOptionsFiller( rawData ) {
387394
itemObj.input = rawItem.input || '$/input';
388395
itemObj.inputFormats = rawItem.inputFormats;
389396
itemObj.resize = (rawItem.resize || rawItem.resize === false) ? rawItem.resize : 'fill';
397+
if ( rawItem.inputPlaced_runAction ) itemObj.inputPlaced_runAction = rawItem.inputPlaced_runAction;
398+
if ( rawItem.inputPlaced_runScript ) itemObj.inputPlaced_runScript = rawItem.inputPlaced_runScript;
390399
items.push( itemObj );
391400
}
392401

@@ -603,9 +612,6 @@ function replaceSoContents( item, sourcepath ) {
603612

604613
}
605614

606-
soDoc.close( SaveOptions.DONOTSAVECHANGES );
607-
if ( item.align ) returnLayer.remove();
608-
609615
}
610616

611617
if ( item.resize ) {
@@ -654,6 +660,20 @@ function replaceSoContents( item, sourcepath ) {
654660
// HIDE BACKGROUND
655661
if ( doc.layers.length > 1 ) doc.backgroundLayer.visible = false;
656662

663+
try {
664+
if ( item.inputPlaced_runAction ) {
665+
app.doAction(item.inputPlaced_runAction[1], item.inputPlaced_runAction[0]);
666+
}
667+
668+
if ( item.inputPlaced_runScript ) {
669+
const scriptPath = absolutelyRelativePath( item.inputPlaced_runScript ).decoded;
670+
$.evalFile( File(scriptPath) );
671+
}
672+
} catch(e) { alert(e) }
673+
674+
soDoc.close( SaveOptions.DONOTSAVECHANGES );
675+
if ( item.align ) returnLayer.remove();
676+
657677
} catch (e) {}
658678
}
659679

0 commit comments

Comments
 (0)