• 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 write the code to clear the "priority option" of the style?

Enthusiast ,
Sep 24, 2020 Sep 24, 2020

Copy link to clipboard

Copied

How should the code to clear the "Preferences" of "Character Style" and "Paragraph Style" be written?
Similarly, how do you write the code to clear the "Preferences" of "Table Style" and "Cell Format"?
These styles are imported from word, I don’t need them, they must be removed.

 

Thank you. 

TOPICS
Bug , How to , Import and export , Performance , Scripting

Views

399

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

Community Expert , Sep 26, 2020 Sep 26, 2020

Text or paragraphs have a clearOverrides method. This would get all of the stories in the active document, and clear the texts Pargraph and Character Style overrides.

 

 

 

//gets all of the document’s stories and clear their overrides
var txt = app.documents[0].stories.everyItem().clearOverrides(OverrideType.ALL)

//this would clear the paragraph overrides and leave the character overrides unchanged
var txt = app.documents[0].stories.everyItem().clearOverrides(OverrideType.OverrideType.PARAGRAP
...

Votes

Translate

Translate
Community Expert ,
Sep 24, 2020 Sep 24, 2020

Copy link to clipboard

Copied

I am not sure if I understood your question well. I suppose the following objects and properties could get you what you want

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#WordRTFImportPreference.html

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#TextImportPreference.html

-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 ,
Sep 25, 2020 Sep 25, 2020

Copy link to clipboard

Copied

—These styles are imported from word, I don’t need them, they must be removed.

 

If you want to delete imported styles, you can use the remove method. You can choose to replace with a new style with the parameter:

 

//gets the style to remove 
var ps = app.activeDocument.paragraphStyles.itemByName("ImportedStyleName");
ps.remove("ReplacementStyle")

 

You could also check if a style is imported:

var ps = app.activeDocument.paragraphStyles;


for (var i = 0; i < ps.length; i++){
    //Check if the style is imported
    if (ps[i].imported) {
        $.writeln("Imported")
        //remove and replace
        ps[i].remove("ReplacementStyle")
    } 
};   

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
Enthusiast ,
Sep 25, 2020 Sep 25, 2020

Copy link to clipboard

Copied

Hello, rob day.
I actually want to achieve: after importing my word text, apply the "mybody" paragraph style, apply the "none" character style, and clear the "priority option".

The same: after applying the script, apply the "mytab" table style, apply the "none" cell style, and clear the "preferences" of the table.
Thanks~

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 ,
Sep 25, 2020 Sep 25, 2020

Copy link to clipboard

Copied

What does "priority option" mean? Do you mean you want to clear overrides from the imported text (Paragraph Styles panel>Clear Overrides)?

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
Enthusiast ,
Sep 25, 2020 Sep 25, 2020

Copy link to clipboard

Copied

Overrides?

Maybe it’s what you said, it’s the one you need to press Alt+double click to clear.
We call it: mixed priority options。

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 ,
Sep 26, 2020 Sep 26, 2020

Copy link to clipboard

Copied

Text or paragraphs have a clearOverrides method. This would get all of the stories in the active document, and clear the texts Pargraph and Character Style overrides.

 

 

 

//gets all of the document’s stories and clear their overrides
var txt = app.documents[0].stories.everyItem().clearOverrides(OverrideType.ALL)

//this would clear the paragraph overrides and leave the character overrides unchanged
var txt = app.documents[0].stories.everyItem().clearOverrides(OverrideType.OverrideType.PARAGRAPH_ONLY)

 

 

 

 

Screen Shot 42.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
Enthusiast ,
Sep 26, 2020 Sep 26, 2020

Copy link to clipboard

Copied

LATEST

Hello~
rob day
It is "Clear Overrides".
It's a bit complicated, I don't understand it very well.
Can you write it completely for me? thank you very much!
------------------------------------
This is what I want to achieve:

after importing my text, apply the "mybody" paragraph style, apply the "none" text style, and perform "clear overrides" for "mybody".
(If it is not selected, The script will work on the entire text box. If selected, The script is useful for the current selection.)

If it is a table: After applying the script, apply the "mytab" table style and the "none" cell style. And perform "clear overrides" for "mytab",and "clear overrides" for "none" character style.
(No need to select, The script works on the table where the cursor is currently located)

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