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

How to add some setting for the AA objectStyle?

Guide ,
Aug 11, 2025 Aug 11, 2025

I can't find the size settings.

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ObjectStyle.html

 

//Creat AA ObjectStyle
var wn = [AA];
for (var i = 0; i < wn.length; i++) {
    w = newObjStyle(app.activeDocument, wn[i], emptyStyle);
};

 

I want to set image size, frame,
fit content proportionally, position objects,  wrap text in the script.
Like this:

 

dublove_1-1754965116930.jpegdublove_2-1754965248569.jpegdublove_3-1754965322974.jpegdublove_4-1754965347394.jpeg

 

TOPICS
How to , Scripting
687
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

Guide , Aug 15, 2025 Aug 15, 2025

Hi @Manan Joshi 

Hi @rob day 

I searched for a long time and found that:
There is very little information on setting the width in object styles.
For example, I want to set the width of the “AA” object style to 42 mm.

 

Translate
Community Expert ,
Aug 12, 2025 Aug 12, 2025

If possible please do post screenshots in english as many of us can't read the language you post. Secondly you explain it in very few words so really difficult. However, I checked and maybe look into methods like setPositionAttributeState and setDimensionAttributeState

-Manan

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 ,
Aug 12, 2025 Aug 12, 2025

And your fit content proportionally options are under the frameFittingOptions property. Actually study and test against thr API. 

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 ,
Aug 15, 2025 Aug 15, 2025

Hi @Manan Joshi 

Hi @rob day 

I searched for a long time and found that:
There is very little information on setting the width in object styles.
For example, I want to set the width of the “AA” object style to 42 mm.

 

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 ,
Aug 15, 2025 Aug 15, 2025

Your code throws errors—in your newObjectStyle function the first parameter is doc, but in the first if statement you are using d. Change d to doc:

 

Screen Shot 8.png

 

 

 

 

 

 

There is very little information on setting the width in object styles.

 

The ObjectStyle class has textFramePreferences and textWrapPreferences

 

Screen Shot 6.png

 

 

 

Screen Shot 7.png

 

Screen Shot 9.png

 

 

 

 

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 ,
Aug 15, 2025 Aug 15, 2025

Hi @rob day 

I'm sorry.
I forgot to check. Take a look at this. 

/**
 * @file Make Object Style.js
 * @author m1b
 * @version 2025-07-18
 * @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
 */

var wn = ["AA"];
for (var i = 0; i < wn.length; i++) {
    w = newObjStyle(app.activeDocument, wn[i], emptyStyle);
};


//Make new objectStyle
var d = app.activeDocument;
var emptyStyle = newObjStyle(d, "trueNone");
function newObjStyle(d, n, parentObjectStyle) {
    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;
    };
};


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 ,
Aug 16, 2025 Aug 16, 2025

Set the textFramePreference properties for the AA objectStyle like this (you don’t need the for statement)

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#TextFramePreference.html#d1e307842

 

 

//make an object style named trueNone based on [None]
var tn = newObjStyle(app.activeDocument, "trueNone", "[None]");

//make an object style named AA based on the style named trueNone
var os = newObjStyle(app.activeDocument, "AA", tn)

//set the textFranePreference properties for AA
os.textFramePreferences.properties = {autoSizingType:AutoSizingTypeEnum.WIDTH_ONLY, useMinimumWidthForAutoSizing:true, minimumWidthForAutoSizing: 42}



function newObjStyle(d, n, parentObjectStyle) {
    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;
    };
};


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
Guide ,
Aug 16, 2025 Aug 16, 2025

Hi rob day.

It should not be “useMinimumWidthForAutoSizing”.

useMinimumWidthForAutoSizing

Maybe it is this:

setDimensionAttributeState

https://www.indesignjs.de/extendscriptAPI/indesign-latest/index.html#ObjectStyle.html

 

6-08.png

dublove_0-1755354305186.jpeg

I want to set these items.

09-08.png

 

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 ,
Aug 16, 2025 Aug 16, 2025

Looks likke you can set the position and dimension attributes, but i’m not seeing a way to set dimensions

 

//make an object style named trueNone based on [None]
var tn = newObjStyle(app.activeDocument, "trueNone", "[None]");

//make an object style named AA based on the style named trueNone
var os = newObjStyle(app.activeDocument, "AA", tn)
os.setPositionAttributeState (PositionAttributes.X_ATTRIBUTE, true);
os.setDimensionAttributeState (DimensionAttributes.WIDTH_ATTRIBUTE, true)
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 ,
Aug 16, 2025 Aug 16, 2025

I found this useful.

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#TransformAttributeOption.html

os.transformAttributeOptions.transformAttrWidth = 42;

But I don't know how to enable it.

08-10.png

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 ,
Aug 16, 2025 Aug 16, 2025

That is unusual—you have to run the 2 methods before setting the transformAttributeOptions

 

//make an object style named trueNone based on [None]
var tn = newObjStyle(app.activeDocument, "trueNone", "[None]");

//make an object style named AA based on the style named trueNone
var os = newObjStyle(app.activeDocument, "AA", tn)
os.setPositionAttributeState (PositionAttributes.X_ATTRIBUTE, true);
os.setDimensionAttributeState (DimensionAttributes.WIDTH_ATTRIBUTE, true)
os.transformAttributeOptions.transformAttrWidth = 42;
os.transformAttributeOptions.transformAttrX = 12;
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 ,
Aug 16, 2025 Aug 16, 2025

It turns out that:
os.enableTransformAttributes = true;

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 ,
Aug 16, 2025 Aug 16, 2025

It turns out that FitOptions.PROPORTIONALLY is FRAME_TO_CONTENT.

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 ,
Aug 17, 2025 Aug 17, 2025

Done, use this for text wrapping.
textWrapPreferences.textWrapOffset = [2, 5, 5, 5];
But I still feel that the writing style is not standard.
Could it be written from top to bottom, categorized separately?

os.TextWrapAndOthers.properties = {
TextWrapModes.BOUNDING_BOX_TEXT_WRAP;
textWrapOffset = [2, 5, 5, 5];
}

But, the name  "TextWrapAndOthers" seems incorrect.

 

Without knowing the standard names for each item in the object style, it is difficult to find useful information.

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 ,
Aug 17, 2025 Aug 17, 2025

There is no TextWrapAndOthers property—you have to use the dictionary

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ObjectStyle.html

 

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 ,
Aug 17, 2025 Aug 17, 2025

I couldn't find this item: Keep within the top and bottom boundaries of the column.
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#AnchoredObjectSetting.html

dublove_0-1755435363874.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 ,
Aug 17, 2025 Aug 17, 2025

Try os.anchoredObjectSettings.pinPosition = true

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 ,
Aug 17, 2025 Aug 17, 2025
LATEST
quoteIf true, pins the position of the anchored object within the text frame top and bottom.

 

I see.
So, what this means is that it is limited to the bounding box...

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 ,
Aug 16, 2025 Aug 16, 2025

Other information may be available and can be referenced from others.
However, there is very little information available on image width settings.

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 ,
Aug 12, 2025 Aug 12, 2025

What is [AA]? var wn = [AA]; throws an error:

 

Screen Shot 7.png

 

If it’s supposed to be an object style then it needs to be this:

 

var wn = app.activeDocument.objectStyles.itemByName("AA")
 
And if it is an object style there is nothing to loop thru object styles have no length property:
 
Screen Shot 8.png
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 ,
Aug 12, 2025 Aug 12, 2025

Hi rob day.

Sorry, it should be “AA.”

The original AA was read from my.json.
emptyStyle, refer to the information provided by m1b.
https://community.adobe.com/t5/indesign-discussions/how-to-create-new-object-styles-based-on-really-...

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 ,
Aug 12, 2025 Aug 12, 2025

Sorry, it should be “AA.”

 

That also throws an error—wn[i] returns the character A

 

Screen Shot 11.png

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 ,
Aug 12, 2025 Aug 12, 2025

It started out like this.
These are two variables that get strings from json.

I've abbreviated it here. It should be:
var wn = [“AA”];

var wn = [captionA,captionB];
for (var i = 0; i < wn.length; i++) {
    w = newObjStyle(app.activeDocument, wn[i], emptyStyle);
};
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 ,
Aug 12, 2025 Aug 12, 2025

@dublove it is very difficult to work with incomplete information. You should give us code snippets and screenshots that we can work with. Atleast try to abstract the problem so that someone can help you. You keep adding information like this came from JSON, it is abbreviated etc which does not make things better. Anyhow I and @brian_p_dts have given you some points on which methods/attributes might be of interest to you. Please try those and let us know if that does not work, with a sample code that you tested. Atleast we should have a piece of code that is able to get to the point where we are trying to set properties.

-Manan

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 ,
Aug 12, 2025 Aug 12, 2025

@Manan Joshi 

I haven't had a chance to look into it yet, but it should be possible to achieve what you described with setPositionAttributeState and setDimensionAttributeState.
I'll take a closer look at it later.
Thank you very much.

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