Skip to main content
Inspiring
February 23, 2022
Answered

Set tool with Action Manager code

  • February 23, 2022
  • 2 replies
  • 1059 views

Taking a stab at Action Manager code. I want to be able to set the antialiasing in the tool to none without having to set any text. Hence using AM code:

 

It's a wild stab in the dark with a blindfold on:

var idMk = charIDToTypeID( "Mk  " );
var desc11046 = new ActionDescriptor();
var ref2274 = new ActionReference();
var idAntA = charIDToTypeID( "AntA" );
var idPrpr = charIDToTypeID( "Prpr" );
ref2274.putProperty( idPrpr, idAntA );
var idAnnt = charIDToTypeID( "Annt" );
var idAnno = charIDToTypeID( "Anno" );
var idantiAliasNone = stringIDToTypeID( "antiAliasNone" );
desc11046.putEnumerated( idAntA, idAnnt, idantiAliasNone );
executeAction( idMk, desc11046, DialogModes.NO );

 

Sadly, it doesn't work but I don't know why or where. Any ideas?

 

 

 

 

This topic has been closed for replies.
Correct answer jazz-y

 

#target photoshop;

var s2t = stringIDToTypeID;

(r = new ActionReference()).putProperty(s2t('property'), p = s2t('currentToolOptions'));
r.putEnumerated(s2t('application'), s2t('ordinal'), s2t('targetEnum'));
var toolOptions = executeActionGet(r).getObjectValue(p),
    characterOptions = toolOptions.getObjectValue(s2t('textToolCharacterOptions')),
    textStyle = characterOptions.getObjectValue(s2t('textStyle'));

textStyle.putInteger(s2t('antiAlias'), 0);
characterOptions.putObject(s2t('textStyle'), s2t('textStyle'), textStyle);
toolOptions.putObject(s2t('textToolCharacterOptions'), s2t('null'), characterOptions);

(r = new ActionReference()).putClass(s2t('typeCreateOrEditTool'));
(d = new ActionDescriptor()).putReference(s2t('target'), r);
d.putObject(s2t('to'), s2t('target'), toolOptions);
executeAction(s2t('set'), d, DialogModes.NO);

 

Frst we need to find in which object the antiAlias ​​option is located (application -> currentToolOptions -> textToolCharacterOptions -> textStyle). In one of the recent threads @Stephen Marsh gave you a link where it was described in detail how to search for parameters. Then we sequentially collect the object in reverse order, i.e. first we put antiAlias ​​= 0 in textStyle, then we put textStyle in textToolCharacterOptions, and finally put textToolCharacterOptions in currentToolOptions (do not forget that in addition to the name of the object, we need to specify its classID - all this is available at the stage of searching for the desired variable). After we got the finished object, we simply assign it to the typeCreateOrEditTool class (name of current tool can be found at application -> tool)

2 replies

jazz-yCorrect answer
Legend
February 23, 2022

 

#target photoshop;

var s2t = stringIDToTypeID;

(r = new ActionReference()).putProperty(s2t('property'), p = s2t('currentToolOptions'));
r.putEnumerated(s2t('application'), s2t('ordinal'), s2t('targetEnum'));
var toolOptions = executeActionGet(r).getObjectValue(p),
    characterOptions = toolOptions.getObjectValue(s2t('textToolCharacterOptions')),
    textStyle = characterOptions.getObjectValue(s2t('textStyle'));

textStyle.putInteger(s2t('antiAlias'), 0);
characterOptions.putObject(s2t('textStyle'), s2t('textStyle'), textStyle);
toolOptions.putObject(s2t('textToolCharacterOptions'), s2t('null'), characterOptions);

(r = new ActionReference()).putClass(s2t('typeCreateOrEditTool'));
(d = new ActionDescriptor()).putReference(s2t('target'), r);
d.putObject(s2t('to'), s2t('target'), toolOptions);
executeAction(s2t('set'), d, DialogModes.NO);

 

Frst we need to find in which object the antiAlias ​​option is located (application -> currentToolOptions -> textToolCharacterOptions -> textStyle). In one of the recent threads @Stephen Marsh gave you a link where it was described in detail how to search for parameters. Then we sequentially collect the object in reverse order, i.e. first we put antiAlias ​​= 0 in textStyle, then we put textStyle in textToolCharacterOptions, and finally put textToolCharacterOptions in currentToolOptions (do not forget that in addition to the name of the object, we need to specify its classID - all this is available at the stage of searching for the desired variable). After we got the finished object, we simply assign it to the typeCreateOrEditTool class (name of current tool can be found at application -> tool)

Inspiring
February 23, 2022

Sadly, that fails on line 7. Running PS 19.16, if that helps

 

Legend
February 23, 2022

I only have the latest version installed (this is my mistake - I didn't check compatibility with older versions). Try that way:

 

#target photoshop;

var s2t = stringIDToTypeID;

(r = new ActionReference()).putProperty(s2t('property'), p = s2t('tool'));
r.putEnumerated(s2t('application'), s2t('ordinal'), s2t('targetEnum'));
var toolOptions = executeActionGet(r).getObjectValue(s2t('currentToolOptions')),
    characterOptions = toolOptions.getObjectValue(s2t('textToolCharacterOptions')),
    textStyle = characterOptions.getObjectValue(s2t('textStyle'));

textStyle.putInteger(s2t('antiAlias'), 0);
characterOptions.putObject(s2t('textStyle'), s2t('textStyle'), textStyle);
toolOptions.putObject(s2t('textToolCharacterOptions'), s2t('null'), characterOptions);

(r = new ActionReference()).putClass(s2t('typeCreateOrEditTool'));
(d = new ActionDescriptor()).putReference(s2t('target'), r);
d.putObject(s2t('to'), s2t('target'), toolOptions);
executeAction(s2t('set'), d, DialogModes.NO);

 

Kukurykus
Legend
February 23, 2022
Inspiring
February 23, 2022

This is setting text, or text tools. which is the same; but different 🙂

 

Kukurykus
Legend
February 23, 2022

I don't understand what you need.