more bpy.context.scene fixes
authorCarlos Padial <palidoestudio2@gmail.com>
Sun, 6 Jan 2013 22:19:46 +0000 (22:19 +0000)
committerCarlos Padial <palidoestudio2@gmail.com>
Sun, 6 Jan 2013 22:19:46 +0000 (22:19 +0000)
sequencer_extra_actions/__init__.py
sequencer_extra_actions/functions.py
sequencer_extra_actions/operators_extra_actions.py
sequencer_extra_actions/ui.py

index 5443ff6e4f3b46f575337b40bd2f6eae92f22942..675abc683e84af47d9737317cd4b0718643cd656 100644 (file)
@@ -35,11 +35,9 @@ if "bpy" in locals():
     import imp
     imp.reload(operators_extra_actions)
     imp.reload(ui)
-    #imp.reload(operators_recursive)
 else:
     from . import operators_extra_actions
     from . import ui
-    #from . import operators_recursive
 
 import bpy
 import os.path
@@ -91,4 +89,4 @@ def unregister():
 
 
 if __name__ == '__main__':
-    register()
+    register()
\ No newline at end of file
index c603dd1df99790fa9ded075471cf719a5e1fed59..b8ef6818f1e03ed14edcf10ec0382915a2e1f064 100644 (file)
@@ -70,8 +70,8 @@ movieextdict = [("1", ".avi", ""),
 
 # Functions
 
-def add_marker(text):
-    scene = bpy.context.scene
+def add_marker(context, text):
+    scene = context.scene
     markers = scene.timeline_markers
     mark = markers.new(name=text)
     mark.frame = scene.frame_current
@@ -191,42 +191,17 @@ def sortlist(filelist):
     
 # recursive load functions 
 
-def loader(filelist):
-    scn = bpy.context.scene
-    if filelist:
-        for i in filelist:
-            setpathinbrowser(i[0], i[1])
-            try:
-                if scn.default_recursive_proxies:
-                    bpy.ops.sequencerextra.placefromfilebrowserproxy(
-                        proxy_suffix=scn.default_proxy_suffix,
-                        proxy_extension=scn.default_proxy_extension,
-                        proxy_path=scn.default_proxy_path,
-                        build_25=scn.default_build_25,
-                        build_50=scn.default_build_50,
-                        build_75=scn.default_build_75,
-                        build_100=scn.default_build_100)
-                else:
-                    bpy.ops.sequencerextra.placefromfilebrowser()
-            except:
-                print("Error loading file (recursive loader error): ", i[1])
-                add_marker(i[1])
-                #self.report({'ERROR_INVALID_INPUT'}, 'Error loading file ')
-                #return {'CANCELLED'}
-                pass
-
-def onefolder():
+def onefolder(context, default_recursive_ext):
     '''
     returns a list of MOVIE type files from folder selected in file browser
     '''
     filelist = []
     path, filename = getfilepathfrombrowser()
     extension = filename.rpartition(".")[2]
-    #extension = scn.default_ext
-    scn = bpy.context.scene
+    scn = context.scene
 
     if detect_strip_type(path + filename) == 'MOVIE':
-        if scn.default_recursive_ext == True:
+        if default_recursive_ext == True:
             for file in os.listdir(path):
                 if file.rpartition(".")[2] == extension:
                     filelist.append((path, file))
@@ -235,20 +210,20 @@ def onefolder():
                 filelist.append((path, file))
     return (filelist)
 
-def recursive():
+def recursive(context, default_recursive_ext):
     '''
     returns a list of MOVIE type files recursively from file browser
     '''
     filelist = []
     path = getpathfrombrowser()
-    scn = bpy.context.scene
+    scn = context.scene
     for i in movieextlist:
         if i[0] == scn.default_ext:
             extension = i[1].rpartition(".")[2]
     #pythonic way to magic:
     for root, dirs, files in os.walk(path):
         for f in files:
-            if scn.default_recursive_ext == True:
+            if default_recursive_ext == True:
                 if f.rpartition(".")[2] == extension:
                     filelist.append((root, f))
             else:
@@ -297,5 +272,3 @@ def randompartition(lst,n,rand):
         newlist.append([lst[count : int(lista[i]-1)+count]])
         count += int(lista[i]) 
     return newlist
-
-
index 11771897a570e6f010673879adbc6348ec507992..92d10f5f551cb3abc1b0c1b2a7fd649640c0dd57 100644 (file)
@@ -39,9 +39,10 @@ from . import exiftool
 
 
 # Initialization
-def initSceneProperties(scn):
+
+def initSceneProperties(context, scn):
     try:
-        if bpy.context.scene.scene_initialized == True:
+        if context.scene.scene_initialized == True:
             return False
     except AttributeError:
         pass
@@ -129,13 +130,13 @@ def initSceneProperties(scn):
         description='Load in recursive folders',
         default=False)
     scn.default_recursive = False
-
+    
     bpy.types.Scene.default_recursive_ext = BoolProperty(
         name='Recursive ext',
         description='Load only clips with selected extension',
         default=False)
     scn.default_recursive_ext = False
-
+    
     bpy.types.Scene.default_recursive_proxies = BoolProperty(
         name='Recursive proxies',
         description='Load in recursive folders + proxies',
@@ -147,17 +148,15 @@ def initSceneProperties(scn):
         name="ext enum",
         default="3")
     scn.default_ext = "3"
-
+    
     bpy.types.Scene.scene_initialized = BoolProperty(
         name='Init',
         default=False)
     scn.scene_initialized = True
-    
-    
 
     return True
 
-
+   
 # TRIM TIMELINE
 class Sequencer_Extra_TrimTimeline(bpy.types.Operator):
     bl_label = 'Trim to Timeline Content'
@@ -294,7 +293,7 @@ class Sequencer_Extra_SlideStrip(bpy.types.Operator):
 
     def invoke(self, context, event):
         scn = context.scene
-        initSceneProperties(scn)
+        initSceneProperties(context,scn)
         self.slide_offset = scn.default_slide_offset
         if self.mode == 'INPUT':
             return context.window_manager.invoke_props_dialog(self)
@@ -1061,6 +1060,18 @@ class Sequencer_Extra_FadeInOut(bpy.types.Operator):
             default='IN',
             )
     bl_options = {'REGISTER', 'UNDO'}
+    
+    fade_duration = IntProperty(
+        name='Duration',
+        description='Number of frames to fade',
+        min=1, max=250,
+        default=25)
+    fade_amount = FloatProperty(
+        name='Amount',
+        description='Maximum value of fade',
+        min=0.0,
+        max=100.0,
+        default=1.0)
 
     @classmethod
     def poll(cls, context):
@@ -1142,7 +1153,7 @@ class Sequencer_Extra_FadeInOut(bpy.types.Operator):
 
     def invoke(self, context, event):
         scn = context.scene
-        initSceneProperties(scn)
+        initSceneProperties(context, scn)
         self.fade_duration = scn.default_fade_duration
         self.fade_amount = scn.default_fade_amount
         return context.window_manager.invoke_props_dialog(self)
@@ -1241,7 +1252,7 @@ class Sequencer_Extra_Distribute(bpy.types.Operator):
 
     def invoke(self, context, event):
         scn = context.scene
-        initSceneProperties(scn)
+        initSceneProperties(context, scn)
         self.distribute_offset = scn.default_distribute_offset
         self.distribute_reverse = scn.default_distribute_reverse
         return context.window_manager.invoke_props_dialog(self)
@@ -1409,14 +1420,37 @@ class Sequencer_Extra_PlaceFromFileBrowserProxy(bpy.types.Operator):
     bl_idname = 'sequencerextra.placefromfilebrowserproxy'
     bl_description = 'Place or insert active file from File Browser, '\
     'and add proxy file with according suffix and extension'
-    insert = BoolProperty(
-    name='Insert',
-    default=False)
+    insert = BoolProperty(name='Insert', default=False)
+    build_25 = BoolProperty(name='default_build_25',
+        description='default build_25',
+        default=True)
+    build_50 = BoolProperty(name='default_build_50',
+        description='default build_50',
+        default=True)
+    build_75 = BoolProperty(name='default_build_75',
+        description='default build_75',
+        default=True)
+    build_100 = BoolProperty(name='default_build_100',
+        description='default build_100',
+        default=True)
+    proxy_suffix = StringProperty(
+        name='default proxy suffix',
+        description='default proxy filename suffix',
+        default="-25")
+    proxy_extension = StringProperty(
+        name='default proxy extension',
+        description='default proxy extension',
+        default=".mkv")
+    proxy_path = StringProperty(
+        name='default proxy path',
+        description='default proxy path',
+        default="")
 
     bl_options = {'REGISTER', 'UNDO'}
 
     def invoke(self, context, event):
         scn = context.scene
+        initSceneProperties(context, scn)
         self.build_25 = scn.default_build_25
         self.build_50 = scn.default_build_50
         self.build_75 = scn.default_build_75
@@ -1664,13 +1698,109 @@ class Sequencer_Extra_RecursiveLoader(bpy.types.Operator):
     bl_idname = "sequencerextra.recursiveload"
     bl_label = "recursive load"
     bl_options = {'REGISTER', 'UNDO'}
+    
+    default_recursive = BoolProperty(
+        name='Recursive',
+        description='Load in recursive folders',
+        default=False)
+        
+    default_recursive_ext = BoolProperty(
+        name='Recursive extension',
+        description='Load in recursive folders',
+        default=False)
+        
+    default_ext = EnumProperty(
+        items=functions.movieextdict,
+        name="ext enum",
+        default="3")
+        
+    default_recursive_proxies = BoolProperty(
+        name='Recursive proxies',
+        description='Load in recursive folders',
+        default=False)
+    build_25 = BoolProperty(name='default_build_25',
+        description='default build_25',
+        default=True)
+    build_50 = BoolProperty(name='default_build_50',
+        description='default build_50',
+        default=True)
+    build_75 = BoolProperty(name='default_build_75',
+        description='default build_75',
+        default=True)
+    build_100 = BoolProperty(name='default_build_100',
+        description='default build_100',
+        default=True)
+    proxy_suffix = StringProperty(
+        name='default proxy suffix',
+        description='default proxy filename suffix',
+        default="-25")
+    proxy_extension = StringProperty(
+        name='default proxy extension',
+        description='default proxy extension',
+        default=".mkv")
+    proxy_path = StringProperty(
+        name='default proxy path',
+        description='default proxy path',
+        default="")
+    
+       
+    
+    @classmethod
+    def poll(self, context):
+        scn = context.scene
+        if scn and scn.sequence_editor:
+            return (scn.sequence_editor)
+        else:
+            return False
+        
+    def invoke(self, context, event):
+        scn = context.scene
+        initSceneProperties(context, scn)
+        self.build_25 = scn.default_build_25
+        self.build_50 = scn.default_build_50
+        self.build_75 = scn.default_build_75
+        self.build_100 = scn.default_build_100
+        self.proxy_suffix = scn.default_proxy_suffix
+        self.proxy_extension = scn.default_proxy_extension
+        self.proxy_path = scn.default_proxy_path
+        self.default_recursive = scn.default_recursive
+        self.default_recursive_ext = scn.default_recursive_ext
+        self.default_recursive_proxies = scn.default_recursive_proxies
+        self.default_ext = scn.default_ext 
+        
+        return context.window_manager.invoke_props_dialog(self)  
+        
+    def loader(self, context, filelist):
+        scn = context.scene
+        if filelist:
+            for i in filelist:
+                functions.setpathinbrowser(i[0], i[1])
+                try:
+                    if self.default_recursive_proxies:
+                        bpy.ops.sequencerextra.placefromfilebrowserproxy(
+                            proxy_suffix=self.default_proxy_suffix,
+                            proxy_extension=self.default_proxy_extension,
+                            proxy_path=self.default_proxy_path,
+                            build_25=self.default_build_25,
+                            build_50=self.default_build_50,
+                            build_75=self.default_build_75,
+                            build_100=self.default_build_100)
+                    else:
+                        bpy.ops.sequencerextra.placefromfilebrowser()
+                except:
+                    print("Error loading file (recursive loader error): ", i[1])
+                    functions.add_marker(i[1], context)
+                    #self.report({'ERROR_INVALID_INPUT'}, 'Error loading file ')
+                    pass
+
 
     def execute(self, context):
-        scn = bpy.context.scene
+        scn = context.scene
+        initSceneProperties(context, scn)
         if scn["default_recursive"] == True:
-            functions.loader(functions.sortlist(functions.recursive()))
+            self.loader(context, functions.sortlist(functions.recursive(context, self.default_recursive_ext)))
         else:
-            functions.loader(functions.sortlist(functions.onefolder()))
+            self.loader(context, functions.sortlist(functions.onefolder(context, self.default_recursive_ext)))
         return {'FINISHED'}
 
 
@@ -1736,4 +1866,4 @@ class Sequencer_Extra_ReadExifData(bpy.types.Operator):
         text = bpy.context.active_object
         strip = context.scene.sequence_editor.active_strip
         sce['metadata'] = getexifdata(strip)
-        return {'FINISHED'}
+        return {'FINISHED'}
\ No newline at end of file
index 2d96e4189a4432463261fb883a1fb962bb92d416..f092d334545aac3eb5f5c99728b7c03b000f4f5c 100644 (file)
@@ -54,24 +54,11 @@ class AddRecursiveLoadPanel(bpy.types.Panel):
         layout.label(text="", icon="NLA")
 
     def draw(self, context):
-
-        scn = bpy.context.scene
-        self.layout.prop(scn, "default_recursive_ext", text="Same extension")
-        if scn.default_recursive_ext:
-            split = self.layout.split()
-            col = split.column()
-            col.prop(scn, "default_ext", text="extension: ")
-
-        self.layout.prop(scn, "default_recursive", text="Recursive Folders")
-        split = self.layout.split(percentage=0.3)
-
-        split.label(text="")
-        split.prop(scn, "default_recursive_proxies", text="Proxies")
-
         self.layout.operator("sequencerextra.recursiveload",
             text="Import from Browser")
 
 
+
 def sequencer_select_menu_func(self, context):
     self.layout.operator_menu_enum('sequencerextra.select_all_by_type',
     'type', text='All by Type', icon='PLUGIN')
@@ -215,4 +202,4 @@ class ExifInfoPanel(bpy.types.Panel):
             except KeyError:
                 pass
         except AttributeError:
-            pass
+            pass
\ No newline at end of file