Highlighted

How to use appliedConditions in a Indesign script

Community Beginner ,
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

399

Likes

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

How to use appliedConditions in a Indesign script

Community Beginner ,
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

400

Likes

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
May 08, 2020 0
Adobe Community Professional ,
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

Likes

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
Reply
Loading...
May 08, 2020 1
Community Beginner ,
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

Likes

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
Reply
Loading...
May 11, 2020 0
Community Beginner ,
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?

Likes

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
Reply
Loading...
May 11, 2020 0
Adobe Community Professional ,
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

Likes

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
Reply
Loading...
May 11, 2020 1
Adobe Community Professional ,
May 12, 2020

Copy link to clipboard

Copied

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 )

Likes

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
Reply
Loading...
May 12, 2020 3