Linking Layer visibility to a variable
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