Install Brushes via script
I'm creating some Photoshop actions that are going to work via HTML Panel, some of them uses tool presets and others use tool presets and brushes and right now I don't know how check if X brush exist and if not install the .abr file from some route, don't know if it's possible do it or in some way change the script that I have for the .tpl files to do the same.
Right now I use this to detect if there's a X preset tool and if not install it:
var presetSet = 'fileName';
var presetName = 'tool name';
function setTools(){
try {
selectToolPreset(presetName);
} catch(e) {
if (loadToolPresetSet(presetSet)) {
try {
selectToolPreset(presetName);
} catch(e) {
alert("Was unable to Select the Tools Preset "+presetName);
}
} else {
alert("Was unable to load Tools Presets Set "+presetSet);
}
};
};
function selectToolPreset(PresetName) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putName( stringIDToTypeID( "toolPreset" ), PresetName );
desc.putReference( charIDToTypeID( "null" ), ref );
executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
}
function loadToolPresetSet(SetName) {
returncode = true;
var thisFile = new File($.fileName);
var path = thisFile.path+'/';
var SetFile = new File(path + SetName + ".tpl");
if (!SetFile.exists) {
returncode = false;
} else {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID( "toolPreset" ));
ref.putEnumerated( charIDToTypeID( "capp" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
desc.putPath( charIDToTypeID( "T " ), new File( SetFile ) );
desc.putBoolean( charIDToTypeID( "Appe" ), true );
try {
executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
} catch(e) {
returncode = false;
}
}
return returncode ;
}