[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57182] trunk/blender/release/scripts/ startup: Added a short-cut button in the Freestyle Python Scripting mode for loading

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Sun Jun 2 00:37:15 CEST 2013


Revision: 57182
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57182
Author:   kjym3
Date:     2013-06-01 22:37:15 +0000 (Sat, 01 Jun 2013)
Log Message:
-----------
Added a short-cut button in the Freestyle Python Scripting mode for loading
a style module file as a text datablock and appending it to the style module
stack.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_operators/freestyle.py
    trunk/blender/release/scripts/startup/bl_ui/properties_freestyle.py

Modified: trunk/blender/release/scripts/startup/bl_operators/freestyle.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/freestyle.py	2013-06-01 15:24:15 UTC (rev 57181)
+++ trunk/blender/release/scripts/startup/bl_operators/freestyle.py	2013-06-01 22:37:15 UTC (rev 57182)
@@ -19,7 +19,7 @@
 import sys
 import bpy
 
-from bpy.props import (EnumProperty, StringProperty)
+from bpy.props import (BoolProperty, EnumProperty, StringProperty)
 
 
 class SCENE_OT_freestyle_fill_range_by_selection(bpy.types.Operator):
@@ -139,3 +139,37 @@
                 ks.paths.add(mesh, path, index=0)
         bpy.ops.object.mode_set(mode=ob_mode, toggle=False)
         return {'FINISHED'}
+
+
+class SCENE_OT_freestyle_module_open(bpy.types.Operator):
+    """Open a style module file"""
+    bl_idname = "scene.freestyle_module_open"
+    bl_label = "Open Style Module File"
+    bl_options = {'INTERNAL'}
+
+    filepath = StringProperty(subtype='FILE_PATH')
+
+    make_internal = BoolProperty(
+        name="Make internal",
+        description="Make module file internal after loading",
+        default=True)
+
+    @classmethod
+    def poll(cls, context):
+        rl = context.scene.render.layers.active
+        return rl and rl.freestyle_settings.mode == 'SCRIPT'
+
+    def invoke(self, context, event):
+        self.freestyle_module = context.freestyle_module
+        wm = context.window_manager
+        wm.fileselect_add(self)
+        return {'RUNNING_MODAL'}
+
+    def execute(self, context):
+        text = bpy.data.texts.load(self.filepath)
+        if self.make_internal:
+            text.is_in_memory = True
+            text.is_dirty = True
+            text.filepath = ""
+        self.freestyle_module.script = text
+        return {'FINISHED'}

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_freestyle.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_freestyle.py	2013-06-01 15:24:15 UTC (rev 57181)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_freestyle.py	2013-06-01 22:37:15 UTC (rev 57182)
@@ -161,6 +161,7 @@
                 row = box.row(align=True)
                 row.prop(module, "use", text="")
                 row.prop(module, "script", text="")
+                row.operator("scene.freestyle_module_open", icon='FILESEL', text="")
                 row.operator("scene.freestyle_module_remove", icon='X', text="")
                 row.operator("scene.freestyle_module_move", icon='TRIA_UP', text="").direction = 'UP'
                 row.operator("scene.freestyle_module_move", icon='TRIA_DOWN', text="").direction = 'DOWN'




More information about the Bf-blender-cvs mailing list