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

Global function working on normal render but not through aerender.exe

New Here ,
May 11, 2021 May 11, 2021

I have a global function in an expression that takes a text layer and autosizes it to fit a box. The expression works when I add to render queue in the program. However, when I send a .jsx file to aerender.exe with the same params, the global function is ignored. Any ideas why this happens?

Setup:

comp: // textConstrainer

.       text layer: // textConstrainer

.            expression on sourceText: $.textConstrainer = function (whichLayer) { code }

comp: Foo

.         text layer: sizeMe

.              expression on sourceText: $.textConstrainer(thisLayer)

 

TOPICS
Expressions
235
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
Valorous Hero ,
May 11, 2021 May 11, 2021

The text file containing the Global Function should be placed in the Comp(s) that you send for rendering outside of AE and this includes aerender.

Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
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
New Here ,
May 13, 2021 May 13, 2021
LATEST

If I have to put the code in every comp it would defeat my purpose for having a global expression.

The global function is below. I have 50 comps. Each comp is different animation and each animation has at least 1 text layer and a shape layer 'box'. This function tells the text layer to scale to fit inside the box. How would I be able to put this function in one place so its available to all comps? Right now it's in an expression on the sourcetext of an empty comp.

global is below and at this github gist. I'm surprised there's not a more robust code formater in text tools 

 

$.textConstrainer = function (whichLayer) {
if (whichLayer.hasParent) {
foundComp = whichLayer.parent;
}

layerName = whichLayer.name;


if (layerName.slice(-2) == "t1") {
target_box = "box1";
} else if (layerName.slice(-2) == "t2") {
target_box = "box2";
} else if (layerName.slice(0, 3) == "box") {
return 0;
}

var targetLayer = thisLayer.sourceRectAtTime(time);
var targetLayerWidth = targetLayer.width;
var targetLayerHeight = targetLayer.height;

var boxLayer = thisComp.layer(target_box.toString()).sourceRectAtTime(time);
var boxLayerWidth = boxLayer.width;
var boxLayerHeight = boxLayer.height

var ratioWidth = boxLayerWidth / targetLayerWidth;
var ratioHeight = boxLayerHeight / targetLayerHeight;

if (ratioHeight > ratioWidth) {
return [ratioWidth * 100, ratioWidth * 100];
} else if (ratioHeight < ratioWidth) {
return [ratioHeight * 100, ratioHeight * 100];
} else {
return value;
}

}

$.textConstrainer(thisLayer);

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