Copy link to clipboard
Copied
Hi,
Just ran through probably 4th session with the AI to try to solve this issue, but "we" just can not solve it.
I have a shape layer path that defines a frontline on a battle map. It is defined by even hundreds of individual vertices and some keyframes that then shows frontline changes through time.
There are days where the frontline on the battle map does not change, even though in reality it does. So I have the vertices and keyframes defined on those static days without any changes, with the same value. What my goal is, is to use an expression (or a script?) to have it "ignore" the keyframes where there are no vertice movements, and get it to basically skip showing static vertices (with same values) on neighboring keyframes, and link vertices only with the next vertice that has a change in its value. So to have a continual and smooth animation.
Assuming I explained this well, is this something that AE can achieve via expressions/scripts, or does something like that have to be done manually?
Thank you,
Copy link to clipboard
Copied
like this?
Duplicate_Keyframe_Remover.jsx
(function(thisObj) {
buildUI(thisObj);
function buildUI(thisObj) {
var palette = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Duplicate Keyframe Remover", undefined, {
resizeable: true
});
palette.orientation = "column";
palette.alignChildren = ["left", "top"];
var button1 = palette.add("button");
button1.text = "Clean Keyframes";
if (palette instanceof Window) {
palette.center();
palette.show();
}
else {
palette.layout.layout(true);
palette.layout.resize();
}
button1.onClick = function() {
app.beginUndoGroup("undo");
var proj = app.project;
var thisComp = proj.activeItem;
var selectedLayers = thisComp.selectedLayers;
for (var i = 0; i < selectedLayers.length; i++) {
for (var j = 0; j < selectedLayers[i].selectedProperties.length; j++) {
var prop = selectedLayers[i].selectedProperties[j];
if(prop.numKeys > 1){
for(var k = prop.numKeys; k > 1; k--){
if(JSON.stringify(prop.keyValue(k)) == JSON.stringify(prop.keyValue(k-1))){
prop.removeKey(k)
}
}
}
}
}
app.endUndoGroup();
}
}
}
)(this);
Copy link to clipboard
Copied
Hi Airweb_AE,
That's quite an interesting script. Thank you very much for sending it. Unfortunately, my issue is more related to vertices which are fixed in a pair of keyframes, and which then in say a 3rd keyframe start moving. Since this is the battle map, the frontline / vertices were actually moving the whole time. And my animation has a lot of such fixed vertices across the time period. Which I would now really love to see how it would all look if AE is actually able to link such vertices to the next vertice that has movement (which is sometimes a few keyframes away).
Either being the case, thanks a lot of the suggestion!
Copy link to clipboard
Copied
I'm not sure where you are going with this question. If you delete vertices, the whole transition between keyframes will be fouled up. If you have the wrong keyframe interpolation set up, you can get weird bounces between keyframes. This applies to vector paths, motion paths, and even color or opacity keyframes.
I haven't fiddled with an expression to look for vertices that don't change position between keyframes, but any expression that looks back at a position value for every vertex in a complex shape or mask path and then compares that with the position of every other vertex or point in the path is going to be very slow. Expressions don't remember what happened before the current frame; they have to look back one frame, then one more, then back again until they get to the start of the timeline. They become recursive and will slow down your render. I'm not as much of an expression expert as Dan Ebberts, but It would not surprise me that an expression that looks at a path with hundreds of points and tries to figure out which ones did not change position would slow down to a complete crawl in just a few frames. As far as I know, the only way to get the position of a path point is to implement the language generated by the Create Nulls from Paths script in the window menu. A path with 100 points would generate 100 null layers or require at least 100 look back lines of code for every vertex. Dan would know for sure, but I am pretty sure that this would be an insanely difficult and inefficient way to approach your workflow problem.
I have done hundreds of complex animated maps and chart illustrations with complex animated shapes and mask paths. I usually use Rotobezier paths instead of standard vertex paths because there are fewer handles to fiddle with. When I do that moving line animation, I almost always apply "Create Nulls from Paths/Points Follow Nulls" from the path at its most complicated shape. Then, I manually add position keyframes to the nulls. It usually does not take very many keyframes, and it's pretty easy to move the nulls around and even use parenting to simplify the animation workflow. I set up the keyframe interpolation methods to be linear. If I need to finess the timing, I pre-compose and apply time remapping instead of messing with easing or the Graph Editor on all those keyframed properties.
I hope this long-winded explanation helps you figure out an easier way to animate your battle lines.
Copy link to clipboard
Copied
Hi Rick,
Yes unfortunately I'm aware that deleting vertices is a no go for the idea. But you did get the right idea that I'm a newbie. I was just wondering if hence the system is able to skip to the next vertice if there is no movement. But I understand you that it would slow down the entire project.
So I understand you guys, this is the wrong approach. Thank you.
Also, interesting to hear how you were doing your map animations. I'm personally just making 2 PSD map layers, and then drawing the object / frontline path with a pencil between em, and then just pushing keyframes through time. No using of nulling, parenting or precomposing. It seems that I am doing it in the most pleb alike way. Neither of the things you've mentioned I've tackled with, or found ways to implement into my work flows.
Perhaps you will find the attached snapshot of one of my projects interesting:
I do feel like instead of using raw brain power to get through this, I am using raw finger muscle power instead.
Copy link to clipboard
Copied
You can fiddle with all sorts of nonsensical scripts like the one proposed or write complex and slow expressions, but ultimately it's a simple workflow problem. if something doesn't change, you isolate it on its own layer. AE is terrible with complex masks to begin with and it's far too easy to mess up things. Simply use multiple layers and patch your frontlines together.
Mylenium
Copy link to clipboard
Copied
Hey Mylenium 🙂
Yeah doing it with multiple layers seems to be near perfect. Adds dynamics in some ways as well. However, when I have multiple layers, and then frontline starts moving back (Ukraine conflict) then I have a total mess and multiple vertices / keyframes from multiple layers to pull back together. That is when I realize I must be doing this in a wrong way.. or hey the mess just comes with it of course.
Thanks,