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

sourceRectAtTime not working in AE2025

New Here ,
Oct 29, 2024 Oct 29, 2024

Copy link to clipboard

Copied

We use sourceRectAtTime a lot for building mogrt's.
To make comps and shapes resize around text. images etc

// Get the first layer in the composition

var a = thisComp.layer(1).sourceRectAtTime();

// Width and height of the first layer

var width = a.width;

var height = a.height;


But in 2024 width and height are always 1000
tried:
sourceRectAtTime(time, false);
sourceRectAtTime(time, ture);


 also this is always 1000:
var layer = thisComp.layer(1);

var width = layer.width;

var height = layer.height;

Tried on multiple workstations here, mac and pc.

Also no new method in the  expression language reference
https://helpx.adobe.com/after-effects/using/expression-language-reference.html

When will this be fixed? It is quit essential for everybody making mogrts? 

Bug Unresolved
TOPICS
Expressions

Views

87

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
5 Comments
New Here ,
Oct 29, 2024 Oct 29, 2024

Copy link to clipboard

Copied

Found the problem!

width and height cannot be set in AE2025 (can in AE2024) renaming to w and h fixed the problem:

// Get the first layer in the composition

var a = thisComp.layer(1).sourceRectAtTime();

// Width and height of the first layer

var w = a.width;

var h = a.height;

 

Votes

Translate

Translate

Report

Report
Community Expert ,
Oct 29, 2024 Oct 29, 2024

Copy link to clipboard

Copied

It is a very bad idea to use a reserved word for a variable. I would rewrite your expression like this:

// Get the first layer in the composition
var a = thisComp.layer(1).sourceRectAtTime();
// Width and height of the first layer
var x = a.width;
var y = a.height;
[x, y]

 I did not run into any problems with any of my expressions using sourceRectAtTime in any of the recent builds of After Effects. 

Votes

Translate

Translate

Report

Report
New Here ,
Oct 29, 2024 Oct 29, 2024

Copy link to clipboard

Copied

I agree, lucky I have some programming background. That's why I came to the solusion. But tell that to chatGTP 😉
It's trained with all the tutorials from the last decade.

For a prompt like this:
need to get the width and height of this layer thisComp.layer(1) in after effects and add 10px to the width and height values. 

the answer is:

// Get the layer
var layer = thisComp.layer(1);

// Get the width and height by referencing the layer's sourceRectAtTime()
var width = layer.sourceRectAtTime(time, false).width;
var height = layer.sourceRectAtTime(time, false).height;

// Add 10 pixels to each dimension
var newWidth = width + 10;
var newHeight = height + 10;

// Calculate the position, based on the layer's current position
[layer.position[0] - newWidth / 2, layer.position[1] - newHeight / 2];

Votes

Translate

Translate

Report

Report
Community Expert ,
Oct 29, 2024 Oct 29, 2024

Copy link to clipboard

Copied

Percentage of efficient and reliably working After Effects expressions from AI resources: 10% on a good day.

Percentage of efficient and reliably working After Effects expressions when you study and practice using good Javascript workflows is 95%. We all make some mistakes sometimes.

 

ChatGTB and other AI platforms just scan a bunch of code written by anyone with any skills, and AI does not know what you are thinking. It might be a way to get some ideas, but I don't believe AI will ever replace a skilled technician, and AI can never produce art that comes from an artist's heart and soul. If AI ever replaces human creative thought, we will all be out of a job. The biggest danger to creative workflows and the value of our work is that clients will begin to accept AI-generated content because it is cheap and quick instead of looking for people who can tell their story effectively that resonates with the desired audience.

 

OK, I'm off my soap box now. I don't want to start an argument.

Votes

Translate

Translate

Report

Report
New Here ,
Oct 29, 2024 Oct 29, 2024

Copy link to clipboard

Copied

LATEST

Yes, but I have animators with NO programming experience.  Working with code is always a start. I agree that AI not the smartest at times. But animators are animators and not programmers.
Showing them to ask simple questions 
 

Votes

Translate

Translate

Report

Report