(Python) (Blender) 如何获取每个有标记的帧的编号?

(Python) (Blender) How can I take the number of every frame on which there are markers?

有没有办法获取时间轴中有标记的每个帧编号,并将其设置为 噪声修改器 r 上的 f 曲线的起点所选对象?

标记数据可以在scene.timeline_markers

中找到

fcurve数据在object.animation_data.action.fcurves

如果您想添加从每个标记开始持续 10 帧的噪波修改器,您可以使用 -

import bpy

# data_path='location' with an index=1 is the y location curve
fc = bpy.context.object.animation_data.action.fcurves.find('location', index=1)

for m in bpy.context.scene.timeline_markers:
    nmod = fc.modifiers.new(type='NOISE')
    nmod.strength = 1.5
    nmod.use_restricted_range = True
    nmod.frame_start = m.frame
    nmod.frame_end = m.frame + 10

请注意,此处使用的 fcurves.find() 仅适用于 blender 2.76+,对于早期版本,您需要循环遍历 fcurves 并测试 data_path 以找到您想要的那个。