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

Find an Object by its name

Community Beginner ,
Oct 05, 2017 Oct 05, 2017

What is the easiest way to find an anchored object within the document. I this case I would like to find OB2 (the cyan square ) and hide it.

If you know an easy way of doing this I would be grateful for your help. I am using jsx.

Thank you : )

Geza

Capture.PNG

Capture2.PNG

TOPICS
Scripting
591
Translate
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

LEGEND , Oct 06, 2017 Oct 06, 2017

Hi,

Try this:

var myItems = app.activeDocument.allPageItems,  I = myItems.length;

while (I--) if (myItems.name == "OB2") myItems.visible = false;

(^/) 

Translate
Engaged ,
Oct 05, 2017 Oct 05, 2017

Hi,

Try this!!

app.activeDocument.layers.itemByName("OB2").visible=false;

Thanks

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
Translate
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
Community Beginner ,
Oct 06, 2017 Oct 06, 2017

Hi,

Thank you for this but it only works if the layer is on the very top of the hierarchy.

So in this case

app.activeDocument.layers.itemByName("OB2").visible=false

Will fail. Because for me app.activeDocument.layers.itemByName("OB2") returns an inValid layer.

This would work

app.activeDocument.layers.itemByName("Layer 1").visible=false

Because Layer 1 is on the very top.

So is there any way to find the OB1 or OB2. Or maybe I am doing something wrong  ?   : )

Thank you,

Geza

Translate
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
LEGEND ,
Oct 06, 2017 Oct 06, 2017

Hi,

Try this:

var myItems = app.activeDocument.allPageItems,  I = myItems.length;

while (I--) if (myItems.name == "OB2") myItems.visible = false;

(^/) 

Translate
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
Community Beginner ,
Oct 07, 2017 Oct 07, 2017
LATEST

Many Thanks! You saved me a lot of time.

Translate
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