FORUMS: list search recent posts

Hide layer with conditional in script

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Rainier Raydán
Hide layer with conditional in script
on Apr 30, 2017 at 5:31:14 pm

Hi 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!


Return to posts index

Walter Soyka
Re: Hide layer with conditional in script
on May 1, 2017 at 9:19:44 am

There 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 [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Rainier Raydán
Re: Hide layer with conditional in script
on May 1, 2017 at 1:29:32 pm

Thanks 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?


Return to posts index


Walter Soyka
Re: Hide layer with conditional in script
on May 1, 2017 at 1:33:21 pm

Forget 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 [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Rainier Raydán
Re: Hide layer with conditional in script
on May 1, 2017 at 1:45:39 pm

Sorry 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...


Return to posts index

Rainier Raydán
Re: Hide layer with conditional in script
on May 1, 2017 at 1:47:59 pm

Oh I see. I dont need the conditional! Excellent! thanks fior the help! It was really helpfull :)


Return to posts index


Rainier Raydán
Re: Hide layer with conditional in script
on May 1, 2017 at 2:21:46 pm

Ok, 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?


Return to posts index

Rainier Raydán
Re: Hide layer with conditional in script
on May 1, 2017 at 9:18:46 pm

Ok, 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!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]