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

Is it possible to use a global variable as the argument of the "footage" function?

Community Beginner ,
Nov 09, 2021 Nov 09, 2021

Hello, 

 

 I'm looking for a way how to use a global variable as the argument of the "footage" function. Not sure if it's possible at all. 

 

It should be simple, but it doesn't work for some reason:


var path = eval(thisComp.layer("GlobalFileName").text.sourceText)
footage(path).dataValue([1,1,0,15]) + (" Frames")

 

In this version, I'm getting the "Couldn't find footage named 'Text Property' " error... So, it looks like the "footage" function can't read the "path" variable. Or probably can't use the variables at all?  

 

But in this case, for example , it works just fine and I'm getting the proper text on the screen: 

var path = eval(thisComp.layer("GlobalFileName").text.sourceText)

path

 

Any ideas how to fix that? Need that for parsing a lot of json files... just want to implement some automation. 

 

Thank you,

Paul

 

 

TOPICS
Error or problem , Expressions , How to , Scripting , User interface or workspaces
216
Translate
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 Beginner , Nov 10, 2021 Nov 10, 2021

it works this way - 

 

path = thisComp.layer("Global_Text").text.sourceText.value
myFootage = footage(path);

footage(myFootage.name).dataValue([1,1,0,15]) + (" Frames")

 

Translate
Community Expert ,
Nov 09, 2021 Nov 09, 2021

Not sure exactly what you're trying to do, but you should be able to use a variable for the agrument to footage(), as long as it resloves to the name of a footage file already loaded into the project panel. For example, this simple sourcetext expression works if "drums.wav" has been imported:

path = "drums.wav";
myFootage = footage(path);
myFootage.name

 

Translate
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 Beginner ,
Nov 10, 2021 Nov 10, 2021

Thank you for the reply, but unfortunately your example not working as well in my case. Please take a look at the attachment. 

 

I want to use the sane "path" variable for a few different layers and expretions, but in terms of the same sequence. 

So, I'm trying get the name of the file from source text of the designated text layer (Global_Text layer at the example attached). 

 

Translate
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 10, 2021 Nov 10, 2021

Your code does not contain any proper string processing, so I'm not sure what you are hoping to do here. eval() simply returns an infinitely long unprocessed string that is treated as code that can be evaluated, but of course if it contains actual strings or URIs you have to isolate them from the rest and possibly account for operating system specific oddities like name handling, path delimiters and so on. You need to put in more effort and harden your code to make this work like adding toString() or decodeURI().

 

Mylenium

Translate
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 Beginner ,
Nov 10, 2021 Nov 10, 2021
LATEST

it works this way - 

 

path = thisComp.layer("Global_Text").text.sourceText.value
myFootage = footage(path);

footage(myFootage.name).dataValue([1,1,0,15]) + (" Frames")

 

Translate
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