Skip to main content
Inspiring
June 17, 2022
Question

extendscript checkbox issue firing my code

  • June 17, 2022
  • 2 replies
  • 320 views

i have issue with my checkbox code firing part of my code take a look.

 

 

if you test it by clicking button on selected solid layer it will add element effect to it.

how ever am trying to use checkbox to enable option in element 3d.

fx.property("VIDEOCOPILOT 3DArray-1202").setValue(1);//Enable Fog

if i turn it on in checkbox one after effects freezez why

 

 

 

var dialog = new Window("dialog"); 
    dialog.text = "Dialog"; 
    dialog.orientation = "column"; 
    dialog.alignChildren = ["center","top"]; 
    dialog.spacing = 10; 
    dialog.margins = 16; 

var checkbox1 = dialog.add("checkbox", undefined, undefined, {name: "checkbox1"}); 
    checkbox1.text = "Enable Fog"; 

var checkbox2 = dialog.add("checkbox", undefined, undefined, {name: "checkbox2"}); 
    checkbox2.text = "Checkbox"; 

var checkbox3 = dialog.add("checkbox", undefined, undefined, {name: "checkbox3"}); 
    checkbox3.text = "Checkbox"; 

var checkbox4 = dialog.add("checkbox", undefined, undefined, {name: "checkbox4"}); 
    checkbox4.text = "Checkbox"; 

var checkbox5 = dialog.add("checkbox", undefined, undefined, {name: "checkbox5"}); 
    checkbox5.text = "Checkbox"; 

var button1 = dialog.add("button", undefined, undefined, {name: "button1"}); 
    button1.text = "Button"; 
    
button1.onClick = function () {
    

    function setFx(lyr)
{
      var eg = lyr.property("ADBE Effect Parade");
 var fx = eg.addProperty("VIDEOCOPILOT 3DArray"); 

	fx.name = "Element"
	fx.enabled = true;
// Element/Scene Settings This property cannot be Scripted!


}

    
    
 if (checkbox1.value == true) {

//           alert ("checkbox1");
     //  fx.property("VIDEOCOPILOT 3DArray-1202").setValue(1);//Enable Fog
}else  if (checkbox2.value == true) {
    alert ("checkbox2");
}else  if (checkbox3.value == true) {
    alert ("checkbox3");
}else  if (checkbox4.value == true) {
    alert ("checkbox4");
}else  if (checkbox5.value == true) {
    alert ("checkbox5");
} else {
//       alert ("na");
}

if ( app.project.activeItem instanceof CompItem) {
	var sl = app.project.activeItem.selectedLayers;
	if ( sl.length>0){
		setFx(sl[0]);
	}
}


}
dialog.show();

 

This topic has been closed for replies.

2 replies

Inspiring
June 17, 2022

one issue only one option works not the selected options

 if (checkbox1.value == true) {

//           alert ("checkbox1");
 fx.property("VIDEOCOPILOT 3DArray-1202").setValue(1);//Enable Fog
}else  if (checkbox2.value == true) {
  //  alert ("checkbox2");
    fx.property("VIDEOCOPILOT 3DArray-1458").setValue(2000000);//Camera Far Plane
}else  if (checkbox3.value == true) {
    alert ("checkbox3");
}else  if (checkbox4.value == true) {
    alert ("checkbox4");
}else  if (checkbox5.value == true) {
    alert ("checkbox5");
} else {
//       alert ("na");
}
}
Inspiring
June 18, 2022

only one value from checkbox gets added when checked why isn't others being added

 if (checkbox1.value == true) {

//           alert ("checkbox1");
 fx.property("VIDEOCOPILOT 3DArray-1202").setValue(1);//Enable Fog
}else  if (checkbox2.value == true) {
  //  alert ("checkbox2");
    fx.property("VIDEOCOPILOT 3DArray-1458").setValue(2000000);//Camera Far Plane
}else  if (checkbox3.value == true) {
    alert ("checkbox3");
}else  if (checkbox4.value == true) {
    alert ("checkbox4");
}else  if (checkbox5.value == true) {
    alert ("checkbox5");
} else {
//       alert ("na");
}
}
Dan Ebberts
Community Expert
Community Expert
June 18, 2022

It sounds like maybe you just need a bunch of if statements, rather than a cascading if/else, like this:

if (checkbox1.value == true) {
	// checkbox 1 code
}
if (checkbox2.value == true) {
	// checkbox 2 code
}
if (checkbox3.value == true) {
	// checkbox 3 code
}
// etc.

 

Inspiring
June 17, 2022

delete this post sorry fixed