Paste Code
Paste Blends
Paste Images
bl_info = {
"name": "VSE Transform tool",
"description": "",
"author": "kgeogeo",
"version": (1, 0),
"blender": (2, 6, 5),
"wiki_url": "",
"tracker_url":"",
"category": "Sequencer"}

import bpy
from mathutils import *
from math import *
from bpy_extras import view3d_utils

class TF_Add(bpy.types.Operator):
bl_idname = "sequencer.tf_add"
bl_label = "Add Transform Effect"

@classmethod
def poll(cls, context):
return context.space_data.type == 'SEQUENCE_EDITOR'

def execute(self, context):
selection = [seq for seq in context.scene.sequence_editor.sequences if seq.select]
for seq in selection:
bpy.ops.sequencer.select_all(action='DESELECT')
context.scene.sequence_editor.active_strip = seq
bpy.ops.sequencer.effect_strip_add(type = "TRANSFORM")
active_seq = context.scene.sequence_editor.active_strip
seq.mute = True
context.scene.sequence_editor.active_strip.blend_type = seq.blend_type
context.scene.sequence_editor.active_strip.blend_alpha = seq.blend_alpha
context.scene.sequence_editor.active_strip.translation_unit = "PIXELS"
return {'FINISHED'}

class TF_Scale(bpy.types.Operator):
bl_idname = "sequencer.tf_scale"
bl_label = "Transform Scale"

first_mouse = Vector((0,0))
init_s = [0.0 ,0.0]
tab_init = []

@classmethod
def poll(cls, context):
return context.scene.sequence_editor.active_strip.type == 'TRANSFORM' and context.region.type == 'PREVIEW'

def modal(self, context, event):
width = context.region.width
height = context.region.height

deltax = event.mouse_region_x - self.first_mouse.x
deltay = event.mouse_region_y - self.first_mouse.y

if event.shift:
fac = 0.1
else:
fac = 1

for seq in context.scene.sequence_editor.sequences:
if seq.select and seq.type == 'TRANSFORM':
seq.scale_start_x += deltax*0.01*fac
seq.scale_start_y += deltax*0.01*fac

self.first_mouse.x = event.mouse_region_x
self.first_mouse.y = event.mouse_region_y

if event.type == 'LEFTMOUSE':
return {'FINISHED'}

if event.type == 'ESC' or event.type == 'RIGHTMOUSE':
for seq in context.scene.sequence_editor.sequences:
if seq.select and seq.type == 'TRANSFORM':
seq.scale_start_x = self.tab_init[0][0]
seq.scale_start_y = self.tab_init[0][1]
self.tab_init.pop(0)
return {'FINISHED'}

return {'RUNNING_MODAL'}

def invoke(self, context, event):
context.window_manager.modal_handler_add(self)
self.first_mouse.x = event.mouse_region_x
self.first_mouse.y = event.mouse_region_y
self.tab_init = []
for seq in context.scene.sequence_editor.sequences:
if seq.select and seq.type == 'TRANSFORM':
self.init_s = [seq.scale_start_x,seq.scale_start_y]
self.tab_init.append(self.init_s)

return {'RUNNING_MODAL'}

class TF_Rotation(bpy.types.Operator):
bl_idname = "sequencer.tf_rotation"
bl_label = "Transform Rotation"

first_mouse = Vector((0,0))
init_r = 0.0
tab_init = []

@classmethod
def poll(cls, context):
return context.scene.sequence_editor.active_strip.type == 'TRANSFORM' and context.region.type == 'PREVIEW'

def modal(self, context, event):
width = context.region.width
height = context.region.height

deltax = event.mouse_region_x - self.first_mouse.x
deltay = event.mouse_region_y - self.first_mouse.y

if event.shift:
fac = 0.1
else:
fac = 1

for seq in context.scene.sequence_editor.sequences:
if seq.select and seq.type == 'TRANSFORM':
seq.rotation_start -= deltax*fac

self.first_mouse.x = event.mouse_region_x
self.first_mouse.y = event.mouse_region_y

if event.type == 'LEFTMOUSE':
return {'FINISHED'}

if event.type == 'ESC' or event.type == 'RIGHTMOUSE':
for seq in context.scene.sequence_editor.sequences:
if seq.select and seq.type == 'TRANSFORM':
seq.rotation_start = self.tab_init[0]
self.tab_init.pop(0)
return {'FINISHED'}

return {'RUNNING_MODAL'}

def invoke(self, context, event):
context.window_manager.modal_handler_add(self)
self.first_mouse.x = event.mouse_region_x
self.first_mouse.y = event.mouse_region_y
self.tab_init = []
for seq in context.scene.sequence_editor.sequences:
if seq.select and seq.type == 'TRANSFORM':
self.init_r = seq.rotation_start
self.tab_init.append(self.init_r)

return {'RUNNING_MODAL'}

class TF_Position(bpy.types.Operator):
bl_idname = "sequencer.tf_position"
bl_label = "Transform Position"
axe_x = True
axe_y = True
first_mouse = Vector((0,0))
init_g = [0.0 ,0.0]
tab_init = []

@classmethod
def poll(cls, context):
return context.scene.sequence_editor.active_strip.type == 'TRANSFORM' and context.region.type == 'PREVIEW'

def modal(self, context, event):
width = context.region.width
height = context.region.height

deltax = event.mouse_region_x - self.first_mouse.x
deltay = event.mouse_region_y - self.first_mouse.y

if event.shift:
fac = 0.1
else:
fac = 1

for seq in context.scene.sequence_editor.sequences:
if seq.select and seq.type == 'TRANSFORM':
if self.axe_x:
seq.translate_start_x += deltax*2*fac
if self.axe_y:
seq.translate_start_y += deltay*2*fac

self.first_mouse.x = event.mouse_region_x
self.first_mouse.y = event.mouse_region_y

if event.type == 'X' and event.value == 'PRESS':
if self.axe_x == True and self.axe_y == True:
self.axe_y = False
elif self.axe_x == True and self.axe_y == False:
self.axe_y = True
elif self.axe_x == False and self.axe_y == True:
self.axe_y = False
self.axe_x = True

if event.type == 'Y' and event.value == 'PRESS':
if self.axe_x == True and self.axe_y == True:
self.axe_x = False
elif self.axe_x == False and self.axe_y == True:
self.axe_x = True
elif self.axe_x == True and self.axe_y == False:
self.axe_y = True
self.axe_x = False

print(self.axe_x,self.axe_y)

if event.type == 'LEFTMOUSE':
return {'FINISHED'}

if event.type == 'ESC' or event.type == 'RIGHTMOUSE':
for seq in context.scene.sequence_editor.sequences:
if seq.select and seq.type == 'TRANSFORM':
seq.translate_start_x = self.tab_init[0][0]
seq.translate_start_y = self.tab_init[0][1]
self.tab_init.pop(0)
return {'FINISHED'}

return {'RUNNING_MODAL'}

def invoke(self, context, event):
context.window_manager.modal_handler_add(self)
self.first_mouse.x = event.mouse_region_x
self.first_mouse.y = event.mouse_region_y
self.tab_init = []
for seq in context.scene.sequence_editor.sequences:
if seq.select and seq.type == 'TRANSFORM':
self.init_g = [seq.translate_start_x,seq.translate_start_y]
self.tab_init.append(self.init_g)

return {'RUNNING_MODAL'}

def register():
bpy.utils.register_module(__name__)
km = bpy.context.window_manager.keyconfigs.default.keymaps['View2D']
kmi = km.keymap_items.new("sequencer.tf_position", 'G', 'PRESS')
kmi = km.keymap_items.new("sequencer.tf_scale", 'S', 'PRESS')
kmi = km.keymap_items.new("sequencer.tf_rotation", 'R', 'PRESS')
kmi = km.keymap_items.new("sequencer.tf_add", 'T', 'PRESS')

def unregister():
bpy.utils.unregister_module(__name__)
km = bpy.context.window_manager.keyconfigs.default.keymaps['View2D']
for kmi in (kmi for kmi in km.keymap_items if kmi.idname in {"sequencer.tf_position", "sequencer.tf_scale", "sequencer.tf_rotation", "sequencer.tf_add", }):
km.keymap_items.remove(kmi)

if __name__ == "__main__":
register()
  1. bl_info = {
  2.     "name": "VSE Transform tool",
  3.     "description": "",
  4.     "author": "kgeogeo",
  5.     "version": (1, 0),
  6.     "blender": (2, 6, 5),
  7.     "wiki_url": "",
  8.     "tracker_url":"",
  9.     "category": "Sequencer"}
  10.  
  11. import bpy
  12. from mathutils import *
  13. from math import *
  14. from bpy_extras import view3d_utils
  15.  
  16. class TF_Add(bpy.types.Operator):
  17.     bl_idname = "sequencer.tf_add"
  18.     bl_label = "Add Transform Effect"
  19.  
  20.     @classmethod
  21.     def poll(cls, context):
  22.         return context.space_data.type == 'SEQUENCE_EDITOR'
  23.                
  24.     def execute(self, context):  
  25.         selection = [seq for seq in context.scene.sequence_editor.sequences if seq.select]
  26.         for seq in selection:
  27.             bpy.ops.sequencer.select_all(action='DESELECT')
  28.             context.scene.sequence_editor.active_strip = seq
  29.             bpy.ops.sequencer.effect_strip_add(type = "TRANSFORM")
  30.             active_seq = context.scene.sequence_editor.active_strip
  31.             seq.mute = True
  32.             context.scene.sequence_editor.active_strip.blend_type = seq.blend_type
  33.             context.scene.sequence_editor.active_strip.blend_alpha = seq.blend_alpha
  34.             context.scene.sequence_editor.active_strip.translation_unit = "PIXELS"                          
  35.         return {'FINISHED'}
  36.  
  37. class TF_Scale(bpy.types.Operator):
  38.     bl_idname = "sequencer.tf_scale"
  39.     bl_label = "Transform Scale"
  40.    
  41.     first_mouse = Vector((0,0))
  42.     init_s = [0.0 ,0.0]
  43.     tab_init = []
  44.    
  45.     @classmethod
  46.     def poll(cls, context):
  47.         return context.scene.sequence_editor.active_strip.type == 'TRANSFORM' and context.region.type == 'PREVIEW'
  48.  
  49.     def modal(self, context, event):
  50.         width = context.region.width
  51.         height = context.region.height
  52.  
  53.         deltax = event.mouse_region_x - self.first_mouse.x
  54.         deltay = event.mouse_region_y - self.first_mouse.y                
  55.        
  56.         if event.shift:
  57.             fac = 0.1
  58.         else:
  59.             fac = 1
  60.            
  61.         for seq in context.scene.sequence_editor.sequences:
  62.             if seq.select and seq.type == 'TRANSFORM':
  63.                 seq.scale_start_x += deltax*0.01*fac
  64.                 seq.scale_start_y += deltax*0.01*fac        
  65.        
  66.         self.first_mouse.x = event.mouse_region_x
  67.         self.first_mouse.y = event.mouse_region_y
  68.  
  69.         if event.type == 'LEFTMOUSE':
  70.             return {'FINISHED'}
  71.        
  72.         if event.type == 'ESC' or event.type == 'RIGHTMOUSE':
  73.             for seq in context.scene.sequence_editor.sequences:
  74.                 if seq.select and seq.type == 'TRANSFORM':
  75.                     seq.scale_start_x = self.tab_init[0][0]
  76.                     seq.scale_start_y = self.tab_init[0][1]
  77.                     self.tab_init.pop(0)
  78.             return {'FINISHED'}
  79.        
  80.         return {'RUNNING_MODAL'}
  81.                
  82.     def invoke(self, context, event):  
  83.         context.window_manager.modal_handler_add(self)
  84.         self.first_mouse.x = event.mouse_region_x
  85.         self.first_mouse.y = event.mouse_region_y  
  86.         self.tab_init = []
  87.         for seq in context.scene.sequence_editor.sequences:
  88.             if seq.select and seq.type == 'TRANSFORM':
  89.                 self.init_s = [seq.scale_start_x,seq.scale_start_y]
  90.                 self.tab_init.append(self.init_s)
  91.                
  92.         return {'RUNNING_MODAL'}
  93.  
  94. class TF_Rotation(bpy.types.Operator):
  95.     bl_idname = "sequencer.tf_rotation"
  96.     bl_label = "Transform Rotation"
  97.    
  98.     first_mouse = Vector((0,0))
  99.     init_r = 0.0
  100.     tab_init = []
  101.    
  102.     @classmethod
  103.     def poll(cls, context):
  104.         return context.scene.sequence_editor.active_strip.type == 'TRANSFORM' and context.region.type == 'PREVIEW'
  105.  
  106.     def modal(self, context, event):
  107.         width = context.region.width
  108.         height = context.region.height
  109.  
  110.         deltax = event.mouse_region_x - self.first_mouse.x
  111.         deltay = event.mouse_region_y - self.first_mouse.y                
  112.        
  113.         if event.shift:
  114.             fac = 0.1
  115.         else:
  116.             fac = 1
  117.  
  118.         for seq in context.scene.sequence_editor.sequences:
  119.             if seq.select and seq.type == 'TRANSFORM':
  120.                 seq.rotation_start -= deltax*fac          
  121.        
  122.         self.first_mouse.x = event.mouse_region_x
  123.         self.first_mouse.y = event.mouse_region_y
  124.        
  125.         if event.type == 'LEFTMOUSE':
  126.             return {'FINISHED'}
  127.        
  128.         if event.type == 'ESC' or event.type == 'RIGHTMOUSE':
  129.             for seq in context.scene.sequence_editor.sequences:
  130.                 if seq.select and seq.type == 'TRANSFORM':
  131.                     seq.rotation_start = self.tab_init[0]
  132.                     self.tab_init.pop(0)
  133.             return {'FINISHED'}
  134.        
  135.         return {'RUNNING_MODAL'}
  136.                
  137.     def invoke(self, context, event):  
  138.         context.window_manager.modal_handler_add(self)
  139.         self.first_mouse.x = event.mouse_region_x
  140.         self.first_mouse.y = event.mouse_region_y  
  141.         self.tab_init = []
  142.         for seq in context.scene.sequence_editor.sequences:
  143.             if seq.select and seq.type == 'TRANSFORM':
  144.                 self.init_r = seq.rotation_start
  145.                 self.tab_init.append(self.init_r)
  146.                
  147.         return {'RUNNING_MODAL'}
  148.  
  149. class TF_Position(bpy.types.Operator):
  150.     bl_idname = "sequencer.tf_position"
  151.     bl_label = "Transform Position"
  152.     axe_x = True
  153.     axe_y = True
  154.     first_mouse = Vector((0,0))
  155.     init_g = [0.0 ,0.0]
  156.     tab_init = []
  157.    
  158.     @classmethod
  159.     def poll(cls, context):
  160.         return context.scene.sequence_editor.active_strip.type == 'TRANSFORM' and context.region.type == 'PREVIEW'
  161.  
  162.     def modal(self, context, event):
  163.         width = context.region.width
  164.         height = context.region.height
  165.  
  166.         deltax = event.mouse_region_x - self.first_mouse.x
  167.         deltay = event.mouse_region_y - self.first_mouse.y                
  168.                
  169.         if event.shift:
  170.             fac = 0.1
  171.         else:
  172.             fac = 1
  173.            
  174.         for seq in context.scene.sequence_editor.sequences:
  175.             if seq.select and seq.type == 'TRANSFORM':              
  176.                 if self.axe_x:
  177.                     seq.translate_start_x += deltax*2*fac
  178.                 if self.axe_y:
  179.                     seq.translate_start_y += deltay*2*fac  
  180.        
  181.         self.first_mouse.x = event.mouse_region_x
  182.         self.first_mouse.y = event.mouse_region_y
  183.        
  184.         if event.type == 'X' and event.value == 'PRESS':
  185.             if self.axe_x == True and self.axe_y == True:
  186.                 self.axe_y = False
  187.             elif self.axe_x == True and self.axe_y == False:
  188.                 self.axe_y = True
  189.             elif self.axe_x == False and self.axe_y == True:
  190.                 self.axe_y = False
  191.                 self.axe_x = True  
  192.        
  193.         if event.type == 'Y' and event.value == 'PRESS':
  194.             if self.axe_x == True and self.axe_y == True:
  195.                 self.axe_x = False
  196.             elif self.axe_x == False and self.axe_y == True:
  197.                 self.axe_x = True
  198.             elif self.axe_x == True and self.axe_y == False:
  199.                 self.axe_y = True
  200.                 self.axe_x = False
  201.        
  202.         print(self.axe_x,self.axe_y)
  203.        
  204.         if event.type == 'LEFTMOUSE':
  205.             return {'FINISHED'}
  206.        
  207.         if event.type == 'ESC' or event.type == 'RIGHTMOUSE':
  208.             for seq in context.scene.sequence_editor.sequences:
  209.                 if seq.select and seq.type == 'TRANSFORM':
  210.                     seq.translate_start_x = self.tab_init[0][0]
  211.                     seq.translate_start_y = self.tab_init[0][1]
  212.                     self.tab_init.pop(0)
  213.             return {'FINISHED'}
  214.        
  215.         return {'RUNNING_MODAL'}
  216.                
  217.     def invoke(self, context, event):  
  218.         context.window_manager.modal_handler_add(self)
  219.         self.first_mouse.x = event.mouse_region_x
  220.         self.first_mouse.y = event.mouse_region_y  
  221.         self.tab_init = []
  222.         for seq in context.scene.sequence_editor.sequences:
  223.             if seq.select and seq.type == 'TRANSFORM':
  224.                 self.init_g = [seq.translate_start_x,seq.translate_start_y]
  225.                 self.tab_init.append(self.init_g)
  226.                
  227.         return {'RUNNING_MODAL'}
  228.  
  229. def register():
  230.     bpy.utils.register_module(__name__)
  231.     km = bpy.context.window_manager.keyconfigs.default.keymaps['View2D']
  232.     kmi = km.keymap_items.new("sequencer.tf_position", 'G', 'PRESS')
  233.     kmi = km.keymap_items.new("sequencer.tf_scale", 'S', 'PRESS')
  234.     kmi = km.keymap_items.new("sequencer.tf_rotation", 'R', 'PRESS')
  235.     kmi = km.keymap_items.new("sequencer.tf_add", 'T', 'PRESS')
  236.  
  237. def unregister():
  238.     bpy.utils.unregister_module(__name__)
  239.     km = bpy.context.window_manager.keyconfigs.default.keymaps['View2D']
  240.     for kmi in (kmi for kmi in km.keymap_items if kmi.idname in {"sequencer.tf_position", "sequencer.tf_scale", "sequencer.tf_rotation", "sequencer.tf_add", }):
  241.             km.keymap_items.remove(kmi)
  242.            
  243. if __name__ == "__main__":
  244.     register()
  245.  
go to heaven