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

random action selection script

Explorer ,
Feb 26, 2016 Feb 26, 2016

Hello,

I have made 10 actions with brush definitions. I need a script for random action execution(instead of executing them on the actions panel) if it is possible. Can someone show me how to do it or post a final example here?

I have very low knowledge for scripting, please be gentle with me.

Thank you for your kindness,

Nick

TOPICS
Actions and scripting
5.5K
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

correct answers 1 Correct answer

Guide , Feb 27, 2016 Feb 27, 2016

This version requires you change the variable to suit your LayerSet name.

#target photoshop;

if(documents.length){

    main();

    }else{

        alert("You need a document open to run this script!");

        }

function main(){

//////////////////////////////////////////////////////////////////////

// Change "Default Actions" to the name of your LayerSet

var ASname = "Default Actions";

/////////////////////////////////////////////////////////////////////

if(!checkActionExists(ASname.toString()))

...
Translate
Adobe
Explorer ,
Mar 05, 2016 Mar 05, 2016

Thanks a bunch SuperMerlin, you made many things clear to me!

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 ,
Mar 16, 2016 Mar 16, 2016

SuperMerlin‌, is it possible to change brushes with slider? If it is, can you show me an example how to do it?

Thanks a bunch.

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
Guide ,
Mar 16, 2016 Mar 16, 2016

Not sure what you want, is this something like?

#target photoshop;

app.bringToFront();

main();

function main(){

var win = new Window("dialog", "Brushs");

var Brushs = getPresetList (0);

win.brushno = win.add('statictext',undefined,'Total number of brushes = ' + Brushs.length);

win.brush = win.add('statictext',undefined,'');

win.brush.preferredSize=[400,20];

win.slider = win.add('scrollbar', undefined, 0, 0, Brushs.length-1);

win.slider.value =0;

win.brush.text = Brushs[win.slider.value] + " - Brush Number " + (Number(win.slider.value) +1);

win.slider.preferredSize = [400,20];

win.slider.onChanging = function(){

win.brush.text = Brushs[win.slider.value] + " - Brush Number " + (Number(win.slider.value) +1); 

}

win.can = win.add('button',undefined,'Cancel');

win.can.preferredSize=[400,30];

win.sel = win.add('button',undefined,'Select Brush');

win.sel.preferredSize=[400,30];

win.sel.onClick = function(){

win.close(0);

selectBrushAtIndex(win.slider.value + 1);

}

win.show();

};

function getPresetList (Idx){

var presetNames = [ ];

var ref = new ActionReference ();

ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("presetManager"));

ref.putEnumerated (stringIDToTypeID ("application"), stringIDToTypeID ("ordinal"), stringIDToTypeID ("targetEnum"));

var desc = executeActionGet (ref);

var list = desc.getList (stringIDToTypeID ("presetManager"));

var nameList = list.getObjectValue (Idx).getList (stringIDToTypeID ("name"));

for (var nameIndex = 0; nameIndex < nameList.count; nameIndex++){

presetNames.push (nameList.getString (nameIndex));

}

return presetNames;

};

function selectBrushAtIndex(index){

var desc1 = new ActionDescriptor();

var ref1 = new ActionReference();

ref1.putIndex( charIDToTypeID( "Brsh" ), index );

desc1.putReference(charIDToTypeID( "null" ), ref1 );

try{

executeAction( charIDToTypeID( "slct" ), desc1, DialogModes.NO );

}catch(e){}

};

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 ,
Mar 16, 2016 Mar 16, 2016

It looks a bit complicated, and as I see this represents a slider in dialog box with 'cancel' and 'select brush' buttons for confirmation too.

I need a slider on the panel that makes immediate brush choice as I move it right or left without 'OK' and 'Cancel' buttons.

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
Guide ,
Mar 16, 2016 Mar 16, 2016

Sorry can't help with that.

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 ,
Mar 17, 2016 Mar 17, 2016

SuperMerlin‌ thank you, you are very helpful.

Can you point me tutorials and references for photoshop scripting because, as I notice, there is very low help according to photoshop scripting. As I understood ScriptUI has to do with sliders controlling objects but it is for CS and CC family, and not for CC 2014-15. What I am confused also, is it possible to directly change value with slider without using dialog boxes with confirmation at all? Please, if you have time point me some answers so I continue on my reseach.

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
Guide ,
Mar 17, 2016 Mar 17, 2016

CS4/5 and CS6 had Configurator that you could create simple panels, but anything complicated you would have needed Flash Builder or some other program.

Configurator was also version dependant.

With CC Flash panels no longer exist as Flash is no longer supported, so panels have now to be written in HTML5.

I don't have CC so never done and HTML5 programming but there are a number of people here that have.

This forum may have more info.

Extension Builder 3

Good luck.

Edit: This site would be a good start:- http://www.davidebarranca.com/

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 ,
Mar 17, 2016 Mar 17, 2016

Thank you SuperMerlin, I will ask in the other forum.

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