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

How to add variable to property link

Explorer ,
Nov 11, 2022 Nov 11, 2022

Copy link to clipboard

Copied

I have a null, I'm going to call it null x.  Null x has 170 sliders which their values going from 0 to 1 and all staggered by 1 second.  

I have another null, which I shall call null y, which has a slider which holds a number.  This number is the slider I want to select from null x.  I need this selection to be placed on a opacity property of a layer.

Essentially I need to be able to change the value of the slider on null y which then offsets the animation of the opacity value fading by the value of the slider on null y in seconds (I hope that makes sense haha)

Basically I want to add a varialbe to a property path but I'm not sure how to.

TOPICS
Expressions , How to

Views

240

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

LEGEND , Nov 12, 2022 Nov 12, 2022

Here's some rudimentary code that works:

 

 

 

mPrefix="Slider ";

mRef=thisComp.layer("Reference");
mPick=thisLayer.effect("Slider Pick")("Slider");

mNum=Math.floor(mPick);

mRef.effect(mPrefix+mNum.toString())(1).value;

 

 

 

Note that there isn't any provision for safety measures and you have to dial in valid existing numbers or else it errors out. Change the layer names in the code as needed. As usual this could be expanded and refined in a million ways.

 

Mylenium

Votes

Translate

Translate
Community Expert ,
Nov 11, 2022 Nov 11, 2022

Copy link to clipboard

Copied

I think you might have to post some screen shots...

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
Explorer ,
Nov 12, 2022 Nov 12, 2022

Copy link to clipboard

Copied

LcDo7FKrep.png

The null on the left has 170 sliders (15 can only be seen but there are 170), they are all named as single numbers.  I would like to use the selected slider on the right null to select the corresponding slider on the left null and pug it into a opacity property of a layer.

It all needs to be done via expressions as the right slider will change 

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
Community Expert ,
Nov 12, 2022 Nov 12, 2022

Copy link to clipboard

Copied

LATEST

Basically, something like this, but it won't take into account which Sector slider you have selected (I'm not sure that was your intention)--you'd have to edit the first line to change that:

s = thisComp.layer("TimecodeValues").effect("Sector 1 Time (seconds)")("Slider");
v = thisComp.layer("AnimatorsFull").effect(Math.round(s))("Slider");

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
LEGEND ,
Nov 11, 2022 Nov 11, 2022

Copy link to clipboard

Copied

In the simplest case you would simply extract a number or such with some basic string processing. E.g. if the sliders have the number at the end it could be substr(-1, 1) for the single digit numbers. A regular expression filter would be similarly possible. All of that would run in a loop and when the numbers match - bam, the value of the respective slider is used. On my tablet right now and typing code would be awkward, but if Dan doesn't beat me to it I might be able to offer something more complete tomorrow when I'm back at the computer.

 

Mylenium 

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
LEGEND ,
Nov 12, 2022 Nov 12, 2022

Copy link to clipboard

Copied

Here's some rudimentary code that works:

 

 

 

mPrefix="Slider ";

mRef=thisComp.layer("Reference");
mPick=thisLayer.effect("Slider Pick")("Slider");

mNum=Math.floor(mPick);

mRef.effect(mPrefix+mNum.toString())(1).value;

 

 

 

Note that there isn't any provision for safety measures and you have to dial in valid existing numbers or else it errors out. Change the layer names in the code as needed. As usual this could be expanded and refined in a million ways.

 

Mylenium

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
Explorer ,
Nov 12, 2022 Nov 12, 2022

Copy link to clipboard

Copied

So there is no way of making it so you just need to edit the right slider? I will always need to edit the code?

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
LEGEND ,
Nov 12, 2022 Nov 12, 2022

Copy link to clipboard

Copied

You misunderstand. You can copy & paste this to all your layers as long as the names for the sliders match, which you only need to adjust ones before pasting it to your other layers. I'm still not really clear what you actually want, since you seem to want to blend between different values, which is a whole different exercise involving valueAtTime(). The code snippet of mine really only hard-sets one value of your 170 by dialing it in with a slider applied to the layer referencing a number.

 

Mylenium

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