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

How to use appliedConditions in a Indesign script

Community Beginner ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

I am attempting to write a script which completes a series of auto-transalation for series of flyer we convert to bilingual.  I am very new to javascripting. I am have having uses understanding how appliedConditions is used/coded to work.

- This what I drafted up.  (Both the Character style and Condition are already in the document created either thrua script or the styleif copy tot eh document.)

- I am using GrepPreferences vs TextPreferences because later on I have GREP searches to complete.

 

app.findChangeGrepOptions = null;

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.findWhat = '(?i)Assorted SKUs';
app.changeGrepPreferences.appliedCharacterStyle = 'Pigiarniq - Bold';
app.changeGrepPreferences.changeTo = 'ᐊᔾᔨᒌᙱᑦᑐᓂ ᓈᓴᐅᑎᓖᑦ';
app.changeGrepPreference.appliedConditions = ['DoNotTranslate'];

app.activeDocument.changeGrep();

 

I get error number 55

 

thank you in advance

TOPICS
How to , Scripting

Views

838

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 ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

You have a slight typo in your code, you have a missing s. Use the following

app.changeGrepPreferences.appliedConditions = ['DoNotTranslate'];

In the document you should have a condition DoNotTranslate present, then i don't get any errors.

Screenshot 2020-05-09 at 5.10.21 AM.png

-Manan

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 Beginner ,
May 11, 2020 May 11, 2020

Copy link to clipboard

Copied

Manan,

thank you - clearly end of day on friday not the best time for my dyslexic brain - thank you so very much 🙂

JJ

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 Beginner ,
May 11, 2020 May 11, 2020

Copy link to clipboard

Copied

Follow up

I now need to apply just the condition to text without the replacing of the text and it not working

 

function grep_reset(){
app.findGrepPreferences = NothingEnum.nothing;
app.findChangeGrepOptions.includeLockedLayersForFind = true;
app.findChangeGrepOptions.includeLockedStoriesForFind = true;
app.findChangeGrepOptions.includeHiddenLayers = false;
app.findChangeGrepOptions.includeMasterPages = true;
app.findChangeGrepOptions.includeFootnotes = true;
app.changeGrepPreferences = NothingEnum.nothing;
}

app.findGrepPreferences.findWhat = '\$\d\d*,*\d+\.\d\d';
app.changeGrepPreferences.appliedConditions = ['DoNotTranslate'];
app.activeDocument.changeGrep();
grep_reset();

 

can you enlighten me as to what I goofed up this time?

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 ,
May 11, 2020 May 11, 2020

Copy link to clipboard

Copied

On first look it seems a problem with escaping the grep string. Use the following it should work

app.findGrepPreferences.findWhat = '\\$\\d\\d*,*\\d+\\.\\d\\d';

 

-Manan

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 ,
May 12, 2020 May 12, 2020

Copy link to clipboard

Copied

LATEST

Hi JJ_Cloutier,

if you want to test an expression like:

app.findGrepPreferences.findWhat =

Simply execute the command and then switch to InDesign's GREP Find/Change panel to see what exactly happened.

This one executed:

app.findGrepPreferences.findWhat = '\$\d\d*,*\d+\.\d\d';

will yield this result:

GREP-FindChange-FindWhat-1.PNG

 

This is an easy way to debug your GREP Find expressions.

 

Regards,
Uwe Laubender

( ACP )

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