• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help with modifying previous code from Dan Ebberts

Engaged ,
Apr 24, 2023 Apr 24, 2023

Copy link to clipboard

Copied

@Dan Ebberts I have to call on your expertise again. Remember when we came up with this:

L = thisComp.layer("Dropdown Menu");
menu = L.effect("Dropdown Menu Control")("Menu");
moveTime = thisComp.layer("Shape Dynamics").effect("Transition Duration (SS)")("Slider");
temp1 = " " + thisProperty.propertyGroup(1).name;
val = value;
if (menu.numKeys > 0){
  n = menu.nearestKey(time).index;
  if (time < menu.key(n).time) n--;
  if (n < 2){
    L1name = L.text.sourceText.valueAtTime(menu.key(1).time);
    val = thisComp.layer(L1name).effect(name + temp1)("Slider").value;
  }else{
    t = menu.key(n).time;
    L1name = L.text.sourceText.valueAtTime(menu.key(n-1).time);
    v1 = thisComp.layer(L1name).effect(name + temp1)("Slider").value;
    L2name = L.text.sourceText.valueAtTime(menu.key(n).time);
    v2 = thisComp.layer(L2name).effect(name + temp1)("Slider").value;
    val = ease(time,t,t + moveTime,v1,v2);
  }
}
val

 This worked flawlessly to help us use a dropdown menu to govern certain shape changes, and animate them according to a duration I specified.

Now I need to do something slightly different. In the original comp, all the shape dynamics were stored on individual layers in the same comp as the dropdown menu. Now, I have need of non-animated versions of a number of shots, and to do that I need to move the layers with the positions and sizes into a master comp (some later steps will depend on this; the idea is to move the calculations into a single place where all comps can call upon them).

The problem is, no matter how I try to tweak this, it gives me errors. Basically I need this expression to do the exact same thing we set it up to do, but instead of looking in thisComp for a layer name matching the value of the dropdown, I need it to look in comp("_Master Layouts").

I've been trying to fix this for almost two hours and it's still having issues. Either it can't find a layer matching the value from the dropdown, or it can't find the dropdown itself, and I can't figure out what isn't working.

I've uploaded the comp in its original configuration and an alternate version with the setup I'm trying to get to. Can you help?

TOPICS
Error or problem , Expressions , FAQ

Views

358

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 24, 2023 Apr 24, 2023

What happens when you replace

thisComp.layer(L1name)

with

comp("_Master Layouts").layer(L1name)

and

thisComp.layer(L2name)

with

comp("_Master Layouts").layer(L2name)

?

Votes

Translate

Translate
Community Expert ,
Apr 24, 2023 Apr 24, 2023

Copy link to clipboard

Copied

What happens when you replace

thisComp.layer(L1name)

with

comp("_Master Layouts").layer(L1name)

and

thisComp.layer(L2name)

with

comp("_Master Layouts").layer(L2name)

?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 24, 2023 Apr 24, 2023

Copy link to clipboard

Copied

It says it can't find the dropdown menu:

 

Error.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 24, 2023 Apr 24, 2023

Copy link to clipboard

Copied

Alright, I've figured it out...we set up the dropdown source text like this:

 

 

var x = effect("Dropdown Menu Control")("Menu").value,
temp1 = 14;
titles = [thisComp.layer(index+temp1).name,
  thisComp.layer(index+temp1+1).name,
  thisComp.layer(index+temp1+2).name,
  thisComp.layer(index+temp1+3).name,
  thisComp.layer(index+temp1+4).name,
  thisComp.layer(index+temp1+5).name,
  thisComp.layer(index+temp1+6).name,
  thisComp.layer(index+temp1+7).name,
  thisComp.layer(index+temp1+8).name,
  thisComp.layer(index+temp1+9).name,
  thisComp.layer(index+temp1+10).name,
  thisComp.layer(index+temp1+11).name,
  thisComp.layer(index+temp1+12).name,
  thisComp.layer(index+temp1+13).name,
  thisComp.layer(index+temp1+14).name,
  thisComp.layer(index+temp1+15).name,
  thisComp.layer(index+temp1+16).name,
  thisComp.layer(index+temp1+17).name,
  thisComp.layer(index+temp1+18).name,
  thisComp.layer(index+temp1+19).name,
  thisComp.layer(index+temp1+20).name,
  thisComp.layer(index+temp1+21).name,
  thisComp.layer(index+temp1+22).name,
  thisComp.layer(index+temp1+23).name,
  thisComp.layer(index+temp1+24).name,
  thisComp.layer(index+temp1+25).name,
  thisComp.layer(index+temp1+26).name,
  thisComp.layer(index+temp1+27).name,
  thisComp.layer(index+temp1+28).name,
  thisComp.layer(index+temp1+29).name,
  thisComp.layer(index+temp1+30).name,
  thisComp.layer(index+temp1+31).name,
  thisComp.layer(index+temp1+32).name,
  thisComp.layer(index+temp1+33).name,
  thisComp.layer(index+temp1+34).name,
  thisComp.layer(index+temp1+35).name,
  thisComp.layer(index+temp1+36).name,
  thisComp.layer(index+temp1+37).name,
  thisComp.layer(index+temp1+38).name,
  thisComp.layer(index+temp1+39).name,
  thisComp.layer(index+temp1+40).name,
  thisComp.layer(index+temp1+41).name,
  thisComp.layer(index+temp1+42).name,
  thisComp.layer(index+temp1+43).name,
  thisComp.layer(index+temp1+44).name,
  thisComp.layer(index+temp1+45).name,
  thisComp.layer(index+temp1+46).name,
  thisComp.layer(index+temp1+47).name,
  thisComp.layer(index+temp1+48).name,
  thisComp.layer(index+temp1+49).name,
  thisComp.layer(index+temp1+50).name,
  thisComp.layer(index+temp1+51).name,
  thisComp.layer(index+temp1+52).name,
  thisComp.layer(index+temp1+53).name,
  thisComp.layer(index+temp1+54).name,
  thisComp.layer(index+temp1+55).name,
  thisComp.layer(index+temp1+56).name,
  thisComp.layer(index+temp1+57).name,
  thisComp.layer(index+temp1+58).name,
  thisComp.layer(index+temp1+59).name,
  thisComp.layer(index+temp1+60).name,
  thisComp.layer(index+temp1+61).name,
  thisComp.layer(index+temp1+62).name,
  thisComp.layer(index+temp1+63).name,
  thisComp.layer(index+temp1+64).name,
  thisComp.layer(index+temp1+65).name,
  thisComp.layer(index+temp1+66).name,
  thisComp.layer(index+temp1+67).name,
  thisComp.layer(index+temp1+68).name,
  thisComp.layer(index+temp1+69).name,
  thisComp.layer(index+temp1+70).name,
  thisComp.layer(index+temp1+71).name,
  thisComp.layer(index+temp1+72).name,
  thisComp.layer(index+temp1+73).name,
  thisComp.layer(index+temp1+74).name,
  thisComp.layer(index+temp1+75).name,
  thisComp.layer(index+temp1+76).name,
  thisComp.layer(index+temp1+77).name,
  thisComp.layer(index+temp1+78).name,
  thisComp.layer(index+temp1+79).name,
  thisComp.layer(index+temp1+80).name,
  thisComp.layer(index+temp1+81).name,
  thisComp.layer(index+temp1+82).name,
  thisComp.layer(index+temp1+83).name,
  thisComp.layer(index+temp1+84).name,
  thisComp.layer(index+temp1+85).name];
titles[x-1]

 

But now with all those layers gone, the dropdown doesn't have anything to pull from (or rather, it doesn't have the right layers, or enough of them, to pull from, hence the error). I'm going to try changing the relative references to the Master Layouts comp and see if that fixes the issue.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 24, 2023 Apr 24, 2023

Copy link to clipboard

Copied

As best I can tell what it's doing is pulling "Dropdown Menu" (as in the name of the layer) instead of the value of the dropdown menu, which makes no sense to me. I put this on its own text layer so I could see what value it was seeing:

 

L = thisComp.layer("Dropdown Menu");
menu = L.effect("Dropdown Menu Control")("Menu");
moveTime = comp("_Master Layouts").layer("Shape Dynamics").effect("Transition Duration (SS)")("Slider");
temp1 = " " + thisProperty.propertyGroup(1).name;
val = value;
L1name = L.text.sourceText.valueAtTime(menu.key(1).time);
//val = comp("_Master Layouts").layer(L1name).effect(name + temp1)("Slider").value;

L1name

 

"val" was returning the error, and L1name is pulling "Dropdown Menu" instead of what I have the dropdown set to.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 24, 2023 Apr 24, 2023

Copy link to clipboard

Copied

LATEST

Dan Hibberts does it again. With one single question you pointed me in a direction I hadn't considered before while banging my head on the desk. Thanks as always sir!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines