Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

How to delete all Action Sets in the Actions Palette

New Here ,
Oct 08, 2008 Oct 08, 2008
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
TOPICS
Actions and scripting
966
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Explorer ,
Oct 08, 2008 Oct 08, 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();
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 09, 2008 Oct 09, 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?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 09, 2008 Oct 09, 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;
};
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 09, 2008 Oct 09, 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?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 09, 2008 Oct 09, 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 09, 2008 Oct 09, 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 09, 2008 Oct 09, 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 09, 2008 Oct 09, 2008
LATEST
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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines