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
}
}
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
Copy link to clipboard
Copied
It's C#.
Thanks! Gonna give it a try to translate that into C# code.
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…
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
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…
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.
Copy link to clipboard
Copied
I think you can do that… I unlocked and made visible all parents outlined then put back… was a while back fuzzy memory…