Copy link to clipboard
Copied
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
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()))
Copy link to clipboard
Copied
Thanks a bunch SuperMerlin, you made many things clear to me!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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){}
};
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Sorry can't help with that.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Good luck.
Edit: This site would be a good start:- http://www.davidebarranca.com/
Copy link to clipboard
Copied
Thank you SuperMerlin, I will ask in the other forum.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now