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

loop through layers and determine if its a text containing layer

New Here ,
Aug 21, 2012 Aug 21, 2012

Copy link to clipboard

Copied

Hi,

I am trying to loop/iterate through all layers, determine if it's a "text-layer", if it is, set it's opacity to 0.

This is what I have so far:

var iapp = new Illustrator.Application();

var openoptions = new Illustrator.OpenOptions();

var idoc = iapp.Open("c:\\myFile.pdf", Illustrator.AiDocumentColorSpace.aiDocumentRGBColor, openoptions);

Illustrator.Layer mainlayer = idoc.Layers["Layer 1"];

foreach (Illustrator.GroupItem groupitem in idoc.GroupItems)
{
foreach (Illustrator.GroupItem item in groupitem.GroupItems)
{
/* determine here if its a textlayer */
if( ... ) // (item.TextFrames.Count > 0) perhaps?
{
item.Opacity = 0;
}

//item.Opacity = 15; //this indeed sets the layer opacity 15
}

}

TOPICS
Scripting

Views

2.4K

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
Adobe
Guru ,
Aug 21, 2012 Aug 21, 2012

Copy link to clipboard

Copied

Is that VB? Does your soloution need to be too?

#target illustrator

textLayersOff();

function textLayersOff() {

          var doc = app.activeDocument;

          for ( var i = 0; i < doc.layers.length; i++ ) {

                    if ( doc.layers.textFrames.length > 0 ) { doc.layers.opacity = 0; };

          };

};

This would check for text frames NOT their content… if any

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
New Here ,
Aug 21, 2012 Aug 21, 2012

Copy link to clipboard

Copied

It's C#.

Thanks! Gonna give it a try to translate that into C# code.

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
Guru ,
Aug 21, 2012 Aug 21, 2012

Copy link to clipboard

Copied

As is… it ONLY looks for text frames at top level layer… if you have text in groups these can be endless so you would need recurse any such items…

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
New Here ,
Aug 22, 2012 Aug 22, 2012

Copy link to clipboard

Copied

Hi Mark,

Thanks. Your response was helpful. Though, can you show me how to write a recursive loop, so it checks any layers for groups and it's underlaying items?

Regards

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
Guru ,
Aug 22, 2012 Aug 22, 2012

Copy link to clipboard

Copied

I posted a text outlining script in this forum some time back… It mines all layers/sub-layers/groups… Search resurse and you should find it…

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
Enthusiast ,
Aug 22, 2012 Aug 22, 2012

Copy link to clipboard

Copied

Why not direcrly loop through all textFrames, check it's parent: 1)layer -- that's OK, 2)groupItem -- get the groupItem.layer,

then set the layer's opacity.

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
Guru ,
Aug 22, 2012 Aug 22, 2012

Copy link to clipboard

Copied

LATEST

I think you can do that… I unlocked and made visible all parents outlined then put back… was a while back fuzzy memory…

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