[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3213] contrib/py/scripts/addons/ space_view3d_paint_bprojection.py: BProjection: we can save several plan with suplt on the plan.

geo kgeo kgeogeo at hotmail.com
Wed Apr 4 22:01:13 CEST 2012


Revision: 3213
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3213
Author:   kgeogeo
Date:     2012-04-04 20:01:12 +0000 (Wed, 04 Apr 2012)
Log Message:
-----------
BProjection: we can save several plan with suplt on the plan. Now need code clean up but work fine

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-04-04 19:35:24 UTC (rev 3212)
+++ contrib/py/scripts/addons/space_view3d_paint_bprojection.py	2012-04-04 20:01:12 UTC (rev 3213)
@@ -280,13 +280,15 @@
         for item in ob.custom_props:
             item.custom_active = False            
         new_props.custom_active = True
-        bpy.ops.object.copy_view(index = len(bpy.context.object.custom_props)-1)
-        
+        bpy.ops.object.save_view(index = len(bpy.context.object.custom_props)-1)
+        ob.data.shape_keys.key_blocks[ob.active_shape_key_index].mute = True
+        bpy.ops.object.shape_key_add(from_mix = False)
+        ob.data.shape_keys.key_blocks[ob.active_shape_key_index].value = 1.0
         return {'FINISHED'}
 
 # Oprerator Class to copy view 
 class Copyiew(Operator):
-    bl_idname = "object.copy_view"
+    bl_idname = "object.save_view"
     bl_label = "copy the view"
     
     index = IntProperty(default = 0)
@@ -344,13 +346,23 @@
     
     def execute(self, context):              
         ob = context.object
+        
+        ob.active_shape_key_index =  self.index + 1
+        bpy.ops.object.shape_key_remove()
+        
         if  context.object.custom_props[self.index].custom_active: 
             if len(ob.custom_props) > 0:
                 bpy.ops.object.active_view(index = self.index-1)
             if self.index == 0 and len(ob.custom_props) > 1:
                 bpy.ops.object.active_view(index = 1)
                 
-        ob.custom_props.remove(self.index)           
+        ob.custom_props.remove(self.index)
+        
+        print(len(context.object.custom_props))
+                
+        if len(context.object.custom_props) == 0:
+            bpy.ops.object.create_view()            
+                 
         i=0
         for item in context.object.custom_props:
             item.custom_index = i
@@ -366,10 +378,18 @@
     index = IntProperty(default = 0)
     
     def execute(self, context):
-        for item in context.object.custom_props:
+        ob = context.object
+        for item in ob.custom_props:
             item.custom_active = False
-        context.object.custom_props[self.index].custom_active  = True
-        context.object.custom_active_view = context.object.custom_props[self.index].custom_active_view 
+        ob.custom_props[self.index].custom_active  = True
+        ob.custom_active_view = ob.custom_props[self.index].custom_active_view 
+        ob.active_shape_key_index =  self.index + 1
+        
+        for i in ob.data.shape_keys.key_blocks:
+            i.mute = True
+        
+        ob.data.shape_keys.key_blocks[ob.active_shape_key_index].mute = False
+        
         bpy.ops.object.paste_view(index = self.index)         
         
         return {'FINISHED'}
@@ -445,7 +465,7 @@
                 row = box.column(align =True)
                 row.prop(ob.material_slots['Material for BProjection'].material,'alpha', slider = True)
                 row = box.column(align =True)
-                row.operator('object.create_view', text="Create View", icon = 'RENDER_STILL')
+
                 
             for item in ob.custom_props:
                 box = layout.box()
@@ -455,8 +475,10 @@
                 else:
                     row.operator("object.active_view",text = "", icon='RADIOBUT_OFF', emboss = False).index = item.custom_index 
                 row.prop(item, "custom_active_view", text="")
-                row.operator('object.copy_view', text="", icon = 'FILE_REFRESH').index = item.custom_index         
-                row.operator('object.remove_view', text="", icon = 'PANEL_CLOSE', emboss = False).index = item.custom_index         
+                row.operator('object.save_view', text="", icon = 'SAVE_PREFS').index = item.custom_index         
+                row.operator('object.remove_view', text="", icon = 'PANEL_CLOSE', emboss = False).index = item.custom_index
+            row = layout.row()
+            row.operator('object.create_view', text="Create View", icon = 'RENDER_STILL')        
 
         except:
             col = layout.column(align = True)
@@ -614,8 +636,7 @@
             em.hide = True   
                      
             self.creatematerial(context)
-
-            #bpy.ops.object.applyimage()  
+  
           
             bpy.ops.gpencil.data_add()
             ob.grease_pencil.draw_mode = 'VIEW'
@@ -623,6 +644,10 @@
             ob.grease_pencil.layers.active.color = [1.0,0,0]
             
             bpy.ops.object.editmode_toggle()
+            
+            bpy.ops.object.shape_key_add(from_mix = False)
+            
+            bpy.ops.object.create_view()
                     
             km = bpy.data.window_managers['WinMan'].keyconfigs['Blender'].keymaps['3D View']
             km.keymap_items[3-1].idname = 'view3d.rotate_view3d'
@@ -736,6 +761,11 @@
                     km.keymap_items.remove(kmi)
             
             bpy.ops.paint.texture_paint_toggle()
+            
+            for i in ob.data.shape_keys.key_blocks:
+                bpy.ops.object.shape_key_remove()
+            bpy.ops.object.shape_key_remove()    
+            
             removecustomprops()
                     
         except:
@@ -1023,4 +1053,4 @@
     bpy.utils.unregister_module(__name__)
 
 if __name__ == "__main__":
-    register()
+    register()
\ No newline at end of file



More information about the Bf-extensions-cvs mailing list