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_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')

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