Skip to main content
dublove
Legend
October 1, 2025
Answered

The basedOn property of the object style has been read, but why isn't it actually working?

  • October 1, 2025
  • 2 replies
  • 172 views

"basedOn" is merely a setting, but it doesn't actually take effect.

I can see in the b1 object style that it is based on a1, but in fact, b1 does not inherit a1's settings.

It might be because “basedOn” was set later.
Do I need to “reset the baseline options”?


How is this script written?

app.documents[0].objectStyleGroups.itemByName(AA).
    objectStyles.itemByName(b1).properties = {
    basedOn: app.documents[0].objectStyleGroups.itemByName(AA).objectStyles.itemByName(a1),

 

Correct answer m1b

Hi @dublove here is a function to do the "Reset to Base".

- Mark

 

/**
 * @file Reset Object Style.js
 *
 * Equivalent of clicking the "Reset To Base" button
 * in the Object Style Options dialog box..
 *
 * @author m1b
 * @version 2025-10-09
 * @discussion https://community.adobe.com/t5/indesign-discussions/how-to-create-new-object-styles-based-on-really-quot-none-quot-object-using-scripts/m-p/15412503
 */
function main() {

    var doc = app.activeDocument;
    var myTestStyle = doc.objectStyles.itemByName('Test');

    // reset the style to its base style
    resetObjectStyle(myTestStyle);

};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Reset Object Style');

/**
 * Resets the object style to its base style.
 * @author m1b
 * @version 2025-10-09
 * @param {ObjectStyle} style - the style to reset.
 */
function resetObjectStyle(style) {

    var baseStyle = style.basedOn;

    if (!baseStyle.isValid)
        return alert('Object style cannot be reset due to missing base style.');

    style.properties = baseStyle.properties;
    style.contentEffectsEnablingSettings.properties = baseStyle.contentEffectsEnablingSettings.properties;
    style.objectEffectsEnablingSettings.properties = baseStyle.objectEffectsEnablingSettings.properties;

    style.basedOn = baseStyle;

};

2 replies

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
October 9, 2025

Hi @dublove here is a function to do the "Reset to Base".

- Mark

 

/**
 * @file Reset Object Style.js
 *
 * Equivalent of clicking the "Reset To Base" button
 * in the Object Style Options dialog box..
 *
 * @author m1b
 * @version 2025-10-09
 * @discussion https://community.adobe.com/t5/indesign-discussions/how-to-create-new-object-styles-based-on-really-quot-none-quot-object-using-scripts/m-p/15412503
 */
function main() {

    var doc = app.activeDocument;
    var myTestStyle = doc.objectStyles.itemByName('Test');

    // reset the style to its base style
    resetObjectStyle(myTestStyle);

};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Reset Object Style');

/**
 * Resets the object style to its base style.
 * @author m1b
 * @version 2025-10-09
 * @param {ObjectStyle} style - the style to reset.
 */
function resetObjectStyle(style) {

    var baseStyle = style.basedOn;

    if (!baseStyle.isValid)
        return alert('Object style cannot be reset due to missing base style.');

    style.properties = baseStyle.properties;
    style.contentEffectsEnablingSettings.properties = baseStyle.contentEffectsEnablingSettings.properties;
    style.objectEffectsEnablingSettings.properties = baseStyle.objectEffectsEnablingSettings.properties;

    style.basedOn = baseStyle;

};
dublove
dubloveAuthor
Legend
October 9, 2025

Another world-class challenge has been conquered.
Absolutely amazing!

Thank you very much.

dublove
dubloveAuthor
Legend
October 2, 2025

Finding the code for this will solve the problem.