I find I need to jump to the next keyframe very often, instead of the next linked frame which I don’t want to change on that. I use SPACE key to go to the next frame, but it’s annoying to only get the next linked frame which I do not intend to change.
i hope i’m not wrong, but there’s no such function.
i looked into api thinking it could be added by script, but i don’t see any indication of specific cel being linked or not.
Based on my recent experience, that seems to be exactly the case. Linked cels have no “this is a linked cel” sort of associated metadata apparently.
I wrote this function for my own script (one part of which is to force relink cels after an import/tab merge) in case someone wants a starting place to write their own script.
--receives 2 cel objects, A and B, returns true if they look and have been set identically. advancedMatch is a boolean
function areCelsEqual(celA, celB, advancedMatch)
local celEquality = false
--do an "appeareance" check, i.e., same image, opacity setting, bounds
if (celA.image:isEqual(celB.image) == true and
celA.position == celB.position and
celA.opacity == celB.opacity and
celA.bounds == celB.bounds
)
then
celEquality = true
end
if(advancedMatch == true) then
--check other extra data like cel's UI color and metadata
if (celA.color ~= celB.color or celA.data ~= celB.data) then
celEquality = false
end
end
return celEquality
end
I ended up writing my script to do this job, and bind to “space” and “shift+space”:
local function reached_different_cel()
local current_frame = app.activeFrame.frameNumber
local prev_frame = current_frame - 1
if prev_frame == 0 then
prev_frame = #app.activeLayer.cels
end
return app.activeLayer:cel(current_frame).image ~= app.activeLayer:cel(prev_frame).image
end
local function jump_to_next_key_cel()
repeat
app.command.GotoNextFrame()
until(reached_different_cel())
end
jump_to_next_key_cel()
That’s pretty neat. One observation though which I don’t know if it could affect your script.
image
is basically the pixels drawn in that cel. As far as I know, it doesn’t take into consideration its position. This means you can have the exact same image in two different cels, but positioned in different coordinates. If the position
of that image object is different, this line below might consider those cels to be the exact same cel/image even though they are technically different.
return app.activeLayer:cel(current_frame).image ~= app.activeLayer:cel(prev_frame).image
Same applies to opacity and probably other attributes. Two cels can have the same image, and if their opacity is different (one is 100%, the other is 80%), the image object will still be considered to be the same, even though they would obviously look different.
Not 100% sure if any of the above affects your implementation or your workflow, but they could be edge cases that might make you go to the wrong keyframe. That would also depend on your definition of “keyframe”.