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

Set tool with Action Manager code

Engaged ,
Feb 23, 2022 Feb 23, 2022

Copy link to clipboard

Copied

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?

 

 

 

 

TOPICS
Actions and scripting

Views

406

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

Guide , Feb 23, 2022 Feb 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('text
...

Votes

Translate

Translate
Adobe
LEGEND ,
Feb 23, 2022 Feb 23, 2022

Copy link to clipboard

Copied

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
Engaged ,
Feb 23, 2022 Feb 23, 2022

Copy link to clipboard

Copied

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

 

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
LEGEND ,
Feb 23, 2022 Feb 23, 2022

Copy link to clipboard

Copied

I don't understand what you need.

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
New Here ,
Feb 23, 2022 Feb 23, 2022

Copy link to clipboard

Copied

this guy solve your error

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
LEGEND ,
Feb 23, 2022 Feb 23, 2022

Copy link to clipboard

Copied

Reply if you are not SpamBot.

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
Guide ,
Feb 23, 2022 Feb 23, 2022

Copy link to clipboard

Copied

 

#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_A_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)

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
Engaged ,
Feb 23, 2022 Feb 23, 2022

Copy link to clipboard

Copied

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

GhoulFool_0-1645646193213.png

 

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
Guide ,
Feb 23, 2022 Feb 23, 2022

Copy link to clipboard

Copied

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

 

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
Engaged ,
Feb 24, 2022 Feb 24, 2022

Copy link to clipboard

Copied

Sadly, that also didn't work. 

 

GhoulFool_0-1645703024737.png

 

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
Guide ,
Feb 24, 2022 Feb 24, 2022

Copy link to clipboard

Copied

add before main function

app.currentTool = 'typeCreateOrEditTool'

Most tools allow you to set options without switching to them directly, but with typeCreateOrEditTool, that trick doesn't seem to work 😞

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
Engaged ,
Feb 24, 2022 Feb 24, 2022

Copy link to clipboard

Copied

Nice. That works, 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
Engaged ,
Feb 24, 2022 Feb 24, 2022

Copy link to clipboard

Copied

var aa = 2
textStyle.putInteger(s2t('antiAlias'), aa);

 

Setting aa to 0, 1, & 2 I get None , Sharp & Strong respectively. However it seems to have skipped over Crisp & smooth. Values or 3 or above give none. What's that about?

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
Guide ,
Feb 24, 2022 Feb 24, 2022

Copy link to clipboard

Copied

None == 0

Sharp == 16

Crisp == 1

Strong == 2

Smooth == 8

 

Windows LCD == 64

Windows == 128

 

Perhaps a bitmask is used there ðŸ¤·

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
Engaged ,
Feb 24, 2022 Feb 24, 2022

Copy link to clipboard

Copied

LATEST

D'oh! Thank you once again.

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