Copy link to clipboard
Copied
Hi all - I am working on a script that relies on some preloaded brushes. From what I can gather (I'm traditionally an InDesign scripter), the only way to set opacity is through a preloaded brush. I do have a function in script that checks the brushes, where I'd like to set the opacity and feather weight of these brushes if they exist. I can't figure out how to Action Script it. Does anyone have any guidance? TIA.
var hasBrushes = function(weight) {
function checkStroked(enabled) {
if (enabled != undefined && !enabled)
return;
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(cTID('Brsh'), "Solid" + weight.toString() + "px");
desc1.putReference(cTID('null'), ref1);
executeAction(cTID('slct'), desc1, DialogModes.NO);
};
function checkDotted(enabled) {
if (enabled != undefined && !enabled)
return;
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(cTID('Brsh'), "Dotted" + weight.toString() + "px");
desc1.putReference(cTID('null'), ref1);
executeAction(cTID('slct'), desc1, DialogModes.NO);
};
try {
checkStroked();
checkDotted();
catch(e) { return false; }
return true;
}
Does that helps you a little?
// set brush opacity to 84 Procent
var brsh = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( charIDToTypeID('PbTl') );
brsh.putReference( charIDToTypeID('null'), ref );
var desc_br = new ActionDescriptor();
desc_br.putUnitDouble( charIDToTypeID('Opct'), charIDToTypeID('#Prc'), 84 ); // opacity
brsh.putObject( charIDToTypeID('T '), charIDToTypeID('null'), desc_br );
executeAction( charIDToTypeID('setd'), brsh, DialogModes.NO );
Copy link to clipboard
Copied
Does that helps you a little?
// set brush opacity to 84 Procent
var brsh = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( charIDToTypeID('PbTl') );
brsh.putReference( charIDToTypeID('null'), ref );
var desc_br = new ActionDescriptor();
desc_br.putUnitDouble( charIDToTypeID('Opct'), charIDToTypeID('#Prc'), 84 ); // opacity
brsh.putObject( charIDToTypeID('T '), charIDToTypeID('null'), desc_br );
executeAction( charIDToTypeID('setd'), brsh, DialogModes.NO );
Copy link to clipboard
Copied
Worked perfectly. Thank you!