Copy link to clipboard
Copied
Is there a script or action to make abr brush presets from single or layered png files?
Try this script:
...#target photoshop
var bName = prompt ('Enter a name for the brush', 'brush 1', 'Create Brush')
if(bName != null){
var idMk = charIDToTypeID( "Mk " );
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idBrsh = charIDToTypeID( "Brsh" );
ref1.putClass( idBrsh );
desc5.putReference( idnull, ref1 );
var idUsng = charIDToTypeID( "Usng" );
var ref2 = n
Copy link to clipboard
Copied
Try this script:
#target photoshop
var bName = prompt ('Enter a name for the brush', 'brush 1', 'Create Brush')
if(bName != null){
var idMk = charIDToTypeID( "Mk " );
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idBrsh = charIDToTypeID( "Brsh" );
ref1.putClass( idBrsh );
desc5.putReference( idnull, ref1 );
var idUsng = charIDToTypeID( "Usng" );
var ref2 = new ActionReference();
var idPrpr = charIDToTypeID( "Prpr" );
var idfsel = charIDToTypeID( "fsel" );
ref2.putProperty( idPrpr, idfsel );
var idDcmn = charIDToTypeID( "Dcmn" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref2.putEnumerated( idDcmn, idOrdn, idTrgt );
desc5.putReference( idUsng, ref2 );
var idNm = charIDToTypeID( "Nm " );
desc5.putString( idNm, bName );
executeAction( idMk, desc5, DialogModes.NO );
}
Copy link to clipboard
Copied
What you wrote works perfectly if I have one PNG file open, thank-you! If I have a file open with multiple layers, the script will make a brush out of all the layers combined. Is there a way around that, or would that require too many complicated changes to the script?
Copy link to clipboard
Copied
So you want only the selected layer to be made into a brush? Also you want all open documents to be made into brushes?
Copy link to clipboard
Copied
I would like to be able to have a file open and maybe it has 10 layers, then have the script make a brush preset out of each layer. I hope that makes sense.
Copy link to clipboard
Copied
Try this script:
#target photoshop
var doc = activeDocument;
doc.activeLayer = doc.layers[0];
var wkL
visLayers ();
for(var i=0;i<doc.layers.length;i++){
wkL = doc.activeLayer = doc.layers;
wkL.visible = true;
var bName = prompt ('Enter a name for the brush', 'brush 1', 'Create Brush')
if(bName != null){
mkBrush ();
};
wkL.visible = false;
}
for(var i=0;i<doc.layers.length;i++){
doc.layers.visible = true;
}
function mkBrush(){
var idMk = charIDToTypeID( "Mk " );
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idBrsh = charIDToTypeID( "Brsh" );
ref1.putClass( idBrsh );
desc5.putReference( idnull, ref1 );
var idUsng = charIDToTypeID( "Usng" );
var ref2 = new ActionReference();
var idPrpr = charIDToTypeID( "Prpr" );
var idfsel = charIDToTypeID( "fsel" );
ref2.putProperty( idPrpr, idfsel );
var idDcmn = charIDToTypeID( "Dcmn" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref2.putEnumerated( idDcmn, idOrdn, idTrgt );
desc5.putReference( idUsng, ref2 );
var idNm = charIDToTypeID( "Nm " );
desc5.putString( idNm, bName );
executeAction( idMk, desc5, DialogModes.NO );
}
function visLayers(){
var idShw = charIDToTypeID( "Shw " );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var list1 = new ActionList();
var ref1 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref1.putEnumerated( idLyr, idOrdn, idTrgt );
list1.putReference( ref1 );
desc2.putList( idnull, list1 );
var idTglO = charIDToTypeID( "TglO" );
desc2.putBoolean( idTglO, true );
executeAction( idShw, desc2, DialogModes.NO );
}
Copy link to clipboard
Copied
Chuck,
Thank-you so much for this script. Both of them work perfectly. Sending you Merry Christmas wishes!
Paula