Skip to main content
any2cards
Known Participant
September 15, 2021
Answered

Script to convert all master page's background images properties-covert shape-rectangles

  • September 15, 2021
  • 1 reply
  • 483 views

I have an inDesign indd file that contains thousands of individual pages, that all inherit specific details from approximately 100+ master pages.  By default, all of the master pages have a background image that is the exact size of the page, and has rounded rectangles.

 

I am trying to find a way to write a script that will change all of the master page's background images from rounded rectangles to rectangles, which in turn should make all of the pages that inherit from them change.

 

Obviously, doing this one by one is easy enough, especially if there are only one or two master pages.  By I have some files that have hundreds of master pages.

 

I have written plenty of scripts in the past that affect my normal pages, but I can't find anyway to automatically change master pages.

 

I tried using find-change queries, but while they can make these kinds of changes on the normal pages, they end up changing ALL objects from rounded rectangles to rectangles, where I only want ONE specific object changed. This is why I am trying to get it to work for master pages, as there is ONLY ONE object that would be changed.

 

Any insight would be appreciated.

This topic has been closed for replies.
Correct answer Mike Bro

I tried ROUNDED but it was not a supported method or property.  I can't seem to find what is the proper value.


Hello @any2cards,

 

You can find the correct supported method and properties here..

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

you can try the snippet below....you'll just need to key in the correct value for the radius.

var amsr = app.documents[0].masterSpreads.everyItem().rectangles.everyItem();
amsr.bottomRightCornerOption = CornerOptions.ROUNDED_CORNER;
amsr.bottomRightCornerRadius = ".175"
amsr.bottomLeftCornerOption = CornerOptions.ROUNDED_CORNER;
amsr.bottomLeftCornerRadius = ".175"
amsr.topLeftCornerOption = CornerOptions.ROUNDED_CORNER;
amsr.topLeftCornerRadius = ".175"
amsr.topRightCornerOption = CornerOptions.ROUNDED_CORNER;
amsr.topRightCornerRadius = ".175"

 

Regards,

Mike

1 reply

brian_p_dts
Community Expert
Community Expert
September 15, 2021

Something like this would change all rectangles on all masters to have none corner options. If you need to target, then loop through amsr.getElements() to find the rectangles you need. 

 

 

var amsr = app.documents[0].masterSpreads.everyItem().rectangles.everyItem();
amsr.bottomRightCornerOption = CornerOptions.NONE;
amsr.bottomLeftCornerOption = CornerOptions.NONE;
amsr.topLeftCornerOption = CornerOptions.NONE;
amsr.topRightCornerOption = CornerOptions.NONE;

 

 

any2cards
any2cardsAuthor
Known Participant
September 15, 2021

First, thank you.  This worked perfectly !  Now, a followup question.  What is the effective opposite method?  In other words, rather than NONE, what can I use to get rounded rectangle back?  Thank you in advance for your help.  This is an immense timesaver for me !

any2cards
any2cardsAuthor
Known Participant
September 15, 2021

I tried ROUNDED but it was not a supported method or property.  I can't seem to find what is the proper value.