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

Setting Opacity and Feathering of a selected Brush via script

Community Expert ,
Mar 27, 2020 Mar 27, 2020

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;
}

 

 

TOPICS
Actions and scripting

Views

498

Translate

Translate

Report

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

Community Expert , Mar 28, 2020 Mar 28, 2020

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 );

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 28, 2020 Mar 28, 2020

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 );

Votes

Translate

Translate

Report

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
Community Expert ,
Mar 29, 2020 Mar 29, 2020

Copy link to clipboard

Copied

LATEST

Worked perfectly. Thank you!

Votes

Translate

Translate

Report

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