Skip to main content
jayanam
Participant
April 16, 2016
Answered

Set spacing for brush

  • April 16, 2016
  • 2 replies
  • 947 views

HI, I want to set hardness for a brush, but when I use a function to do so, the spacing and diameter is set to 25 automatically. So I use this function to set hardness, spacing and  diameter:

  function setBrushFeatures(Diameter,Hardness,Spacing) { 

  var ref = new ActionReference(); 

  ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 

  var appDesc = executeActionGet(ref); 

  var toolDesc = appDesc.getObjectValue(stringIDToTypeID('currentToolOptions')); 

  var brushDesc = toolDesc.getObjectValue(stringIDToTypeID('brush')); 

  var desc = new ActionDescriptor(); 

  var ref = new ActionReference(); 

  ref.putEnumerated( charIDToTypeID( "Brsh" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) ); 

  desc.putReference( charIDToTypeID( "null" ), ref ); 

  var desc1 = new ActionDescriptor(); 

 

  desc1.putDouble(stringIDToTypeID('diameter'), Diameter); 

 

  desc1.putDouble(stringIDToTypeID('hardness'), Hardness); 

  desc1.putDouble(stringIDToTypeID('spacing'), Spacing); 

 

  var desc5 = new ActionDescriptor(); 

  var idnull = charIDToTypeID( "null" ); 

  var ref3 = new ActionReference(); 

  var idBrsh = charIDToTypeID( "Brsh" ); 

  var idOrdn = charIDToTypeID( "Ordn" ); 

  var idTrgt = charIDToTypeID( "Trgt" ); 

  ref3.putEnumerated( idBrsh, idOrdn, idTrgt ); 

  desc5.putReference( idnull, ref3 ); 

 

   desc5.putObject(charIDToTypeID('T   '), charIDToTypeID('Brsh'), desc1); 

   executeAction(charIDToTypeID('setd'), desc5, DialogModes.NO); 

}

This works but the spacing is not applied, what am I missing?

Cheers

Matthias

This topic has been closed for replies.
Correct answer SuperMerlin

setBrushFeatures(50,50,50);

function setBrushFeatures(Diameter,Hardness,Spacing) { 

  var ref = new ActionReference();

  ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

  var appDesc = executeActionGet(ref);

  var toolDesc = appDesc.getObjectValue(stringIDToTypeID('currentToolOptions'));

  var brushDesc = toolDesc.getObjectValue(stringIDToTypeID('brush'));

  var desc = new ActionDescriptor();

  var ref = new ActionReference();

  ref.putEnumerated( charIDToTypeID( "Brsh" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );

  desc.putReference( charIDToTypeID( "null" ), ref );

  var desc1 = new ActionDescriptor();

  desc1.putDouble(stringIDToTypeID('diameter'), Diameter);

  desc1.putDouble(stringIDToTypeID('hardness'), Hardness);

  desc1.putUnitDouble( stringIDToTypeID('spacing'), charIDToTypeID('#Prc'), Spacing);

  var desc5 = new ActionDescriptor();

  var idnull = charIDToTypeID( "null" );

  var ref3 = new ActionReference();

  var idBrsh = charIDToTypeID( "Brsh" );

  var idOrdn = charIDToTypeID( "Ordn" );

  var idTrgt = charIDToTypeID( "Trgt" );

  ref3.putEnumerated( idBrsh, idOrdn, idTrgt );

  desc5.putReference( idnull, ref3 );

  desc5.putObject(charIDToTypeID('T   '), charIDToTypeID('Brsh'), desc1);

  executeAction(charIDToTypeID('setd'), desc5, DialogModes.NO);

};

2 replies

jayanam
jayanamAuthor
Participant
April 17, 2016

Ah cool, thx, How did you found out that #Prc is needed?

Matthias

SuperMerlin
Inspiring
April 17, 2016

Just used scriptListener after altering the spacing.

jayanam
jayanamAuthor
Participant
April 17, 2016

ok thx, is there a script listener for photoshop CC 2015 also? can't find it.

SuperMerlin
SuperMerlinCorrect answer
Inspiring
April 16, 2016

setBrushFeatures(50,50,50);

function setBrushFeatures(Diameter,Hardness,Spacing) { 

  var ref = new ActionReference();

  ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

  var appDesc = executeActionGet(ref);

  var toolDesc = appDesc.getObjectValue(stringIDToTypeID('currentToolOptions'));

  var brushDesc = toolDesc.getObjectValue(stringIDToTypeID('brush'));

  var desc = new ActionDescriptor();

  var ref = new ActionReference();

  ref.putEnumerated( charIDToTypeID( "Brsh" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );

  desc.putReference( charIDToTypeID( "null" ), ref );

  var desc1 = new ActionDescriptor();

  desc1.putDouble(stringIDToTypeID('diameter'), Diameter);

  desc1.putDouble(stringIDToTypeID('hardness'), Hardness);

  desc1.putUnitDouble( stringIDToTypeID('spacing'), charIDToTypeID('#Prc'), Spacing);

  var desc5 = new ActionDescriptor();

  var idnull = charIDToTypeID( "null" );

  var ref3 = new ActionReference();

  var idBrsh = charIDToTypeID( "Brsh" );

  var idOrdn = charIDToTypeID( "Ordn" );

  var idTrgt = charIDToTypeID( "Trgt" );

  ref3.putEnumerated( idBrsh, idOrdn, idTrgt );

  desc5.putReference( idnull, ref3 );

  desc5.putObject(charIDToTypeID('T   '), charIDToTypeID('Brsh'), desc1);

  executeAction(charIDToTypeID('setd'), desc5, DialogModes.NO);

};