Skip to main content
July 1, 2011
Question

Linking Layer visibility to a variable

  • July 1, 2011
  • 1 reply
  • 533 views

Hello,

I'm trying to add a new layer to a document and assign its visibility to a variable so that I can then create datasets with it. However after running the script below the visibility of the layer is not linked to the variable.

Could someone let me know whats wrong with the following code :

                // create the new layer
                 var newLayer = activeDocument.layers.add();
                 // rename the layer
                 newLayer.name = "testlayer";
                 // make layer visible           
                 newLayer.visible = true;

                // create the new variable
                var testVar = activeDocument.variables.add();
                // make the variable a visibility variable
                testVar.kind = VariableKind.VISIBILITY;
                // rename the variable
                testVar.name = "testVar";

               // assign the variable to the new layer
               newLayer.visibilityVariable = testVar;  

Thanks

This topic has been closed for replies.

1 reply

CarlosCanto
Community Expert
Community Expert
July 1, 2011

you can not assign variables to Layers, you're limited to pageItems