Thanks for replying and sorry if I start repeating Your own questions …
ActionDecsriptors seem beyond my understanding.
But please allow me one more:
If I make an alert from »brushDesc.toStream()« for a sampled and a computed brush they produce differing texts as seen in attached jpg.
»sampledBrush« and »computedBrush« seem to be no keys though or at least the count of the descriptor doesn’t include them, so what are they?
Setting brush options
Setting brush options
pfaffenbichler wrote:Thanks for replying and sorry if I start repeating Your own questions …
Keep asking, maybe the way to solve this is by using toStream. I know I haven't had any luck using my approach.
From looking at all the code posted I would guess that »sampledBrush« and »computedBrush« are stringID for brush type. At least Paul used computedBrush in his code to write the descriptor back. I'm not sure where he got that. I am using the charID Brsh.
I just tried changing Brsh to sampledBrush using my code and it still reset the brush to computed.
Keep asking, maybe the way to solve this is by using toStream. I know I haven't had any luck using my approach.
From looking at all the code posted I would guess that »sampledBrush« and »computedBrush« are stringID for brush type. At least Paul used computedBrush in his code to write the descriptor back. I'm not sure where he got that. I am using the charID Brsh.
I just tried changing Brsh to sampledBrush using my code and it still reset the brush to computed.
Setting brush options
I wonder if anyone has managed to set the mode, opacity and flow of the selected brush?
Setting brush options
No, I would think the code should look something like this
Code: Select all var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var appDesc = executeActionGet(ref);
var toolDesc = appDesc.getObjectValue(stringIDToTypeID('currentToolOptions'));
toolDesc.putInteger(stringIDToTypeID( 'opacity'), 50 );
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID('currentToolOptions') );
ref.putEnumerated( charIDToTypeID( "capp" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
desc.putObject( charIDToTypeID( "T " ), stringIDToTypeID('currentToolOptions'), toolDesc );
executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
Or
Code: Select all var ref = new ActionReference();
ref.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID('currentToolOptions') );
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var toolDesc = executeActionGet(ref).getString(stringIDToTypeID('currentToolOptions'));
toolDesc.putInteger(stringIDToTypeID( 'opacity'), 50 );
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID('currentToolOptions') );
ref.putEnumerated( charIDToTypeID( "capp" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
desc.putObject( charIDToTypeID( "T " ), stringIDToTypeID('currentToolOptions'), toolDesc );
executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
But neither work.
Code: Select all var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var appDesc = executeActionGet(ref);
var toolDesc = appDesc.getObjectValue(stringIDToTypeID('currentToolOptions'));
toolDesc.putInteger(stringIDToTypeID( 'opacity'), 50 );
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID('currentToolOptions') );
ref.putEnumerated( charIDToTypeID( "capp" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
desc.putObject( charIDToTypeID( "T " ), stringIDToTypeID('currentToolOptions'), toolDesc );
executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
Or
Code: Select all var ref = new ActionReference();
ref.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID('currentToolOptions') );
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var toolDesc = executeActionGet(ref).getString(stringIDToTypeID('currentToolOptions'));
toolDesc.putInteger(stringIDToTypeID( 'opacity'), 50 );
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID('currentToolOptions') );
ref.putEnumerated( charIDToTypeID( "capp" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
desc.putObject( charIDToTypeID( "T " ), stringIDToTypeID('currentToolOptions'), toolDesc );
executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
But neither work.
Setting brush options
Thank you for that Mike, another question though.. How did you manage to get the second list of keys, you mentioned the brush was active? Is there a way to try and set these fields when the brush is in this state so the keys are available?
Setting brush options
The second set of keys are the descriptor keys of currentToolOptions when the brush tool is selected so all of those keys can be read with an executeActionGet. I just can't work out how to set them. It may not be possible and we will be forced to use tool presets.
Below is another variation that doesn't work.
Code: Select all var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( stringIDToTypeID('currentToolOptions'), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
var desc1 = new ActionDescriptor();
desc1.putInteger(stringIDToTypeID( 'opacity'), 50 );
desc.putObject( charIDToTypeID( "T " ), stringIDToTypeID('currentToolOptions'), desc1 );
executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
Below is another variation that doesn't work.
Code: Select all var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( stringIDToTypeID('currentToolOptions'), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
var desc1 = new ActionDescriptor();
desc1.putInteger(stringIDToTypeID( 'opacity'), 50 );
desc.putObject( charIDToTypeID( "T " ), stringIDToTypeID('currentToolOptions'), desc1 );
executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
Setting brush options
I tried to get and set the angle of a brush, the angle is correctly seted but the selected brush is changed automatically to Soft Round 25 :s
Does anyone knows how to specify a brush ? I would like to keep the previously selected brush.
Code: Select all*function setBrushAngle(angle) {
while(angle > 180) {
angle = angle - 360
}
while(angle < -180) {
angle = angle + 360
}
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.putUnitDouble( stringIDToTypeID( "angle" ), charIDToTypeID( "#Prc" ), angle );
desc.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Brsh" ), desc1 );
executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
};
Does anyone knows how to specify a brush ? I would like to keep the previously selected brush.
Code: Select all*function setBrushAngle(angle) {
while(angle > 180) {
angle = angle - 360
}
while(angle < -180) {
angle = angle + 360
}
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.putUnitDouble( stringIDToTypeID( "angle" ), charIDToTypeID( "#Prc" ), angle );
desc.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Brsh" ), desc1 );
executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
};
Setting brush options
If your brush is a sampled brush I don't know of any way to change any of the brush setting without Photoshop changing the brush to a computed brush.
Setting brush options
What do you mean ?
My brush is a custom one i made, i use a special shape and a special texture, can it be helpful ?
My brush is a custom one i made, i use a special shape and a special texture, can it be helpful ?
Setting brush options
That is a sampled brush. As far as I can tell you can't edit it with scripting.