Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Guide ,
Jul 12, 2025 Jul 12, 2025

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!

880.png

 

TOPICS
Scripting
709
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 18, 2025 Jul 18, 2025

Hi @dublove, this will do it.

- Mark

 

Screenshot 2025-07-18 at 18.36.06.png

/**
 * @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-re
...
Translate
Community Expert ,
Jul 13, 2025 Jul 13, 2025

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

leor_0-1752419188595.png

 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 13, 2025 Jul 13, 2025
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 13, 2025 Jul 13, 2025

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 13, 2025 Jul 13, 2025

duplicate it

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 13, 2025 Jul 13, 2025

Found this one that brian_p_dts was talking about.
I'm a bit skeptical though, copying isn't based on it.

 

var myDocument = app.activeDocument;

myObjectStyle = myDocument.objectStyles.add({
    name:"obj style 1", 
    enableTextFrameAutoSizingOptions: true,
    textFramePreferences: {
        autoSizingType: AutoSizingTypeEnum.HEIGHT_ONLY,
        autoSizingReferencePoint: AutoSizingReferenceEnum.TOP_CENTER_POINT,
    }
})

myNewObjectStyle = myObjectStyle.duplicate();
myNewObjectStyle.name = "obj style 2";

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2025 Jul 18, 2025

Hi @dublove, this will do it.

- Mark

 

Screenshot 2025-07-18 at 18.36.06.png

/**
 * @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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 18, 2025 Jul 18, 2025

Hi  m1b.

Thank you very much.

 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2025 Jul 18, 2025

I have updated. 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 18, 2025 Jul 18, 2025

Thank you very much.
Very good study material.

 

Help me out, originally you wrote to convert selected rows to table headers and I am trying to duplicate the table headers.

I used the previous method of duplicating rows.
I found that when there is a spanning of rows or columns, it reports an error.

 

I see that you wrote specifically about solving cross rows and columns, but I can't quite read it..
Thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 18, 2025 Jul 18, 2025

Is there any way to set a shortcut for NewStyle?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2025 Jul 18, 2025

Not that I know of.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 18, 2025 Jul 18, 2025

There really isn't any information about it yet.
Probably no way to judge the conflict

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 30, 2025 Sep 30, 2025

@m1b @leo.r 

Take a look for me—I added a new group.
It's no longer based on “trueNone,” and I selected three additional items.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 30, 2025 Sep 30, 2025

@m1b 

After adding a new group,
the newly created style ABC is no longer based on “trueNone”.

I've been working on this for ages and still can't figure out what's wrong.

abc.png

var sL = newObjStyle(app.activeDocument, "ABC", emptyStyle, "Group");
/**
 * Returns an object style named `name`, or if it
 * doesn't exist, returns an empty style.
 * @author m1b
 * @version 2025-07-18
 * @param {Document} doc - an Indesign document.
 * @param {String} name - the style's name.
 * @param {ObjectStyle} parentObjectStyle - the style to base the new style on.
 * @returns {ObjectStyle}
 */
//CreatObj
var d = app.activeDocument;
var emptyStyle = newObjStyle(d, 'trueNone');

function newObjStyle(d, n, parentObjectStyle, g) {
    if (g != null) {
        var group = d.objectStyleGroups.itemByName(g);
        if (!group.isValid)
            group = d.objectStyleGroups.add({ name: g })
        if (!group.objectStyles.itemByName(n).isValid)
            group.objectStyles.add({ name: n });
    }
    if (d.objectStyles.itemByName(n).isValid) {
        return d.objectStyles.itemByName(n);
    } else {
        var style = getThing(d.allObjectStyles, 'name', n);
        if (style)
            return style;
        style = d.objectStyles.add({
            name: n,
            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 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];

};

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 30, 2025 Sep 30, 2025

@dublove  I have updated the script above to show creating an object style inside an existing group.

- Mark

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 30, 2025 Sep 30, 2025

Also there is a mistake in your code (maybe just when pasting here on forum?) where you create `sL` before creating `emptyStyle`. That would explain why you aren't getting a proper empty style as a result.

- Mark

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 30, 2025 Sep 30, 2025

@m1b 

I messed up my original code.
Do I need to manually create My Group?

Thank you very much.

 

dublove_0-1759284286806.jpeg

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 30, 2025 Sep 30, 2025

@dublove I have updated the script above to create the object style group if it is missing. - Mark

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 02, 2025 Oct 02, 2025

Hi@m1b 

You've just created a new style called "NewStyle".

var newStyle = makeObjectStyle(styleGroup, ‘NewStyle’, emptyStyle);


and set one or two properties for it.
Then create NewStyle2 based on NewStyle. Try it out and see if NewStyle2 inherits any settings from NewStyle.

I tried it, and it doesn't work.
You need to reset the base style, but I'm not sure how to implement that step.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 02, 2025 Oct 02, 2025
LATEST

It seems that using `basedOn` doesn't always work. I've now adopted the approach of copying to get the second style, which has resolved the issue.

 

https://community.adobe.com/t5/indesign-discussions/problem-created-quot-basedon-quot-object-styles-...

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines