Bug 391666 - Python timeline/animation API
Summary: Python timeline/animation API
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Scripting (show other bugs)
Version: 4.0.0-beta.1
Platform: unspecified Unspecified
: NOR wishlist
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-10 15:01 UTC by Azure
Modified: 2018-10-29 15:04 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Azure 2018-03-10 15:01:08 UTC
During my testing of the new python scripting, I've found that there's almost no access to the timeline/animation in the API. Ideally, there would be at least methods for getting and setting the current time. 

The functionality of setting the time would be essentially the same as if you had dragged the playhead in the timeline docker, updating both the canvas and the timeline docker. It would also be nice if there were a time/frame change signal to be able to hook into. 

Example code:
document = Krita.instance().activeDocument()
document.currentTime()
document.setTime(10)

My use case:
I was attempting to make an X-sheet docker, which would essentially just be a table that allowed you to add notes to each frame, highlight the current frame you're on, and navigate to a frame directly from the table.
Comment 1 Halla Rempt 2018-04-02 13:43:49 UTC
Hi,

This does need to have a bit more detail before we can start implementing it.
Comment 2 Azure 2018-04-02 13:48:31 UTC
(In reply to Boudewijn Rempt from comment #1)
> Hi,
> 
> This does need to have a bit more detail before we can start implementing it.

What sort of details are needed? I wasn't quite sure what type of info to include initially.
Comment 3 Scott Petrovic 2018-04-16 21:13:30 UTC
I played around a bit with Python and animation and this is kind of where it stands with doing animation related things

You can access to see if a node (layer) has animation turned on. 
You can enable animation for the layer. Animation is off by default for a layer.

You can then use actions to do some animation functions

python stuff I did in the internal scripter...

import sys
from krita import *

for doc in Krita.instance().documents():
    print( doc.activeNode().animated())
    doc.activeNode().enableAnimation()

    # grab and call an existing action
    Krita.instance().action("next_frame").trigger()


...end python code

I think just about all the animation actions right now are in the krita.action file. There should be an "action" folder in your installation where you can see them all. They are just big XML files.

I don't see any actions with "go to frame #". There are a lot of actions with play/stop, previous/next frame, and inserting/deleting frames.
Comment 4 Scott Petrovic 2018-10-29 15:00:37 UTC
Git commit 79ecbca861dbddf370b25ec167050d71c55ec9d9 by Scott Petrovic.
Committed on 29/10/2018 at 15:00.
Pushed by scottpetrovic into branch 'master'.

Add animation Python API for many functions to Document class.

Also added a node API option for setting Use In Timeline

D16462

M  +107  -0    libs/libkis/Document.cpp
M  +79   -0    libs/libkis/Document.h
M  +12   -0    libs/libkis/Node.cpp
M  +12   -0    libs/libkis/Node.h
M  +2    -1    libs/ui/canvas/kis_animation_player.cpp
M  +17   -0    plugins/dockers/animation/animation_docker.cpp
M  +5    -0    plugins/dockers/animation/animation_docker.h
M  +13   -0    plugins/extensions/pykrita/sip/krita/Document.sip
M  +2    -0    plugins/extensions/pykrita/sip/krita/Node.sip

https://commits.kde.org/krita/79ecbca861dbddf370b25ec167050d71c55ec9d9
Comment 5 Scott Petrovic 2018-10-29 15:04:17 UTC
In addition to adding getting the current time and setting the current time, I added quite few more API calls with other things like the frame rate and changing the start and end times.

You can see a list of everything I added in green here.
https://cgit.kde.org/krita.git/diff/libs/libkis/Document.h?id=79ecbca861dbddf370b25ec167050d71c55ec9d9

This will be available in Krita 4.2 ... or the nightly build starting tomorrow if you want it earlier.