Highlighted

Scripted action not functioning in photoshop 21.2

Community Beginner ,
Sep 13, 2020

Copy link to clipboard

Copied

Hi,

How to create a script to delete a pattrern in Photoshop 21.2?

I have tried with this exported code by the xbytor script without success:

 

cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

//
//==================== Action 1 ==============
//
function Action1() {
  // Delete
  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.putEnumerated(cTID('Ptrn'), cTID('Ordn'), cTID('Trgt'));
    desc1.putReference(cTID('null'), ref1);
    executeAction(cTID('Dlt '), desc1, dialogMode);
  };

  step1();      // Delete
};

 

All I get is a response The command "Delete" is not currently available.

How to make this code to work?

Thanks

 

Adobe Community Professional
Correct answer by r-bin | Adobe Community Professional
Tell me, does your action (in the action palette from which you made the script) work at all?

Try to use code where the pattern is removed through its index
 
var d = new ActionDescriptor();
var r = new ActionReference();
r.putIndex(stringIDToTypeID("pattern"), 2); // pattern #2
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
or name
 
var d = new ActionDescriptor();
var r = new ActionReference();
r.putName(stringIDToTypeID("pattern"), "Tree Tile 3");
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
 

Topics

Actions and scripting

Views

86

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

Scripted action not functioning in photoshop 21.2

Community Beginner ,
Sep 13, 2020

Copy link to clipboard

Copied

Hi,

How to create a script to delete a pattrern in Photoshop 21.2?

I have tried with this exported code by the xbytor script without success:

 

cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

//
//==================== Action 1 ==============
//
function Action1() {
  // Delete
  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.putEnumerated(cTID('Ptrn'), cTID('Ordn'), cTID('Trgt'));
    desc1.putReference(cTID('null'), ref1);
    executeAction(cTID('Dlt '), desc1, dialogMode);
  };

  step1();      // Delete
};

 

All I get is a response The command "Delete" is not currently available.

How to make this code to work?

Thanks

 

Adobe Community Professional
Correct answer by r-bin | Adobe Community Professional
Tell me, does your action (in the action palette from which you made the script) work at all?

Try to use code where the pattern is removed through its index
 
var d = new ActionDescriptor();
var r = new ActionReference();
r.putIndex(stringIDToTypeID("pattern"), 2); // pattern #2
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
or name
 
var d = new ActionDescriptor();
var r = new ActionReference();
r.putName(stringIDToTypeID("pattern"), "Tree Tile 3");
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
 

Topics

Actions and scripting

Views

87

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
Sep 13, 2020 0
Adobe Community Professional ,
Sep 13, 2020

Copy link to clipboard

Copied

Tell me, does your action (in the action palette from which you made the script) work at all?

Try to use code where the pattern is removed through its index
 
var d = new ActionDescriptor();
var r = new ActionReference();
r.putIndex(stringIDToTypeID("pattern"), 2); // pattern #2
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
or name
 
var d = new ActionDescriptor();
var r = new ActionReference();
r.putName(stringIDToTypeID("pattern"), "Tree Tile 3");
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...
Sep 13, 2020 1
Community Beginner ,
Sep 15, 2020

Copy link to clipboard

Copied

The action outputs the same error as when it is exported as script.

Your solution works, but I was actually trying to delete a whole pattern group. My bad. I guess

r.putName(stringIDToTypeID("pattern"), "Tree Tile 3");

will do the job where I need to change the string id to something else than "pattern", but how will I do this if I do not have the reference? Some help would be appreciated.

 

Thanks

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...
Sep 15, 2020 0
Community Beginner ,
Sep 15, 2020

Copy link to clipboard

Copied

Thank you r-bin,

For this particular problem it is the correct answer as I have found that for deleting a pattern group you have to place the name of the group, the same as for a single pattern.

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...
Sep 15, 2020 0
r-bin LATEST
Adobe Community Professional ,
Sep 15, 2020

Copy link to clipboard

Copied

It is not clear why you need such a specific script to remove patterns.
In photoshop, folders
not so long ago appeared in the patterns panel, as the patterns panel itself.

Delete by name problem can happen when you have two names that match.

By the way. If you really care about this issue, then you can declare a bug on the feedback site that the action is being recorded, but when you try to play it, an error appears.
 

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...
Sep 15, 2020 0