Copy anchored object with specific object style to new layer
hi there
i'm new scripting , been trying adjust script below, without result.
this script found on indisnip:
var myitems = app.activedocument.allpageitems;
var mydoc = app.activedocument;
var foundobjects = array();
for(var = 0; < myitems.length; i++){
if(myitems[i].parent instanceof character){foundobjects.push(myitems[i]);}
}
if(foundobjects.length > 0){
try{var mydestlayer = mydoc.layers.add({name:"anchor/inline duplicates"});}
catch(_){mydestlayer = mydoc.layers.item("anchor/inline duplicates");}
for(var = 0; < foundobjects.length; i++){
var newduplicate = foundobjects[i].duplicate(mydestlayer);
newduplicate.geometricbounds = foundobjects[i].geometricbounds;
try{newduplicate.graphics[0].geometricbounds = foundobjects[i].graphics[0].geometricbounds;}catch(_){}
}
}
it copy's anchored items new layer 'anchor/inline duplicates'.
but want anchored objects specific object style copied. 'appliedobjectstyles.name == "os-name".
can me that?
thx
arne
(untested!) change lines iterate on found objects , add inline objects, starting @ line #5, following
for(var = 0; < myitems.length; i++){ if(myitems[i].appliedobjectstyle.name == "os-name" && myitems[i].parent instanceof character){foundobjects.push(myitems[i]);} }
-- if-clause has been changed here; second line added.
to highlight code in post, can use "advanced" editor, can apply syntax hi-lighting. makes javascript ever more readable
More discussions in InDesign Scripting
adobe
Comments
Post a Comment