python - How does the timeline_markers list work in Blender? -
i have following code:
import bpy import math import random markers = [] marker in bpy.context.scene.timeline_markers: frame = marker.frame markers.extend([frame]) print('-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+') print(markers) markers = sorted(markers) print(markers)
and when execute it, gives me 2 different output first print statement, before markers = sorted(markers) , after it.
that's output:
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ [33, 93, 151, 212, 265, 409, 640, 786, 524, 317] [33, 93, 151, 212, 265, 317, 409, 524, 640, 786]
when cycle reads items in timeline_markers haven't in increasing order?
but, assuming it's not this, how work?
you assuming timeline_markers stored sorted list, not case. while presented python common list/array, stored internally blender linked list. if trace source code find use listbase defined in dna_listbase.h , implemented in listbase.c.
while think of markers sequence in order matching timeline, there no real need or benefit keeping them sorted. if want display list of markers in frame order need sort them yourself.
Comments
Post a Comment