Copy link to clipboard
Copied
I've been struggling with this for the last day or so.
I want to be able to dynamically add an action set (seems I can do this with app.Load("...atn");
But then I cannot see a way to unload it (which I need to do).
I had a go at copying the .atn file into the presets folder (app data & program default) - but neither seem to enable me to use the Actions behind the scenes without explicitly calling the load.
I'm using C# but any alternatives considered at this stage.
Thanks!
This may help...
...#target photoshop;
var actionList =getActionSets();
for(var d in actionList){
var str = decodeURI(actionList
); //modify to match layerset name to find
if(str.match( /^Set to find/i)) unLoadAction(actionList
); }
////////////// Functions
function getActionSets(){
var aSets=[];
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('ASet'), 1);
var desc = executeActionGet(ref);
var Count = desc.getInteger(stringIDToTypeID("count")) + 1;
for(var t=1; t<=Count; t++){
var ref =
Copy link to clipboard
Copied
Look at Xtool it may have something. I know its has a library function to clear out the Action Pallet I have used to empty it the load a collection of action sets. I'm quiye sure it has a deleteAction function.... As well as delete all action sets which I use.
// Clear out the Action Palette and load a new set of Action Sets
Stdlib.deleteAllActionSets(false); // Thanks to Xtools
for (var i=0;i<actionSetsNames.length;i++){ loadActionSet(new File(actionSetsPath + actionSetsNames + ".atn"));} // Load Action Sets
Copy link to clipboard
Copied
Thanks - I really appreciate this.
It's a a shame there's nothing obviously out-of-the-box when working with the Photoshop application object via the .Net environment.
I'll take a good look though: the reference doc (http://ps-scripts.cvs.sourceforge.net/viewvc/ps-scripts/xtools/docs/Stdlib.pdf ) indicates DeleteActionSet/Step methods so will be good to see how they work.
Copy link to clipboard
Copied
This may help...
#target photoshop;
var actionList =getActionSets();
for(var d in actionList){
var str = decodeURI(actionList
); //modify to match layerset name to find
if(str.match( /^Set to find/i)) unLoadAction(actionList
); }
////////////// Functions
function getActionSets(){
var aSets=[];
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('ASet'), 1);
var desc = executeActionGet(ref);
var Count = desc.getInteger(stringIDToTypeID("count")) + 1;
for(var t=1; t<=Count; t++){
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('ASet'), t);
var desc = executeActionGet(ref);
var actName = desc.getString(charIDToTypeID('Nm '));
aSets.push(actName);
}
return aSets;
};
function unLoadAction(aSet){
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putName( charIDToTypeID( "ASet" ), decodeURI(aSet));
desc.putReference( charIDToTypeID( "null" ), ref );
executeAction( charIDToTypeID( "Dlt " ), desc, DialogModes.NO );
};
Copy link to clipboard
Copied
Great responses - really impressed with the speed of knowledge sharing on my first question!
Linked to the above i found this previously (Help with an action refreshing script )...
Specifically the code: which aligns to what you posted.
function delAction(aName) {
var idDlt = charIDToTypeID( "Dlt " );
var desc1 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idASet = charIDToTypeID( "ASet" );
ref1.putName( idASet, aName );
desc1.putReference( idnull, ref1 );
executeAction( idDlt, desc1, DialogModes.NO );
}