Skip to main content
dublove
Legend
Jul 2, 2025 3:06 AM UTC
Answered

How to create new "None" character  paragraph  table cell and object styles with scripts?

There are too many different properties settings.

I want to get a controlled, clean style with no overrides.
Is there an easy way to do it in three or two lines?

 

Thank you very  much.

rob day
rob dayCorrect answer
Community Expert
Jul 2, 2025 1:51 PM UTC

Text objects also has the clearOverrides() method—this would clear the overrides from selected text

 

//some selected text—Text, Paragraohs, Characters etc.
var sel = app.activeDocument.selection[0];
//could also be OverrideType.CHARACTER_ONLY or OverrideType.PARAGRAPH_ONLY
sel.clearOverrides(OverrideType.ALL)

4 replies

rob day
Community Expert
Community Expert
Jul 2, 2025 1:30 PM UTC

Hi @dublove , The function I’ve posted for you in the past uses the default on creation—based on [No Paragraoh Style]—then you set the properties you want to change in the propertie = {} line:

 

//create a default paragraph style
var pStyle = makeParaStyle(app.activeDocument, "MyStyle")
//changed properties from the default
pStyle.properties = {fillColor:"Black", fillTint:50}


/**
* Makes a new named ParagraphStyle 
* @ param the document to add the style to 
* @ param style name 
* @ return the new paragraph style 
*/

function makeParaStyle(d, n){
if (d.paragraphStyles.itemByName(n).isValid) {
return d.paragraphStyles.itemByName(n);
 } else {
return d.paragraphStyles.add({name:n});
 }
}

 

 

Translate
rob day
Community Expert
rob dayCommunity ExpertCorrect answer
Community Expert
Jul 2, 2025 1:51 PM UTC

Text objects also has the clearOverrides() method—this would clear the overrides from selected text

 

//some selected text—Text, Paragraohs, Characters etc.
var sel = app.activeDocument.selection[0];
//could also be OverrideType.CHARACTER_ONLY or OverrideType.PARAGRAPH_ONLY
sel.clearOverrides(OverrideType.ALL)
Translate
justlearn
Community Expert
Community Expert
Jul 2, 2025 8:03 AM UTC

@dublove one of the easiest way to see if you have any styles that have 'overrides' is by toggling the 'highlighter' 

Once you see an override, select that override and create a new style from it.

Translate
m
dublove
dubloveAuthor
Legend
Jul 2, 2025 12:30 PM UTC

Hi creative explorer.

It's not that, it's that I often have to use the code in scripts.
Looking for some simple code.

Translate