[PYTHON] Set the range of active strips to the preview range

In Blender, specify the range of actions in units called strips There is a function called ** Non-Linear Animation (NLA) ** that superimposes or loops multiple motions. You can also export the strip as one motion when exporting FBX etc. image.png When creating repetitive motions for games, etc. I made it because I often check the movement by repeating with the length of the strip An add-on that sets the specified strip range to the timeline preview

Add the item "Strip to preview range" to the selection menu of the non-linear animation editor. image.png

Fixed what was used at work in the 2.7 era to support 2.8 or later

y_StripTime_to_preview.py


bl_info = {
    "name": "set activeStripTime to preview",
    "description": "Set the range of active strips to the preview range",
    "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()
    #Get strip information
    frame_start = strip.frame_start
    frame_end = strip.frame_end
    repeat = strip.repeat
    #Preview only the first 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="Strip into preview range" )

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()

Recommended Posts

Set the range of active strips to the preview range
[Blender] How to dynamically set the selection of EnumProperty
Set the specified column of QTableWidget to ReadOnly StyledItemDelegate
Standardize the vector to any range
Supplement to the explanation of vscode
Set the last modified date of the child file to the modified date of the parent directory
Extract the index of the original set list that corresponds to the list of subsets.
How to set up the development environment of ev3dev [Windows version]
The story of trying to reconnect the client
[Python] Set the graph range with matplotlib
[pyqtgraph] Set the size ratio of the graph
Script to change the description of fasta
How to check the version of Django
Set the time zone to Japan Standard Time
The story of adding MeCab to ubuntu 16.04
How to set the server time to Japanese time
Set the process name of the Python program
The story of pep8 changing to pycodestyle
Set the number of elements in a NumPy one-dimensional array to a power of 2 (0 padded)
Introduction to Statistical Modeling for Data Analysis Expanding the range of applications of GLM
I want to set a life cycle in the task definition of ECS
I made a script to record the active window using win32gui of Python
Python C / C ++ Extensions: Pass some of the data as np.array to Python (set stride)
How to calculate the volatility of a brand
How to find the area of the Voronoi diagram
I read the implementation of range (Objects / rangeobject.c)
Setting to output the log of cron execution
Specifying the range of ruby and python arrays
I tried to touch the API of ebay
I tried to correct the keystone of the image
Change the decimal point of logging from, to.
To get the path of the currently running python.exe
Djnago Memo Set Japanese to filename of Content-Disposition
I want to customize the appearance of zabbix
From the introduction of pyethapp to the execution of contract
Try to simulate the movement of the solar system
Procedure to set hydrogen of atom (virtual environment)
The story of moving from Pipenv to Poetry
I tried to predict the price of ETF
I tried to vectorize the lyrics of Hinatazaka46!
Set the output destination of the execution result to Vim started as a modeless window
I tried to sort out the objects from the image of the steak set meal-④ Clustering
Find a guideline for the number of processes / threads to set in the application server
It's time to seriously think about the definition and skill set of data scientists
python beginners tried to predict the number of criminals
The wall of changing the Django service from Python 2.7 to Python 3
The easiest way to set up Last-Modified in Flask
Template of python script to read the contents of the file
How to get the number of digits in Python
[GoLang] Set a space at the beginning of the comment
A memo to visually understand the axis of pandas.Panel
I want to grep the execution result of strace
I tried to summarize the basic form of GPLVM
Add information to the bottom of the figure with Matplotlib
The background color of the QWidget subclass cannot be set
[Introduction to Python] How to iterate with the range function?
Try to solve the problems / problems of "Matrix Programmer" (Chapter 1)
How to visualize the decision tree model of scikit-learn
The End of Catastrophic Programming # 04 "Mistaken Exception Catch Range"
[python] option to turn off the output of click.progressbar
Visualize the range of interpolation and extrapolation with python