• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Find objects by title/name

Engaged ,
Jun 13, 2017 Jun 13, 2017

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?

TOPICS
Scripting

Views

1.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Jun 13, 2017 Jun 13, 2017

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});

         

...

Votes

Translate

Translate
Participant ,
Jun 13, 2017 Jun 13, 2017

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 13, 2017 Jun 13, 2017

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 13, 2017 Jun 13, 2017

Copy link to clipboard

Copied

LATEST

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á.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines