Skip to main content
dublove
Legend
Oct 1, 2025 4:47 PM UTC
Answered

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

"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),

 

m1b
m1bCorrect answer
Community Expert
Oct 9, 2025 2:31 AM UTC

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;

};

4 replies

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
Oct 9, 2025 2:31 AM UTC

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;

};
Translate
dublove
dubloveAuthor
Legend
Oct 9, 2025 7:21 AM UTC

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

Thank you very much.

Translate
dublove
dubloveAuthor
Legend
Oct 2, 2025 2:20 AM UTC

Finding the code for this will solve the problem.

Translate