Action Palette & 'ASet' & Color Table

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

robbio

Action Palette & 'ASet' & Color Table

Post by robbio »

Hi All,

I'm new about scripting in PS. I have two issues to submit to you:

1) Looking some code over internet I was able to read each action set from action palette and for each action set how many actions it has and their names.
However I wasn't able to get how many action set there are in the action palette. Probably because I'm familiar with ActionReference, Actiondescriptor and ActionList. Is there a way to get how many action set there are in the Action Palette?

2) I have an image I modified from rgb color to indexed color with four colors. After that I didn't find a way, via scripting, to get each of the four color and eventually changing each of them as you are are able to do if you go under Image | Mode | color Table window menu item. Is there a way to do this via scripting? Do I need to use Action* objects here too?

thanks
-Roberto

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

xbytor

Action Palette & 'ASet' & Color Table

Post by xbytor »

Something like this should work.

Code: Select all  var i = 0;
  while (true) {
    var ref = new ActionReference();
    ref.putIndex(cTID("ASet"), i);
    try {
      var desc = executeActionGet(ref);
      i++;
    } catch (e) {
      break;    // all done
    }
  }
  alert(i + ' ActionSets are in the ActionsPalette');
robbio

Action Palette & 'ASet' & Color Table

Post by robbio »

yes, that was the code I found in internet and it worked. But in that case
you catch the end of the list with an exception. Is there not a way to get
the number of action sets before to cycle over the list? instead to use a try catch pair.

thanks a lot anyway
- Roberto
xbytor

Action Palette & 'ASet' & Color Table

Post by xbytor »

[quote="robbio"Is there not a way to get
the number of action sets before to cycle over the list? instead to use a try catch pair.[/quote]

ActionReference don't have a 'length' property. That's just how they are defined. What's strange is that the binary stream representation of an ActionReference actually does have a length field at the beginning of the block.
robbio

Action Palette & 'ASet' & Color Table

Post by robbio »

it seems to me that Adobe has changed the DOM approach with Action* items, they are different from Document or Layers items etc. More,
the Action* items are so generics it seems strange that I don't have a way to get the count of ActionSet from Action Palette.

- Roberto
xbytor

Action Palette & 'ASet' & Color Table

Post by xbytor »

The Action* objects are a way of getting access to the automation framework that underlies Ps. It's kinda like a syscall in Unix-land. Or, even better, the CORBA dynamic invocation interface.

Ps functionality is vast. Putting all of it in DOM would be a daunting task. And likely would be plagued with errors. Instead, we have the Action* interfaces that give us access to just about all of Ps. It's a trade-off, but a reasonable one. They do add new stuff with each release, like HistoryStates and Guides (real-soon-now), but it's usually easy enough to use the Action* interfaces after you understand their purpose. Plus, there is stuff like xtools and other scripts/libs that provide a layer of abstraction above Action* if you need it.