Skip to main content
December 28, 2009
Question

Applying [None] character style

  • December 28, 2009
  • 2 replies
  • 8140 views

I have a script that finds text with a certain character style, cuts that text from the main story and anchors it in a frame that sits in the margin.

Everything works fine except that I'd like to have the option of removing the character style. However, when I apply the [None] character style InD shows [None] in the character style lists but the formatting for the character style that was just removed remains on the text.

Is there a way to have it work as if the [None] was manually selected from the character style list? i.e.: where the character style formatting is removed as well?

Thanks,

Ken

2 replies

Harbs.
Legend
December 28, 2009

I was sure I responded this morning...

Use text.applyCharacterStyle() instead which allows you to clear overrides in the process.

You can also just do clearOverrides() on the text after applying the [None] style.

Harbs

Jongware
Community Expert
Community Expert
December 29, 2009

Eh, Harbs, isn't that the problem when applying character styles?

void applyCharacterStyle (using: CharacterStyle)
Apply a character style.

No 'clearingOverrides' parameter. It was the first thing I thought of checking.

You can apply a [None] style and then re-apply its own paragraph style, clearing overrides, but that has the potentially nasty side effect it removes all overrides in the entire paragraph.

[Edit] Ah -- good point on the clearOverrides. You can then do a clearOverrides(OverrideType.CHARACTER_ONLY) on just the selection you applied [None] to. Now that oughta work.

Harbs.
Legend
December 29, 2009

Yeah. Sorry about that. I replied from memory, and forgot that applyCharacterStyle doesn't have the "clear overrides" parameter. (applyParagraphStyle does have one.)

I guess it's only option 2 (which is the way I've done it in the past)...

Harbs

grefel
Community Expert
Community Expert
December 28, 2009

hey,

i think this is a bug in indesign. for my scripts i simply create a new characterStyle based on [None] and apply this

var _basedOnNone = app.activeDocument.characterStyles.add({name:"None", basedOn:app.activeDocument.characterStyles[0]})
app.selection[0].appliedCharacterStyle = _basedOnNone

i would be interested in any other solution!

Steven__
Inspiring
December 28, 2009
No text available