Highlighted

Script doesn't apply texture pattern after reopening Photoshop

Community Beginner ,
Oct 08, 2020

Copy link to clipboard

Copied

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.

Adobe Community Professional
Correct answer by r-bin | Adobe Community Professional
It is not clear what your script is doing.

To work correctly, you need to use the same names.

You use the name "bottom_layer_pattern" in one case, and "bottom layer pattern" in the other. Use one or the other. Better to set it as a separate variable.

Delete the line
desc13.putString (cTID ('Idnt'), "513c0c4d-d65d-044b-8fcc-07ea1a508a7c");

Leave only the name of the pattern.

To remove texture your code is not good, use code like this.
var d = new ActionDescriptor();
var r = new ActionReference();
r.putName(stringIDToTypeID("pattern"), "bottom_layer_pattern");
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
TOPICS
Actions and scripting, How to, Problem or error

Views

101

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Script doesn't apply texture pattern after reopening Photoshop

Community Beginner ,
Oct 08, 2020

Copy link to clipboard

Copied

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.

Adobe Community Professional
Correct answer by r-bin | Adobe Community Professional
It is not clear what your script is doing.

To work correctly, you need to use the same names.

You use the name "bottom_layer_pattern" in one case, and "bottom layer pattern" in the other. Use one or the other. Better to set it as a separate variable.

Delete the line
desc13.putString (cTID ('Idnt'), "513c0c4d-d65d-044b-8fcc-07ea1a508a7c");

Leave only the name of the pattern.

To remove texture your code is not good, use code like this.
var d = new ActionDescriptor();
var r = new ActionReference();
r.putName(stringIDToTypeID("pattern"), "bottom_layer_pattern");
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
TOPICS
Actions and scripting, How to, Problem or error

Views

102

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 08, 2020 0
Most Valuable Participant ,
Oct 09, 2020

Copy link to clipboard

Copied

That look like  a converted action.  Actions steps have hard coded settings.  You would need to add  code to the converted action to generated  a uuid each time the script is used. I also do not see the constant  uuid used in step 5 it the step 6 deleted step.  

 

Step 5 function hast two parameters (enabled, withDialog) and has no code to generate anything random "513c0c4d-d65d-044b-8fcc-07ea1a508a7c" is a  constant 

   desc13.putString(cTID('Idnt'), "513c0c4d-d65d-044b-8fcc-07ea1a508a7c"); // the random ID key

 

 

 

 

JJMack

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 09, 2020 2
Adobe Community Professional ,
Oct 09, 2020

Copy link to clipboard

Copied

It is not clear what your script is doing.

To work correctly, you need to use the same names.

You use the name "bottom_layer_pattern" in one case, and "bottom layer pattern" in the other. Use one or the other. Better to set it as a separate variable.

Delete the line
desc13.putString (cTID ('Idnt'), "513c0c4d-d65d-044b-8fcc-07ea1a508a7c");

Leave only the name of the pattern.

To remove texture your code is not good, use code like this.
var d = new ActionDescriptor();
var r = new ActionReference();
r.putName(stringIDToTypeID("pattern"), "bottom_layer_pattern");
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 09, 2020 3
Community Beginner ,
Oct 09, 2020

Copy link to clipboard

Copied

Actually I have made a mistake by not including the underscores in the deletion process. Thank you for your reminder.

Also, I have deleted the line you mentioned, didn't work until I relaized that bottom_layer_pattern was before without underscores either. I am not sure why the actiontojavascript didn't export the code with underscores, maybe I was doing something wrong.

 

Thank you r-bin, this did solve my problem.

 

Also, thank you JJMack, this sounds interesting, maybe providing a sample code for generating UUID each time the script is executed would help me understand things further.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 09, 2020 0