[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3772] contrib/py/scripts/addons/ space_view3d_paint_bprojection.py: Bprojection: fix a bug when the addon is save in user preferences as active

geo kgeo kgeogeo at hotmail.com
Wed Sep 19 23:31:33 CEST 2012


Revision: 3772
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3772
Author:   kgeogeo
Date:     2012-09-19 21:31:32 +0000 (Wed, 19 Sep 2012)
Log Message:
-----------
Bprojection: fix a bug when the addon is save in user preferences as active

Modified Paths:
--------------
    contrib/py/scripts/addons/space_view3d_paint_bprojection.py

Modified: contrib/py/scripts/addons/space_view3d_paint_bprojection.py
===================================================================
--- contrib/py/scripts/addons/space_view3d_paint_bprojection.py	2012-09-19 14:22:18 UTC (rev 3771)
+++ contrib/py/scripts/addons/space_view3d_paint_bprojection.py	2012-09-19 21:31:32 UTC (rev 3772)
@@ -333,8 +333,10 @@
     Ob.custom_scac3d = BoolProperty(name="scac3d", default=False)
     Ob.custom_expand = BoolProperty(name="expand", default=True)
     Ob.custom_active_view = StringProperty(name = "custom_active_view",default = "View")
-    Ob.custom_active_object = StringProperty(name = "custom_active_object",default = context.object.name)
-    
+    try:
+        Ob.custom_active_object = StringProperty(name = "custom_active_object",default = context.object.name)
+    except:
+        Ob.custom_active_object = StringProperty(name = "custom_active_object",default = 'debut')    
     Ob.custom_props = CollectionProperty(type = custom_props)
 
 # Function to remove custom properties
@@ -514,8 +516,7 @@
         return (context.image_paint_object or context.sculpt_object)
 
     def draw(self, context):        
-        layout = self.layout
-                
+        layout = self.layout        
         if  'Empty for BProjection' in [ob.name for ob in bpy.data.objects]:
             
             
@@ -1151,13 +1152,13 @@
         return{'FINISHED'}
 
     def invoke(self, context, event):
+        context.window_manager.modal_handler_add(self)
         self.first_mouse = Vector((event.mouse_region_x,event.mouse_region_y))
         self.first_time = True
         for sub in context.object.modifiers:
-            if sub.type in {'SUBSURF', 'MULTIRES'}:
+            if sub.type in ['SUBSURF', 'MULTIRES']:
                 self.tmp_level = sub.levels
                 sub.levels = 0
-        context.window_manager.modal_handler_add(self)
         return {'RUNNING_MODAL'}
 
 # Oprerator Class to pan the view3D
@@ -1206,13 +1207,14 @@
         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   
         for sub in context.object.modifiers:
-            if sub.type in {'SUBSURF', 'MULTIRES'}:
+            if sub.type in ['SUBSURF', 'MULTIRES']:
                 self.tmp_level = sub.levels
-                sub.levels = 0
-        context.window_manager.modal_handler_add(self)
+                sub.levels = 0  
+                      
         return {'RUNNING_MODAL'}
 
     def execute(self, context):        



More information about the Bf-extensions-cvs mailing list