Copy link to clipboard
Copied
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:
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
And your fit content proportionally options are under the frameFittingOptions property. Actually study and test against thr API.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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:
There is very little information on setting the width in object styles.
The ObjectStyle class has textFramePreferences and textWrapPreferences
Copy link to clipboard
Copied
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];
};
Copy link to clipboard
Copied
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];
};
Copy link to clipboard
Copied
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
I want to set these items.
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
It turns out that:
os.enableTransformAttributes = true;
Copy link to clipboard
Copied
It turns out that FitOptions.PROPORTIONALLY is FRAME_TO_CONTENT.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
There is no TextWrapAndOthers property—you have to use the dictionary
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ObjectStyle.html
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Try os.anchoredObjectSettings.pinPosition = true
Copy link to clipboard
Copied
If 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...
Copy link to clipboard
Copied
Other information may be available and can be referenced from others.
However, there is very little information available on image width settings.
Copy link to clipboard
Copied
What is [AA]? var wn = [AA]; throws an error:
If it’s supposed to be an object style then it needs to be this:
Copy link to clipboard
Copied
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-...
Copy link to clipboard
Copied
Sorry, it should be “AA.”
That also throws an error—wn[i] returns the character A
Copy link to clipboard
Copied
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);
};
Copy link to clipboard
Copied
@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
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now