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

Programatically load/unload actions

Community Beginner ,
Jul 24, 2017 Jul 24, 2017

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!

TOPICS
Actions and scripting

Views

1.3K

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
community guidelines

correct answers 1 Correct answer

Guide , Jul 25, 2017 Jul 25, 2017

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 =

...

Votes

Translate

Translate
Adobe
Community Expert ,
Jul 24, 2017 Jul 24, 2017

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

JJMack

Votes

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
community guidelines
Community Beginner ,
Jul 24, 2017 Jul 24, 2017

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.

Votes

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
community guidelines
Guide ,
Jul 25, 2017 Jul 25, 2017

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 );

};

Votes

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
community guidelines
Community Beginner ,
Jul 25, 2017 Jul 25, 2017

Copy link to clipboard

Copied

LATEST

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 ); 

Votes

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
community guidelines