Copy link to clipboard
Copied
I realize these actions can be done manually, but I am trying to make one big script to run that makes multiple changes. I have found various scripts (mostly the included FindChangeByList) but have not been able to find/figure out scripts that will make the following two things happen:
1) find all instances in the document of ParagraphStyle "ParagraphStyleName" and change the justtification (for example, to Center or to Left).
2) find all instances in the document of Object Style "ObjectStyleName" and turn on the Text Box Auto-Size feature, specify anchor point of TopCenter, and turn on No Line Breaks.
Any ideas? Is this possible with scripting? I have tried having the FindChangeByList find one paragraph style and change it to another, but it either doesn't work or I'm doing something wrong. And from what I can tell FindChangeByList does not to objects.
The API is your friend: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ObjectStyle.html
Code based on your spec:
try { var doc = app.activeDocument; } catch(e) { exit(); }
var os = doc.objectStyles.itemByName("ObjectStyleName");
os.enableTextFrameAutoSizingOptions = true;
os.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_AND_WIDTH;
os.textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.TOP_CENTER_POINT;
os.textFramePreferences.useNoLineBreaksForA...
Copy link to clipboard
Copied
Hi @mgthomas82,
Do you want to change the paragraphstyle/objectstyle itself or you want to add those properties to the text/frame that has these styles applied? Both the cases seem to be doable using script, the first case should be fine with FindChangeByList, so please clarify what you need. A sample of what is needed in the form of sample document or annotated screenshot would also help.
-Manan
Copy link to clipboard
Copied
Thanks for the reply @Manan Joshi.
I have figured out the Paragraph Style part using the FindChangeByList. The only thing I havn't figured out yet is changing the object style. What I currently have is below. The last two will not be commented out in the final version. The blank line is where the Object Style change needs to go. If FindChangeByList worked for Objects, it would look something like this:
object {appliedObjectStyle:"TextFrame1"} {appliedObjectStyle:"TextFrame2"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Fix funky alignment issues.
I've tried about a dozen other "change object style" scripts I've found online and tried to alter them to fit my needs, but I can't get anything to work.
Copy link to clipboard
Copied
The API is your friend: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ObjectStyle.html
Code based on your spec:
try { var doc = app.activeDocument; } catch(e) { exit(); }
var os = doc.objectStyles.itemByName("ObjectStyleName");
os.enableTextFrameAutoSizingOptions = true;
os.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_AND_WIDTH;
os.textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.TOP_CENTER_POINT;
os.textFramePreferences.useNoLineBreaksForAutoSizing = true;
Copy link to clipboard
Copied
Works perfect! Thank you for your insight. This is my third day of delving into scripts for InDesign, and I've clearly got a lot to learn. That link appears to be an invaluable resource. Thank you!
Copy link to clipboard
Copied
It's a wild ride, but yes, the API link is invaluable. Lots of fun stuff to do. Enjoy the journey!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more