View difference between Paste ID: ZjFrmRQM and nWdVvfrL
SHOW: | | - or go back to the newest paste.
1
import bpy
2
3
bl_info = {
4
    # modified version of zeffiis quick script runner, see https://gist.github.com/zeffii/2b488961226ee1ecefcf
5
    "name": "Sequencer Script Runner",
6
    "author": "Samoth",
7
    "version": (0, 1, 0),
8
    "blender": (2, 7, 6),
9
    "location": "Sequencer, Properties Panel (right)",
10
    "category": "Sequencer"
11
}
12
13
14
class GlobalScriptRunner(bpy.types.Operator):
15
    bl_idname = "sequencer.script_runner"
16
    bl_label = "Sequencer Script Runner"
17
18
    def execute(self, context):
19
        # or put own script here...
20
        textblock_name = context.scene.global_script_to_run
21
        textblock = bpy.data.texts.get(textblock_name)
22
        if textblock:
23
            textblock_as_string = textblock.as_string()
24
            exec(textblock_as_string)
25
            return {'FINISHED'}
26
        else:
27
            return {'CANCELLED'}
28
29
30
class ScriptRunnerPanel(bpy.types.Panel):
31
    """Creates a Panel in the Sequencer Properties Panel"""
32
    bl_label = "Script Runner"
33
    bl_idname = "SCENE_PT_script_runner"
34
    bl_space_type = 'SEQUENCE_EDITOR'
35
    bl_region_type = 'UI'
36
37
    def draw(self, context):
38
        layout = self.layout
39
        layout.label('Script to run from Shortcut')
40
        layout.prop_search(context.scene, "global_script_to_run",  bpy.data, "texts")
41
42
43
def register():
44
    bpy.types.Scene.global_script_to_run = bpy.props.StringProperty()
45
    bpy.utils.register_class(GlobalScriptRunner)
46
    bpy.utils.register_class(ScriptRunnerPanel)
47
48
49
def unregister():
50
    bpy.utils.unregister_class(GlobalScriptRunner)
51
    bpy.utils.unregister_class(ScriptRunnerPanel)
52
    del bpy.types.Scene.global_script_to_run