Script doesn't apply texture pattern after reopening Photoshop
Hi,
I am trying to create a texture pattern from the bottom layer and the same being applied in the Bevel & Emboss -> Texture effects, and afterwards being deleted. When closing Photoshop and reopening it, the script will not apply the pattern texture anymore because of the random created identity key that now became constant after creating the script:
desc13.putString(cTID('Idnt'), "513c0c4d-d65d-044b-8fcc-07ea1a508a7c");
This is the whole script:
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
//
//==================== Action 1 ==============
//
function Action1() {
// Select
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(cTID('Lyr '), "Bottom Layer");
desc1.putReference(cTID('null'), ref1);
desc1.putBoolean(cTID('MkVs'), false);
var list1 = new ActionList();
list1.putInteger(2);
desc1.putList(cTID('LyrI'), list1);
executeAction(cTID('slct'), desc1, dialogMode);
};
// Show
function step2(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var list1 = new ActionList();
var ref1 = new ActionReference();
ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
list1.putReference(ref1);
desc1.putList(cTID('null'), list1);
desc1.putBoolean(cTID('TglO'), true);
executeAction(cTID('Shw '), desc1, dialogMode);
};
// Make
function step3(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(cTID('Ptrn'));
desc1.putReference(cTID('null'), ref1);
var ref2 = new ActionReference();
ref2.putProperty(cTID('Prpr'), sTID("selection"));
ref2.putEnumerated(cTID('Dcmn'), cTID('Ordn'), cTID('Trgt'));
desc1.putReference(cTID('Usng'), ref2);
desc1.putString(cTID('Nm '), "bottom_layer_pattern");
executeAction(cTID('Mk '), desc1, dialogMode);
};
// Show
function step4(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var list1 = new ActionList();
var ref1 = new ActionReference();
ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
list1.putReference(ref1);
desc1.putList(cTID('null'), list1);
desc1.putBoolean(cTID('TglO'), true);
executeAction(cTID('Shw '), desc1, dialogMode);
};
// Set
function step5(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Prpr'), cTID('Lefx'));
ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putUnitDouble(cTID('Scl '), cTID('#Prc'), 100);
var desc3 = new ActionDescriptor();
desc3.putBoolean(cTID('enab'), true);
desc3.putBoolean(sTID("present"), true);
desc3.putBoolean(sTID("showInDialog"), true);
desc3.putEnumerated(cTID('hglM'), cTID('BlnM'), cTID('Lmns'));
var desc4 = new ActionDescriptor();
desc4.putDouble(cTID('Rd '), 247.000000476837);
desc4.putDouble(cTID('Grn '), 247.000000476837);
desc4.putDouble(cTID('Bl '), 247.000000476837);
desc3.putObject(cTID('hglC'), sTID("RGBColor"), desc4);
desc3.putUnitDouble(cTID('hglO'), cTID('#Prc'), 40);
desc3.putEnumerated(cTID('sdwM'), cTID('BlnM'), cTID('Drkn'));
var desc5 = new ActionDescriptor();
desc5.putDouble(cTID('Rd '), 0);
desc5.putDouble(cTID('Grn '), 0);
desc5.putDouble(cTID('Bl '), 0);
desc3.putObject(cTID('sdwC'), sTID("RGBColor"), desc5);
desc3.putUnitDouble(cTID('sdwO'), cTID('#Prc'), 26);
desc3.putEnumerated(cTID('bvlT'), cTID('bvlT'), cTID('Slmt'));
desc3.putEnumerated(cTID('bvlS'), cTID('BESl'), cTID('InrB'));
desc3.putBoolean(cTID('uglg'), false);
desc3.putUnitDouble(cTID('lagl'), cTID('#Ang'), 127);
desc3.putUnitDouble(cTID('Lald'), cTID('#Ang'), 30);
desc3.putUnitDouble(cTID('srgR'), cTID('#Prc'), 10);
desc3.putUnitDouble(cTID('blur'), cTID('#Pxl'), 1);
desc3.putEnumerated(cTID('bvlD'), cTID('BESs'), cTID('Out '));
var desc6 = new ActionDescriptor();
var list1 = new ActionList();
var desc7 = new ActionDescriptor();
desc7.putDouble(cTID('Hrzn'), 0);
desc7.putDouble(cTID('Vrtc'), 0);
list1.putObject(cTID('CrPt'), desc7);
var desc8 = new ActionDescriptor();
desc8.putDouble(cTID('Hrzn'), 59);
desc8.putDouble(cTID('Vrtc'), 22);
list1.putObject(cTID('CrPt'), desc8);
var desc9 = new ActionDescriptor();
desc9.putDouble(cTID('Hrzn'), 109);
desc9.putDouble(cTID('Vrtc'), 47);
list1.putObject(cTID('CrPt'), desc9);
var desc10 = new ActionDescriptor();
desc10.putDouble(cTID('Hrzn'), 152);
desc10.putDouble(cTID('Vrtc'), 128);
list1.putObject(cTID('CrPt'), desc10);
var desc11 = new ActionDescriptor();
desc11.putDouble(cTID('Hrzn'), 193);
desc11.putDouble(cTID('Vrtc'), 218);
list1.putObject(cTID('CrPt'), desc11);
var desc12 = new ActionDescriptor();
desc12.putDouble(cTID('Hrzn'), 255);
desc12.putDouble(cTID('Vrtc'), 255);
list1.putObject(cTID('CrPt'), desc12);
desc6.putList(cTID('Crv '), list1);
desc3.putObject(cTID('TrnS'), cTID('ShpC'), desc6);
desc3.putBoolean(sTID("antialiasGloss"), true);
desc3.putUnitDouble(cTID('Sftn'), cTID('#Pxl'), 3);
desc3.putBoolean(sTID("useShape"), false);
desc3.putBoolean(sTID("useTexture"), true);
desc3.putBoolean(cTID('InvT'), false);
desc3.putBoolean(cTID('Algn'), true);
desc3.putUnitDouble(cTID('Scl '), cTID('#Prc'), 100);
desc3.putUnitDouble(sTID("textureDepth"), cTID('#Prc'), 256);
var desc13 = new ActionDescriptor();
desc13.putString(cTID('Nm '), "bottom layer pattern");
desc13.putString(cTID('Idnt'), "513c0c4d-d65d-044b-8fcc-07ea1a508a7c"); // the random ID key
desc3.putObject(cTID('Ptrn'), cTID('Ptrn'), desc13);
var desc14 = new ActionDescriptor();
desc14.putDouble(cTID('Hrzn'), 0);
desc14.putDouble(cTID('Vrtc'), 0);
desc3.putObject(sTID("phase"), cTID('Pnt '), desc14);
desc2.putObject(cTID('ebbl'), cTID('ebbl'), desc3);
desc1.putObject(cTID('T '), cTID('Lefx'), desc2);
executeAction(cTID('setd'), desc1, dialogMode);
};
// Delete
function step6(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var list1 = new ActionList();
var ref1 = new ActionReference();
ref1.putName(cTID('Ptrn'), "bottom layer pattern");
list1.putReference(ref1);
desc1.putList(cTID('null'), list1);
executeAction(cTID('Dlt '), desc1, dialogMode);
};
step1(); // Select
step2(); // Show
step3(); // Make
step4(); // Show
step5(); // Set
step6(); // Delete
};
I need help on solving this problem please.
Thanks.
