Skip to main content
Known Participant
October 8, 2008
Question

How to delete all Action Sets in the Actions Palette

  • October 8, 2008
  • 6 replies
  • 1070 views
I'm in need of a piece of JavaScript code that will delete all the Action Sets in the Actions Palette. I've scripted the logic to load the appropriate Action Set once needed but I don't want to end up with duplicates at the end of processing the batch.

Any help would be most appreciated.

TIA, Scott
This topic has been closed for replies.

6 replies

Known Participant
October 10, 2008
Xbytor wrote:

From xtools/xlib/stdlib.js:

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

>
>

I've added the above to the code; thanks X

Now I'm stuck in the "confirmDelete" loop;

"Do you really want to empty your Actions Palette?"

Story of my life, LOL
Known Participant
October 9, 2008
Thanks Larry:

I tried both of your solutions (additional space after the m in "Nm " and I also changed the code to single quotes.

Unfortunately, neither solved the issue, I'm still getting the error code: "CTID is not a function.
Larry G. Schneider
Community Expert
Community Expert
October 9, 2008
If you copied this from the post, then you will have a problem. There need to be two spaces after the m in "Nm ". You are working with a naming convention where spaces count. Also, I not sure that there isn't a problem with the use of single and double quotes around Nm.
Known Participant
October 10, 2008
Larry G. Schneider wrote:
> There need to be two spaces after the m in "Nm ".

Yep.


> Also, I not sure that there isn't a problem with the use of single and double quotes around Nm.

Not at all. You can use pairs of ' or pairs of " as you like. I try to use ' for
characters and " for strings like in C, but I'm not as consistent with this in
as I get older.


Scott_Miles@adobeforums.com wrote:

> I added the additional code you posted above but now I'm getting an error
message:
> "cTID is not a function"
>

From xtools/xlib/stdlib.js:

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


-X
Known Participant
October 9, 2008
X:

Thanks for the quick response.

I added the additional code you posted above but now I'm getting an error message:
"cTID is not a function"

I am on the Mac platform, could that be the issue?
Known Participant
October 9, 2008
I've targeted Photoshop and run this code as shown. I've also copied it directly out of the xtools library but I'm not having any luck.

Run as shown, I get the error "stdlib is undefined".

I've also removed all references in the code to "stdlib" and the code runs thru the if statements and then returns an error "getActionSets" is not a function.

Could someone clue me in; I'm lost?
Known Participant
October 9, 2008
> Could someone clue me in; I'm lost?

getActionSets = function() {
var i = 1;
var sets = [];

while (true) {
var ref = new ActionReference();
ref.putIndex(cTID("ASet"), i);
var desc;
var lvl = $.level;
$.level = 0;
try {
desc = executeActionGet(ref);
} catch (e) {
break; // all done
} finally {
$.level = lvl;
}
if (desc.hasKey(cTID("Nm "))) {
var set = {};
set.index = i;
set.name = desc.getString(cTID("Nm "));
set.toString = function() { return this.name; };
set.count = desc.getInteger(cTID("NmbC"));
set.actions = [];
for (var j = 1; j <= set.count; j++) {
var ref = new ActionReference();
ref.putIndex(cTID('Actn'), j);
ref.putIndex(cTID('ASet'), set.index);
var adesc = executeActionGet(ref);
var actName = adesc.getString(cTID('Nm '));
set.actions.push(actName);
}
sets.push(set);
}
i++;
}

return sets;
};
Known Participant
October 8, 2008
It's been done and lives in xtools/xlib/stdlib.js.


Stdlib.deleteAllActionSets = function(confirmDelete) {
if (confirmDelete != false) {
if (!confirm("Do you really want to empty your Actions Palette?")) {
return;
}
}

var sets = Stdlib.getActionSets();

for (var i = sets.length-1; i >= 0; i--) {
Stdlib.deleteActionSet(sets.name);
}
};


Stdlib.deleteAllActionSets();