Copy anchored object with specific object style to new layer
Hi there
i'm new to scripting and been trying to adjust the script below, but without result.
This script i found on Indisnip:
var myItems = app.activeDocument.allPageItems;
var myDoc = app.activeDocument;
var foundObjects = Array();
for(var i = 0; i < myItems.length; i++){
if(myItems.parent instanceof Character){foundObjects.push(myItems);}
}
if(foundObjects.length > 0){
try{var myDestLayer = myDoc.layers.add({name:"Anchor/Inline Duplicates"});}
catch(_){myDestLayer = myDoc.layers.item("Anchor/Inline Duplicates");}
for(var i = 0; i < foundObjects.length; i++){
var newDuplicate = foundObjects.duplicate(myDestLayer);
newDuplicate.geometricBounds = foundObjects.geometricBounds;
try{newDuplicate.graphics[0].geometricBounds = foundObjects.graphics[0].geometricBounds;}catch(_){}
}
}
It copy's all the anchored items to a new layer 'Anchor/Inline Duplicates'.
But i only want the anchored objects with a specific object style to be copied. Something like 'appliedObjectStyles.name == "OS-name".
Can someone help me with that?
thx
Arne