ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Referencing a file through 2 layers of Scripts in After Effects

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Inch BunmiReferencing a file through 2 layers of Scripts in After Effects
by on Jul 28, 2015 at 11:58:26 am

Hi Guys,

I am having an issue referencing a file through 2 AE scripts. Here is what I mean:

Script1 (The actual Script that you run):
scriptFile = new File("C:/Scripts/Script2.jsx");
$.evalFile(scriptFile);

Script2:
//Create Null//
var myNull = curItem.layers.addNull(curItem.duration);
myNull.name = "Scale_Null";
//Change Null Scale to an Expression//
var ActionFile = File("Scale.js");
var ActionFileText = ActionFile.open("r");
var ActionFileTextRead = ActionFile.read();
curItem.layer("Scale_Null").scale.expression = ActionFileTextRead;

Scale.js:
A = thisComp.width;
[A, A];
_____________________________

What I want:
1. Script1 is supposed Launch Script2
2. Script2 is supposed to create a Null and then reference a .js file which will be used as the expression for the Null's scale.

Problem:
1. Script1 Launches Script 2 fine.
2. Script2 creates the null.
3. Script2 refuses to reference the .js file
4. BUT When I launch Script2 directly (bypassing script1), The .js file is referenced and then used as the Null's Expression.

Please Help


Return to posts index

Walter SoykaRe: Referencing a file through 2 layers of Scripts in After Effects
by on Jul 28, 2015 at 3:05:01 pm

Perhaps the working directory is different in these two cases? What is the path to Scale.js?

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Inch BunmiRe: Referencing a file through 2 layers of Scripts in After Effects
by on Jul 28, 2015 at 3:18:04 pm

I figured and solved the problem.

Script2 was missing a file location. So by adding "c:/Scripts/" to the Script2 file, I was able to direct the file referencing.

*All 3 files (Script1, Script2 & Scale.js) are placed in the same directory.

Thank you for the response.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]