Skip to main content
Inspiring
September 20, 2021
Answered

DropDown Menu Control

  • September 20, 2021
  • 1 reply
  • 770 views

Multi question that im wrestling with.

I used to use the Layer control for scripots, i want to switch to dropdown menu.
I have a comp with 20 or so layers all named.

1. I want to populate the men u control with the layer names from a specific comp. Struggling?

2. Alot of my scripts use the layer control index to drive it. Is there a Drop Down Menu Control index aspect as well?

Thank you.

This topic has been closed for replies.
Correct answer threedeeNYC

Thank you. I was able to figure it out.
Just a few for loops making arrays then populating the array in the menu control. Similar to what you posted.

 

function makeMenuController(tComp, tLoc) {
  // makes the menu controller
  var myProj = app.project;
  var myComp = myProj.activeItem;
  var myLayer = myComp.selectedLayers[0];
  var itemCount = myProj.numItems;
  var mNames = new Array();
  var dropDownEffect = myLayer
    .property("ADBE Effect Parade")
    .addProperty("ADBE Dropdown Control");
  for (i = 1; i <= itemCount; i++) {
    curItem = myProj.item(i);
    if (curItem instanceof CompItem && curItem.name == tComp) {
      layerCount = curItem.numLayers;
      for (var l = 1; l <= layerCount; l++) {
        curLayer = curItem.layer(l);
        mNames[mNames.length] = curLayer.name;
      }
    }
  }
  dropDownEffect.property(1).setPropertyParameters(mNames);
}




1 reply

Justin Taylor-Hyper Brew
Community Expert
Community Expert
September 22, 2021

You're really better off sticking with layer controls as they're always updated with all your layers. I don't think you can edit Dropdown Menu Control optins with expressions, but you can with scripting:

 

const prop = app.project.activeItem.selectedProperties[0];
prop.menu.setPropertyParameters(["Sunday", "Monday", "Tuesday"]);

 

More details here: https://helpx.adobe.com/after-effects/using/create_dropdowns_using_expressions.html

threedeeNYCAuthorCorrect answer
Inspiring
September 22, 2021

Thank you. I was able to figure it out.
Just a few for loops making arrays then populating the array in the menu control. Similar to what you posted.

 

function makeMenuController(tComp, tLoc) {
  // makes the menu controller
  var myProj = app.project;
  var myComp = myProj.activeItem;
  var myLayer = myComp.selectedLayers[0];
  var itemCount = myProj.numItems;
  var mNames = new Array();
  var dropDownEffect = myLayer
    .property("ADBE Effect Parade")
    .addProperty("ADBE Dropdown Control");
  for (i = 1; i <= itemCount; i++) {
    curItem = myProj.item(i);
    if (curItem instanceof CompItem && curItem.name == tComp) {
      layerCount = curItem.numLayers;
      for (var l = 1; l <= layerCount; l++) {
        curLayer = curItem.layer(l);
        mNames[mNames.length] = curLayer.name;
      }
    }
  }
  dropDownEffect.property(1).setPropertyParameters(mNames);
}