Hi,
I would like to experiment with custom overlays and drawing.
I found a code snippet, that draws lines into the 3Dview. neat.
import bpy
import gpu
from gpu_extras.batch import batch_for_shader
coords = [(1, 1, 1), (-2, 0, 0), (-2, -1, 3), (0, 1, 1)]
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
batch = batch_for_shader(shader, 'LINES', {"pos": coords})
def draw():
shader.bind()
shader.uniform_float("color", (1, 1, 0, 1))
batch.draw(shader)
bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW')
Now i wanted to draw lines into the Timeline/Dopesheet. I just changed the last line. however.
There was no error but also no lines appearing.
import bpy
import gpu
from gpu_extras.batch import batch_for_shader
coords = [(1, 1, 1), (-2, 0, 0), (-2, -1, 3), (0, 1, 1)]
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
batch = batch_for_shader(shader, 'LINES', {"pos": coords})
def draw():
shader.bind()
shader.uniform_float("color", (1, 1, 0, 1))
batch.draw(shader)
bpy.types.SpaceDopeSheetEditor.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW')
It is propably naive to think the same lines as in the 3Dview would also appear in the Timeline.
Does anyone of you has any experience with that kind of magic?
How to draw a simple line into the timeline?
I know, I will propably find anything usefull in here:
https://docs.blender.org/api/current/gpu.shader.html
Or: Where to beginn?