Activity › Forums › Adobe After Effects › Hide layer with conditional in script
-
Hide layer with conditional in script
Posted by Rainier Raydán on April 30, 2017 at 5:31 pmHi guys. I’m traying to write an script for an AE project but I not able to make it work.
This is what I have:
var myComp = app.project.activeItem;
var hideLayerCtrl = myComp.layer(“Controller”).property(“ADBE Effect Parade”).property(“ADBE Checkbox Control”).property(“ADBE Checkbox Control-0001”);
if ((myComp.hideLayerCtrl == 1)) {
myComp.layer(“BG 1”).enabled = true;
}That’s not working for me… I already try app.project.activeItem.layer(“BG 1”).enabled = false; and it works but I want to use a conditional to make it work in a Null’s checkbox and then simply change the null’s effects path to one button in the script UI.
Can anybody help me?
Ty!
Rainier Raydán replied 9 years ago 2 Members · 7 Replies -
7 Replies
-
Walter Soyka
May 1, 2017 at 9:19 amThere are two errors here:
1) hideLayerCtrl as you declare it is its own object, not an attribute of myComp, so you should not refer to it as myComp.hideLayerCtrl
2) hideLayerCtrl is the checkbox object, not an integer or a Boolean value; to see whether the box is checked or not, you should test against hideLayerCtrl.value in your code instead.
Try this:
var myComp = app.project.activeItem;
var hideLayerCtrl = myComp.layer("Controller").property("ADBE Effect Parade").property("ADBE Checkbox Control").property("ADBE Checkbox Control-0001");
if (hideLayerCtrl.value == true) {
myComp.layer("BG 1").enabled = true;
}Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive | RenderBreak [blog] | Profile [LinkedIn] -
Rainier Raydán
May 1, 2017 at 1:29 pmThanks for the answer! I ‘ve try it and it works just when the checkbook is on. How can I add to the conditional so it can be hide when the checkbox is off and shows when the checkbox is on?
-
Walter Soyka
May 1, 2017 at 1:33 pmForget the conditional. Just set the layer’s enabled attribute to the checkbox’s value:
myComp.layer("BG 1").enabled = hideLayerCtrl.value;Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive | RenderBreak [blog] | Profile [LinkedIn] -
Rainier Raydán
May 1, 2017 at 1:45 pmSorry I didn’t catch you… I have to write this?
var myComp = app.project.activeItem;
var hideLayerCtrl = myComp.layer("Controller").property("ADBE Effect Parade").property("ADBE Checkbox Control").property("ADBE Checkbox Control-0001");
if (hideLayerCtrl.value == true) {
myComp.layer("BG 1").enabled = true;
myComp.layer("BG 1").enabled = hideLayerCtrl.value;}I guess not becouse its not working…
-
Rainier Raydán
May 1, 2017 at 1:47 pmOh I see. I dont need the conditional! Excellent! thanks fior the help! It was really helpfull 🙂
-
Rainier Raydán
May 1, 2017 at 2:21 pmOk, now I want that my dropdownlist sets the background of my composition. I have 3 layers, each one is a solid color (later on it will be other composition or a prerender background) and the idea is that when I choose one item in the dropdownlist one of the items shows and the other 2 hide.
This is what I have:
res = "group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
myGroup: Group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
myStaticText: StaticText{text:'StaticText Text'},\
myEditText: EditText{text:'EditText text'},\
},\
myDropDownList: DropDownList{properties:{items:['[ BACKGROUND ]', 'CYAN', 'AMARILLO', 'MAGENTA']}},\
},\
}"// Adds resource string to panel
myPanel.grp = myPanel.add(res);// DropDownList default selection
myPanel.grp.myDropDownList.selection = 0; /// Dropdown index starts at 0// Assign function to UI elements
Anyone can help me with this?
-
Rainier Raydán
May 1, 2017 at 9:18 pmOk, this is what I endup doing:
myPanel.grp.selectBtn.onClick = function() {var myComp = app.project.activeItem;
var hideLayerCtrl = myComp.layer("Controller").property("ADBE Effect Parade").property("ADBE Checkbox Control").property("ADBE Checkbox Control-0001");
if (myPanel.grp.myDropDownList.selection == 1){
myComp.layer("BG 1").enabled = true;
myComp.layer("BG 2").enabled = false;
myComp.layer("BG 3").enabled = false;
}
if(myPanel.grp.myDropDownList.selection == 2){
myComp.layer("BG 1").enabled = false;
myComp.layer("BG 2").enabled = true;
myComp.layer("BG 3").enabled = false;
}
if(myPanel.grp.myDropDownList.selection == 3){
myComp.layer("BG 1").enabled = false;
myComp.layer("BG 2").enabled = false;
myComp.layer("BG 3").enabled = true;
}
It works for me! I guess there is a better and clean way to do it but for me works.
Thanks!
Reply to this Discussion! Login or Sign Up