0

I want to remove the overrides from master items, but just items in object style X, i wrote:

var doc = app.activeDocument;
var pgs = doc.pages;
for(i = 0; i<pgs.length; i++){
    pgs[i].removeOverride(doc.objectStyles.itemByName("myObject"))
}

And all overrides removed. how i do it? Thank in advance

ABE
  • 734
  • 2
  • 9
  • 21

2 Answers2

2

This is admittedly not very well documented in the InDesign Object Model, but using removeOverride() on a page (as you are doing) simply removes all overrides from all pageItems on that page. Also, removeOverride() does not take any arguments. Instead you could use it like this:

var pi = app.activeDocument.pageItems;
var myOS = app.activeDocument.objectStyles.item('myObject');
for(var i = 0; i < pageItems.length; i += 1) {
  if(pi[i].appliedObjectStyle === myOS) page[i].removeOverride();
}

This loops through all pageItems, checks each if it has the objectStyle and if so removes the override.

mdomino
  • 1,195
  • 1
  • 8
  • 22
0

var main = function() {
var doc = app.properties.activeDocument,
pis, pi;
if(!doc) return;
pis = doc.pageItems,
n = pis.length;
while ( n-- ) pis[n].overridden && pis[n].appliedObjectStyle.name=="myObject" && pis[n].removeOverride();
};

main();
Loic
  • 2,173
  • 10
  • 13
  • 1
    I assume you meant to write ```removeOverride()``` instead of ```remove()```, because then it would work. – mdomino May 26 '16 at 10:38