Forum Replies Created
-
Oleg Pirogov
February 12, 2019 at 3:59 am in reply to: Centering anchor point moves my element – Why?Is it just a naked Shape Layer with one Rectangle in it?
No whatever effects/expressions/parentings? -
In general, rotation and scale can be retrieved through observing the transformation of unit vector from child vector space to comp’s vector space.
I.e.:child = thisComp.layer("Child Layer")//unit vector projection
uVecProj = child.toComp([1,0])-child.toComp([0,0])//this gives Scale
scale = 100*length(uVecProj);//this gives Rotation angle in [0, 360] degree range
arcSin=Math.asin(length(cross(normalize(uVecProj), [1,0])))var angle = 0;
switch (arcSin>=0){
case true:
angle = radiansToDegrees(Math.acos(dot(normalize(uVecProj), [1,0])));
case false:
angle = radiansToDegrees(2*Math.PI - Math.acos(dot(normalize(uVecProj), [1,0])));
}angle;
On daily basis though, I would rather get Scale by manually multiplying consequent Scale transformations of a given parent-child structure and Rotation – by adding Rotation transformations.
Or just recreate the whole parent-child structure in another comp with nulls, directly linking nulls’ parameters to their prototypes’ parameters.
-
I see you’ve switched to AE CC 2019. Bear in mind that it has an updated expression engine and is much more strict on syntax and
I’ve only tested this code in previous versions. Though, I believe, I was careful with syntax, still some issues may rise when running this code in CC 2019. -
Oleg Pirogov
February 11, 2019 at 7:41 am in reply to: How to Animate a Slider with external Json file?My shot will be:
$.evalFile('PUT_YOUR_JSON_FILE_PATH_HERE');var dur = 0;
for (var i=0, len = arr.length; i
[This goes to slider property expression]
As I understand your data, IDs are points in time separated from each other by corresponding durations. So the expression sums consequent durations to find a pair of points in time a.k.a. IDs (namely ID i and ID i+1) between which the current time falls. Then it interpolates between slider values of those IDs, i.e. "plays all the numbers between 1,000-2,000 within four seconds and then gets to 2,000".
If current time is beyond the last ID, slider freezes at the slider value of the last ID (arr[len-1].slider).
The JSON file looks as follows:
var arr = [{"ID": 1, "slider": 1000, "duration": 4}, {"ID": 2, "slider":2000, "duration": 4}, {"ID": 3, "slider": 3000, "duration": 4}];Seems to work as intended.
-
Oleg Pirogov
February 11, 2019 at 6:12 am in reply to: Script runs a function that doesn’t exist anymoreI see… Great explanation, thank you!
-
Come to think of it, it’s a typical behavior for cross reference in expressions. Namely, the source rectangle not matching the source and strange bereavement fixed by cache cleaning.
All sorts of weird stuff can rise when you cross reference:

I just didn’t realize that simply mentioning sourceRectAtTime in Text Animator for position counts for cross reference. It totally makes sense though: Text Animators’ position does affect source rectangle (unlike transform.position) thus making reference to sourceRectAtTime a loop. -
The implementation is generally fine as is.
If you put the Rod layer (“FCU Interconnect Rod”) beneath the FCU arm layer, it will work like intended, as I presume:https://www.youtube.com/watch?v=ZLkF7eAffhw
Switching layers’ order is not a proper solution though, the problem is that you have a cross reference:
Rod -(expression)-> A
A -(child)-> FCU arm
FCU arm -(expression)-> C
C -(child) -> RodRod -(expression)-> A -(child)-> FCU arm -(expression)-> C -(child) -> Rod
In this case Gd only knows in what order AE will render and what output you’ll get.
If Rod is above FCU arm you get this:

If Rod is below FCU arm you (may) get:

The Rod image is in the right place but null and source rectangle are not.
This can be cured by cache cleaning but may also lead to various bugs in the future.Bottom line, you would probably wanna find another way to define the Rod length (maybe just a constant), thus breaking the reference loop at C-point. Namely, getting rid of this reference:
//point at which Rod is attached to Arm 1, parented to rod
null3Pos = rod.toWorld(thisComp.layer("Rod Point C").position);Some contents or functionalities here are not available due to your cookie preferences!This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.
-
It can be done with an iteration algorithm:
https://www.youtube.com/watch?v=5R-GqLtYOJ4In my implementation the rod is attached to Arms 1 and 2 at Nulls 1 and 2;
Arm 2 is Input.
Arm 1 is Fuel.This expression for Arm 1 Rotation approximates the Rotation Angle of Arm 1 till the distance between attachment points [almost] equals the length of the Rod:
//computes the difference between (target) Rod's length and a length you get when dependent Arm's rotation is alpha
var deltaRodLength = function(alpha){
//Arm 1 radius
R1 = thisComp.layer("Animation Controls").effect("D1")("Slider")/ 2;
arm1 = thisComp.layer("Arm 1");
arm2 = thisComp.layer("Arm 2");
//point at which Rode is attached to Arm 2
null2Pos = arm2.toWorld(thisComp.layer("Null 2").position);//Rode length
targetRodLength = thisComp.layer("Animation Controls").effect("Rod Length")("Slider");
currentRodLength = length([R1*Math.cos(alpha), -R1*Math.sin(alpha)]+arm1.position, null2Pos);return currentRodLength - targetRodLength;
}a = 0
b = Math.PI;
err = 0.001//iteration algo
i=0
while (Math.abs(deltaRodLength((a+b)/ 2)) >=err){
if (deltaRodLength((a+b)/ 2) > 0){b = (a+b)/ 2;}
if (deltaRodLength((a+b)/ 2) < 0){a = (a+b)/ 2;}
if (deltaRodLength((a+b)/ 2) == 0){
a = (a+b)/ 2;
b = (a+b)/ 2;
}//this prevents AE from freezing when no solution exists
i++;
if (i>200) {break;};
}-radiansToDegrees((a+b)/ 2);
Surprisingly neat expression.
Of cause, it can also been done with an explicit trigonometric formula for the Fuel Arm angle, but it’s quite hideous.Some contents or functionalities here are not available due to your cookie preferences!This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.
-
Oleg Pirogov
February 2, 2019 at 11:31 pm in reply to: Filter to convert RGB pure colors to custom ABC colors? -
I’ve written a script which does the thing for every selected property of shape type (i.e. select the shape path and run the script):
//the script smooths (sets interpolation to Auto Bezier) selected shape properties//smooths a shape path
function shapeSmoother(shape){
//create dummy composition and a text layer in it
var comp = app.project.items.addComp("Dummy", 100, 100, 1, 1, 1);
var pos = comp.layers.addText().transform.position;//create key frames in null position for every shape vertex
var newKey;
for (var i=0; i

