Blender wont update the viewport animation after manipulating keyframes

Hi im making a small set of operators which manipulate grease pencil keyframes positions (frame_number )

But i have a problem. After updating the frame_number of the keyframes , blender doesnt update the playback or anything really with these new values until i click somewhere or call a build in operator like G to move the keyframes.

Thats one of those quirks i cant solve with reading a python tutorial.
I there any way to reinitialize the data of an object, scene or whole blender ?

heres one of the classes i implemented:

1 Like

One thing you can try is changing modes, from the mode you are in to another mode, and, back to the original mode if necessary. Sometimes that will do the updates.

1 Like

yes thanx that was a hack i used before … toggling the .show_in_front attribute also worked … a little bit less invasive… but i think i now have the legit way :

for the gpobject.layers i use layer.frames.update()

folowing updating the 3d view

for win in
        for area in win.screen.areas:
            if area.type == 'VIEW_3D':

None of this works for me: changing the mode, .show_in_front, layer.frames.update(), or redrawing “VIEW_3D”. Does anyone have other ideas?

still working for me in blender 3.5

1 Like

Thank you for the reply and code example. I see that you are moving existing keyframes. In my case, I’m creating new keyframes using the GPencilFrames.copy() method. I believe something there isn’t right and is missing the update.

can you post your code somewhere?

Hello, yes, my code is in the post above “Updating Grease Pencil Data.”

Thank you so much for your replies about this issue. It’s okay though: I believe that this a bug from GPencilFrames.copy. If I create a new keyframe, then copy its attributes from the first keyframe instead of copying the first keyframe with GPencilFrames.copy, the data.layers.update works. :person_shrugging: Hopefully someone from the Grease Pencil team will look into it.

wouldnt get my hopes up for that

The bug report is barely a day old, give it time. Bugs usually get triaged within a week