Activity › Forums › Adobe After Effects Expressions › Show or hide a layer in After Effects (Without using Opacity)
-
Show or hide a layer in After Effects (Without using Opacity)
Posted by Andy Troz on August 5, 2013 at 3:32 pmHello again!
Sorry for the constant questions, but is there a script or expression to show or hide a layer in After Effects (via the “eye” checkbox)?
Best,
Andy.Dan Ebberts replied 10 years, 5 months ago 3 Members · 7 Replies -
7 Replies
-
Dan Ebberts
August 5, 2013 at 5:29 pmYou can’t do it it with expressions, but with scripting it would be like this:
myLayer.enabled = false;
Dan
-
Geof Gagnon
March 13, 2016 at 6:40 amHey Dan, I’m currently having a problem and I can’t get this expression to work. My syntax is:
var path = "~/Desktop/fireball.png";var io = new ImportOptions(File(path));
if (io.canImportAs(ImportAsType.FOOTAGE)){
io.importAs = ImportAsType.FOOTAGE;
io.sequence = false;
io.forceAlphabetical = true;var sequence = app.project.importFile(io);
sequence.name = "importA";
}var myComp = null; // assume the worst
for (var i = 1; i <= app.project.numItems; i++){
if ((app.project.item(i).name == "importA")){
myComp = app.project.item(i);
break;
}
}
if (myComp != null){
app.project.activeItem.layers.add(myComp);}
no matter where I put the expression to disable the layer, it doesn’t seem to do it’s job. Any ideas? Thanks.
-
Dan Ebberts
March 13, 2016 at 7:47 amSorry–I’m confused. You mention an expression, but you posted a script. What is that you’re trying to do exactly?
Dan
-
Geof Gagnon
March 13, 2016 at 7:43 pmSorry, it’s actually a script. On button click I create a solid, add particle world to it, then import a png file, add it to the composition, and then I’d like to hide it. I believe the reference to the .png by the time it reaches the composition is myComp. But I’m unable to disable it.
-
Dan Ebberts
March 13, 2016 at 8:44 pmAh, OK–try this:
var myLayer = app.project.activeItem.layers.add(myComp);
myLayer.enabled = false;Dan
-
Geof Gagnon
March 13, 2016 at 8:49 pmWorked like a charm, you’re a king among men Dan.
If you don’t mind me asking, what was the problem? It just needed to be assigned to a variable? -
Dan Ebberts
March 13, 2016 at 9:34 pmActually, you could have done it in one step like this:
app.project.activeItem.layers.add(myComp).enabled = false;
which would create the layer and disabled it. The key is that you have to apply the .enabled = false to a layer object. I’d probably first put the layer object into a variable (like my example) and then disable it, just for clarity.
Dan
Reply to this Discussion! Login or Sign Up