Copy link to clipboard
Copied
Hi everybody.
In a large document I like to let my script search for objects of the same kind. They should be found and pushed into a layer (I have to create).
My Idea was to search by the name or by the title of that object. It is an Illustrator-created-button. In the link-menue one can find those informations about. But how can I reach those information via script?
It doesn´t work with:
app.select(myDoc.pageItems.itemByName("object_name")
Any idea?
After a while, I resolved the problem by myself... that´s more interresting
...var myDoc = app.activeDocument,
myName="this is a name",
//myPages = myDoc.pages.everyItem(),
myLayers = myDoc.layers,
myRectangles = myDoc.rectangles;
app.doScript(selectObjects, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "moving things");
function selectObjects(){
if( !myDoc.layers.itemByName(myName).isValid ){
mySpecialLayer = myDoc.layers.add({name:myName, layerColor: UIColors.GOLD});
Copy link to clipboard
Copied
Given that myDoc is properly referenced and object_name the actual name of the item then there are no reason your commend wouldn't work to the exception of the forgotten closing parenthesis.
Copy link to clipboard
Copied
There is a closing parenthesis in the original script.
But I´m not sure "itemByName" means THAT name (from the meta-data)
Copy link to clipboard
Copied
After a while, I resolved the problem by myself... that´s more interresting
var myDoc = app.activeDocument,
myName="this is a name",
//myPages = myDoc.pages.everyItem(),
myLayers = myDoc.layers,
myRectangles = myDoc.rectangles;
app.doScript(selectObjects, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "moving things");
function selectObjects(){
if( !myDoc.layers.itemByName(myName).isValid ){
mySpecialLayer = myDoc.layers.add({name:myName, layerColor: UIColors.GOLD});
}
else{alert("There is already a level with the name.")};
for(var i=0;i<myRectangles.length;i++){
if(myRectangles.graphics.length == 1) {
if(myRectangles.graphics[0].itemLink.name == "Button1.ai" || myRectangles.graphics[0].itemLink.name == "Button2.eps"){
myRectangles.move(mySpecialLayer);
}
}
}
}
Voilá.