LoginSignup
0
1

More than 3 years have passed since last update.

アクティブなストリップの範囲をプレビュー範囲に設定

Last updated at Posted at 2021-01-11

Blenderには アクションをストリップという単位で範囲指定して
複数のモーションを重ね合わせたり、ループさせたりするノンリニアアニメーション(NLA)という機能があります
また、FBX等の書き出し時にストリップを1つのモーションとして書き出すこともできます。
image.png
ゲーム等の繰り返しモーションを作成する時に
ストリップの長さでリピートさせて動きをチェックすることが多いので作成した
指定したストリップの範囲をタイムラインのプレビューに設定するアドオンです

ノンリニアアニメーションエディッタの 選択メニューに「ストリップうをプレビュー範囲に」の項目を追加します
image.png

2.7時代に仕事で使用していたものを2.8以降に対応するように修正しました

y_StripTime_to_preview.py
bl_info = {
    "name": "set activeStripTime to preview",
    "description": "アクティブなストリップの範囲をプレビュー範囲に設定",
    "author": "Yukimi",
    "version": (0,3),
    "blender": (2,80, 0),
    "location": "NLA",
    "warning": "",
    "wiki_url": "",
    "tracker_url": "",
    "category": "Animation"}

import bpy

def Striptime_to_preview(context):
    active_track = context.active_object.animation_data.nla_tracks.active
    if not active_track :return()
    for strip in active_track.strips:
        if strip.active:
            active_strip = strip
    if active_strip == "":return()
    #ストリップの情報を取得
    frame_start = strip.frame_start
    frame_end = strip.frame_end
    repeat = strip.repeat
    #リピートの一回目のみをプレビュー
    context.scene.use_preview_range = True
    context.scene.frame_preview_end = frame_start + int(( frame_end - frame_start)/ repeat) -1
    context.scene.frame_preview_start = frame_start

class NLA_OT_StripTimeToPreview(bpy.types.Operator):
    '''    set activestrip to preview '''
    bl_idname = "action.striptime_to_preview"
    bl_label = "set activeStripTime to preview"
    def execute(self, context):
        Striptime_to_preview(context)
        return {'FINISHED'}


classes = (NLA_OT_StripTimeToPreview,)

###################################################
def menu_func(self, context):
    self.layout.operator("action.striptime_to_preview", 
        text="ストリップをプレビュー範囲に" )

def register():
    for cls in classes:
        bpy.utils.register_class(cls)
    bpy.types.NLA_MT_select.prepend(menu_func)

def unregister():
    bpy.types.NLA_MT_select.remove(menu_func)
    for cls in reversed(classes):
        bpy.utils.unregister_class(cls)

if __name__ == "__main__":
    register()
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1