Quantcast
Channel: Adobe Community : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 238792

Activating object layers basing on document layers

$
0
0

Hello,

I have a series of Illustrator files placed on different layers in an Indesign document.

I would like to set the visibility of the layers contained in the Illustrator files basing on the name of the Indesign layers to which they belong (Eg.: I want to activate only the "ES", "quote", and "disegno" layers in my Illustrator file if this one is on the "ES" layer of my Indesign file).

 

Here is my first attempt (which gives me an error):

 

var myDoc = app.activeDocument;
var totRectangles = myDoc.rectangles;


for(i=0; i<totRectangles.length; i++){
var myRectangle = totRectangles[i];
var myRectangleLevel = myRectangle.itemLayer.name; // the name of the Indesign's layer to which the rectangle belongs

 

var totGraphics = myRectangle.allGraphics;

 

for(k=0; k<totGraphics.length; k++){
  var myGraphic = totGraphics[k];

 

  if(myGraphic.imageTypeName == "Adobe PDF"){
   var myGraphicLayers = myGraphic.graphicLayerOptions.graphicLayers; // the layers of the Illustrator file

 

   for(j=0; j<myGraphicLayers.length; j++){
    var myGraphicLayer = myGraphicLayers.item(j).name; // the name of the current Illustrator's layer

 

    if(myRectangleLevel = "ES"){
     switch(myGraphicLayer){
      case "PT":
       myGraphicLayers.item(j).currentVisibility = false;
       break;
      case "ES":
       myGraphicLayers.item(j).currentVisibility = true;
       break;
      case "DE":
       myGraphicLayers.item(j).currentVisibility = false;
       break;
      case "FR":
       myGraphicLayers.item(j).currentVisibility = false;
       break;
      case "EN":
       myGraphicLayers.item(j).currentVisibility = false;
       break;
      case "IT":
       myGraphicLayers.item(j).currentVisibility = false;
       break;
      case "quote":
       myGraphicLayers.item(j).currentVisibility = true;
       break;
      case "Disegno":
       myGraphicLayers.item(j).currentVisibility = true;
       break;
     }
    }
   }
  }
}
}

 

I think the script is someway conceptually correct, but there has to be something wrong, as it doesn't work..

 

Any help would be much appreciated

 

Thanks in advance


Viewing all articles
Browse latest Browse all 238792

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>