Skip to main content
dublove
Legend
Jul 13, 2025 4:34 AM UTC
Answered

How to create new object styles based on really  "NONE" Object using scripts?

I realized that the  "NONE" object in the object style is not really none, it still has a lot of settings.

I would like to create a real none object style (e.g. named "trueNone ").
Then create a new AA object style based on "trueNone".

How to write it?
Thank you very much!

 

m1b
m1bCorrect answer
Community Expert
Jul 18, 2025 8:37 AM UTC

Hi @dublove, this will do it.

- Mark

 

/**
 * @file Make Object Style.js
 *
 * Note: the `makeObjectStyle` function can create
 * an *empty* object style, with no settings enabled.
 * 
 * In this example, we make "EMPTY" object style and then
 * make "NewStyle" which is based on "EMPTY". We make both
 * styles in the "My Group" ObjectStyleGroup.
 *
 * @author m1b
 * @version 2025-10-01
 * @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 styleGroup = makeObjectStyleGroup(doc, 'My Group');
    var emptyStyle = makeObjectStyle(styleGroup, 'EMPTY');
    var newStyle = makeObjectStyle(styleGroup, 'NewStyle', emptyStyle);

};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Do Script');

/**
 * Returns an object style named `name`, or if it
 * doesn't exist, returns an empty style.
 * @author m1b
 * @version 2025-10-01
 * @param {Document|ObjectStyleGroup} container - the container for the new style.
 * @param {String} name - the style's name.
 * @param {ObjectStyle} [parentObjectStyle] - the style to base the new style on (default: nothing).
 * @returns {ObjectStyle}
 */
function makeObjectStyle(container, name, parentObjectStyle) {

    if (
        !container
        || !container.hasOwnProperty('allObjectStyles')
    )
        throw new Error('makeObjectStyle: bad `container` supplied.');

    var style = getThing(container.allObjectStyles, 'name', name);

    if (style)
        return style;

    style = container.objectStyles.add({
        name: name,
        enableAnchoredObjectOptions: false,
        enableExportTagging: false,
        enableFill: false,
        enableFrameFittingOptions: false,
        enableObjectExportAltTextOptions: false,
        enableObjectExportEpubOptions: false,
        enableObjectExportTaggedPdfOptions: false,
        enableParagraphStyle: false,
        enableStoryOptions: false,
        enableStroke: false,
        enableStrokeAndCornerOptions: false,
        enableTextFrameAutoSizingOptions: false,
        enableTextFrameBaselineOptions: false,
        enableTextFrameColumnRuleOptions: false,
        enableTextFrameFootnoteOptions: false,
        enableTextFrameGeneralOptions: false,
        enableTextWrapAndOthers: false,
        enableTransformAttributes: false,
    });

    style.contentEffectsEnablingSettings.properties = {
        enableBevelEmboss: false,
        enableDirectionalFeather: false,
        enableDropShadow: false,
        enableFeather: false,
        enableGradientFeather: false,
        enableInnerGlow: false,
        enableInnerShadow: false,
        enableOuterGlow: false,
        enableSatin: false,
        enableTransparency: false,
    };

    style.objectEffectsEnablingSettings.properties = {
        enableBevelEmboss: false,
        enableDirectionalFeather: false,
        enableDropShadow: false,
        enableFeather: false,
        enableGradientFeather: false,
        enableInnerGlow: false,
        enableInnerShadow: false,
        enableOuterGlow: false,
        enableSatin: false,
        enableTransparency: false,
    };

    if (parentObjectStyle && parentObjectStyle.isValid)
        style.basedOn = parentObjectStyle;

    return style;

};

/**
 * Returns an ObjectStyleGroup named `name`,
 * creating it if necessary in `container`.
 * @author m1b
 * @version 2025-10-01
 * @param {Document|ObjectStyleGroup} container - the container for the new style.
 * @param {String} name - the style's name.
 */
function makeObjectStyleGroup(container, name) {

    if (
        !container
        || !container.hasOwnProperty('objectStyleGroups')
    )
        throw new Error('makeObjectStyleGroup: bad `container` supplied.');

    var styleGroup = getThing(container.objectStyleGroups, 'name', name);

    if (!styleGroup)
        styleGroup = container.objectStyleGroups.add({ name: name });

    return styleGroup;

};

/**
 * Returns a thing with matching property.
 * If `key` is undefined, evaluate the object itself.
 * @author m1b
 * @version 2024-04-21
 * @param {Array|Collection} things - the things to look through.
 * @param {String} [key] - the property name (default: undefined).
 * @param {*} value - the value to match.
 * @returns {*?} - the thing, if found.
 */
function getThing(things, key, value) {

    for (var i = 0; i < things.length; i++)
        if ((undefined == key ? things[i] : things[i][key]) == value)
            return things[i];

};

Edit 2025-07-18: added "basedOn" support.

Edit 2025-10-01: changed parameter `doc` to `container` and modify code to handle either Document or ObjectStyleGroup, so we can create the style inside a group. (Note: this script does not create the object style group if it is missing.)

Edit 2025-10-01: added "makeObjectStyleGroup" function to create the group if missing.

20 replies

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
Jul 18, 2025 8:37 AM UTC

Hi @dublove, this will do it.

- Mark

 

/**
 * @file Make Object Style.js
 *
 * Note: the `makeObjectStyle` function can create
 * an *empty* object style, with no settings enabled.
 * 
 * In this example, we make "EMPTY" object style and then
 * make "NewStyle" which is based on "EMPTY". We make both
 * styles in the "My Group" ObjectStyleGroup.
 *
 * @author m1b
 * @version 2025-10-01
 * @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 styleGroup = makeObjectStyleGroup(doc, 'My Group');
    var emptyStyle = makeObjectStyle(styleGroup, 'EMPTY');
    var newStyle = makeObjectStyle(styleGroup, 'NewStyle', emptyStyle);

};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Do Script');

/**
 * Returns an object style named `name`, or if it
 * doesn't exist, returns an empty style.
 * @author m1b
 * @version 2025-10-01
 * @param {Document|ObjectStyleGroup} container - the container for the new style.
 * @param {String} name - the style's name.
 * @param {ObjectStyle} [parentObjectStyle] - the style to base the new style on (default: nothing).
 * @returns {ObjectStyle}
 */
function makeObjectStyle(container, name, parentObjectStyle) {

    if (
        !container
        || !container.hasOwnProperty('allObjectStyles')
    )
        throw new Error('makeObjectStyle: bad `container` supplied.');

    var style = getThing(container.allObjectStyles, 'name', name);

    if (style)
        return style;

    style = container.objectStyles.add({
        name: name,
        enableAnchoredObjectOptions: false,
        enableExportTagging: false,
        enableFill: false,
        enableFrameFittingOptions: false,
        enableObjectExportAltTextOptions: false,
        enableObjectExportEpubOptions: false,
        enableObjectExportTaggedPdfOptions: false,
        enableParagraphStyle: false,
        enableStoryOptions: false,
        enableStroke: false,
        enableStrokeAndCornerOptions: false,
        enableTextFrameAutoSizingOptions: false,
        enableTextFrameBaselineOptions: false,
        enableTextFrameColumnRuleOptions: false,
        enableTextFrameFootnoteOptions: false,
        enableTextFrameGeneralOptions: false,
        enableTextWrapAndOthers: false,
        enableTransformAttributes: false,
    });

    style.contentEffectsEnablingSettings.properties = {
        enableBevelEmboss: false,
        enableDirectionalFeather: false,
        enableDropShadow: false,
        enableFeather: false,
        enableGradientFeather: false,
        enableInnerGlow: false,
        enableInnerShadow: false,
        enableOuterGlow: false,
        enableSatin: false,
        enableTransparency: false,
    };

    style.objectEffectsEnablingSettings.properties = {
        enableBevelEmboss: false,
        enableDirectionalFeather: false,
        enableDropShadow: false,
        enableFeather: false,
        enableGradientFeather: false,
        enableInnerGlow: false,
        enableInnerShadow: false,
        enableOuterGlow: false,
        enableSatin: false,
        enableTransparency: false,
    };

    if (parentObjectStyle && parentObjectStyle.isValid)
        style.basedOn = parentObjectStyle;

    return style;

};

/**
 * Returns an ObjectStyleGroup named `name`,
 * creating it if necessary in `container`.
 * @author m1b
 * @version 2025-10-01
 * @param {Document|ObjectStyleGroup} container - the container for the new style.
 * @param {String} name - the style's name.
 */
function makeObjectStyleGroup(container, name) {

    if (
        !container
        || !container.hasOwnProperty('objectStyleGroups')
    )
        throw new Error('makeObjectStyleGroup: bad `container` supplied.');

    var styleGroup = getThing(container.objectStyleGroups, 'name', name);

    if (!styleGroup)
        styleGroup = container.objectStyleGroups.add({ name: name });

    return styleGroup;

};

/**
 * Returns a thing with matching property.
 * If `key` is undefined, evaluate the object itself.
 * @author m1b
 * @version 2024-04-21
 * @param {Array|Collection} things - the things to look through.
 * @param {String} [key] - the property name (default: undefined).
 * @param {*} value - the value to match.
 * @returns {*?} - the thing, if found.
 */
function getThing(things, key, value) {

    for (var i = 0; i < things.length; i++)
        if ((undefined == key ? things[i] : things[i][key]) == value)
            return things[i];

};

Edit 2025-07-18: added "basedOn" support.

Edit 2025-10-01: changed parameter `doc` to `container` and modify code to handle either Document or ObjectStyleGroup, so we can create the style inside a group. (Note: this script does not create the object style group if it is missing.)

Edit 2025-10-01: added "makeObjectStyleGroup" function to create the group if missing.

Translate
dublove
dubloveAuthor
Legend
Jul 18, 2025 9:02 AM UTC

Hi  m1b.

Thank you very much.

 

There's one missing.
Creates an new objectstyle based on "empty" objectstyle.

Translate
m1b
Community Expert
Community Expert
Jul 18, 2025 9:10 AM UTC

I have updated. 🙂

Translate
leo.r
Community Expert
Community Expert
Jul 13, 2025 3:09 PM UTC

If I understand your question correctly, you'll need to set these properties to false:

 

The screenshot is from AppleScript dictionary, but you can easily transform the properties to their JS equivalents.

Translate
leo.r
Community Expert
Community Expert
Jul 13, 2025 3:13 PM UTC
dublove
dubloveAuthor
Legend
Jul 14, 2025 1:44 AM UTC

Thank you,
How to create a new style based on an existing style, e.g. existing "none" objectStyle, creat AA object style.

Translate