Forum Replies Created
-
That is what I figured. I’ve had some luck using the comment
// cacheCompareSamplesPerSecond 0and adjusting the number. Making it 0 so it only runs the expressions once has definitely sped things up, though you give up flexibility. Hopefully Adobe will make expressions more effcient in some future release (ha ha) as I use them in almost all my projects. For anyone else wanting to improve performance I recommend reading about that comment here https://blogs.adobe.com/creativecloud/new-changed-after-effects-cc-2014/ -
Solved my own problem. For those who are interested you you will need to use toComp(). This converts the layer coordinates to the camera space coordinates. Then, given any z depth, the viewport position matches the pixel dimensions in your comp size. So, for example, if you are using a 1920×1080 comp, the x value of the left edge of the screen is always 0 and the y value of the right is always 1920, no matter what the z value is. I added a variable in my code to allow for objects with an anchor point slightly out of the viewport to still be visible.
ext = .2;
width = thisComp.width;
height = thisComp.height;
minWidth = 0 - (width * .2);
maxWidth = width + (width * .2);
minHeight = 0 - (height * .2);
maxHeight = height + (height * .2);
z = Math.ceil(Math.abs(toComp([1,1,1])[2]));
x = Math.ceil(toComp([1,1,1])[0]);
y = Math.ceil(toComp([1,1,1])[1]);
isInViewport = (x > minWidth && x < maxWidth) && (y > minHeight && y < maxHeight);isInFrontOfCamera = toCompVec([0, 0, 1])[2] > 0;
if (isInFrontOfCamera && isInViewport ) {
this.opacity = 100;
} else {
this.opacity = 0
}
-
Chad Specter
March 3, 2017 at 5:51 pm in reply to: Expression to switch to the next frame in a sequence at a random timeThanks! Worked like a charm. I made a couple changes so that it will loop through a certain number of frames, but otherwise that was it. Man. After Effects really needs some sort of Javascript console to more easily debug these expressions.
startFrame = 12;
totalFrames = 100;
minFrames = 100;
maxFrames = 150;
fCur = timeToFrames(time);
f0 = f1 = 0;
nextFrame = startFrame-1;
while (f1 <= fCur){
f0 = f1;
seedRandom(113 + f0,true);
f1 += Math.round(random(minFrames,maxFrames));
nextFrame = nextFrame+10;
if (nextFrame >= totalFrames) {nextFrame = nextFrame-totalFrames}
}
framesToTime(nextFrame); -
Chad Specter
January 10, 2013 at 3:40 pm in reply to: Looking for a script to replace text in text layers from a fileI ended up using a couple techniques. First I set up all the text using this method:
https://www.ryanragle.com/index.php?/site/comments/external_file_references_-_after_effects
A little funky, but it worked well in the end. I ended up with a text file that was pretty easy to change and I could hand that off to a producer to fill in all the new text.
Then I used this script to change out images in the project: https://www.digitaldistortion.net/resources/scripts/AE/DS_autoreplace_footage_from_folder.jsx
Basically I added an code to the beginning of each image I wanted to switch out, then you add that code to the beginning of the new images, you run the script and tell it to only look at the first X characters and it will automatically replace them in the project. Have to make sure the new images are the same pixel size as the old ones though. This was a little funkier to do as you have to go into the project, select images and run the script, but still faster than changing them out by hand.
Works like this:
Original images in project
ABCD1_old_image_name1
EFGH2_old_image_name2
IJKL3_old_image_name3
….Change to these images in a folder
ABCD1_new_image_name_1
EFGH2_new_image_name_2
IJKL3_new_image_name_3
…. -
Chad Specter
November 8, 2012 at 5:40 pm in reply to: Looking for a script to replace text in text layers from a fileYeah. I checked that one out. Close, but no cigar. It duplicated the comps you are targeting. My project is too complicated for that. I’d prefer to just replace the text is targeted layers.
This is promising: External File References – After Effects form Ryan Ragle. He created a way to set the path to a file in a project, then is referencing the file via expressions. A little clunky, since you need to set up the text in it’s own precomps, butI might try using his method. Though I still think a scripting solution would be better.