[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3244] contrib/py/scripts/addons/ space_view3d_paint_bprojection.py: BProjection: fix a few bug in sclupt mode, and improve the scale

geo kgeo kgeogeo at hotmail.com
Wed Apr 11 15:38:25 CEST 2012


Revision: 3244
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3244
Author:   kgeogeo
Date:     2012-04-11 13:38:24 +0000 (Wed, 11 Apr 2012)
Log Message:
-----------
BProjection: fix a few bug in sclupt mode, and improve the scale

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-11 00:27:50 UTC (rev 3243)
+++ contrib/py/scripts/addons/space_view3d_paint_bprojection.py	2012-04-11 13:38:24 UTC (rev 3244)
@@ -81,6 +81,7 @@
 def update_LinkUVScale(self, context):
     ob = context.object
     if ob.custom_linkscaleuv:
+        ob.custom_propscaleuv = ob.custom_scaleuv.x
         update_PropUVScale(self, context)
     else:
         update_UVScale(self, context) 
@@ -179,6 +180,19 @@
     
     ob.custom_old_scale = ob.custom_scale
 
+def update_PropScale(self, context):
+    ob = context.object
+    if ob.custom_linkscale:
+        ob.custom_scale = [ob.custom_propscale,ob.custom_propscale]
+    
+def update_LinkScale(self, context):
+    ob = context.object
+    if ob.custom_linkscale:
+        ob.custom_propscale = ob.custom_scale.x
+        update_PropScale(self, context)
+    else:
+        update_Scale(self, context) 
+
 def update_activeviewname(self, context):
     if self.custom_active:
         context.object.custom_active_view = self.custom_active_view
@@ -193,7 +207,9 @@
                                          
     custom_scale = FloatVectorProperty(name="Scales", description="Scale the planes",
                                        subtype = 'XYZ', default=(1.0, 1.0),min = 0.1, size=2)
-                                          
+    custom_propscale = FloatProperty(name="PropScale", description="Scale the Plan",
+                                           default=1.0,min = 0.1)
+                                                                                    
     custom_linkscale = BoolProperty(name="linkscale", default=True)
    
     # UV properties
@@ -234,10 +250,12 @@
                                          
     Ob.custom_scale = FloatVectorProperty(name="Scales", description="Scale the planes",
                                           subtype = 'XYZ', default=(1.0, 1.0),min = 0.1, size=2,update = update_Scale)
+    Ob.custom_propscale = FloatProperty(name="PropScale", description="Scale the Plan",
+                                           default=1.0,min = 0.1,update = update_PropScale)
     Ob.custom_old_scale = FloatVectorProperty(name="old_Scales", description="Old Scale the planes",
                                           subtype = 'XYZ', default=(1.0, 1.0),min = 0.1, size=2)
                                           
-    Ob.custom_linkscale = BoolProperty(name="linkscale", default=True, update = update_props)
+    Ob.custom_linkscale = BoolProperty(name="linkscale", default=True, update = update_LinkScale)
     
                                 
     Ob.custom_sub = IntProperty(name="Subdivide", description="Number of subdivision of the plan",
@@ -273,7 +291,7 @@
     list_prop = ['custom_location', 'custom_rotation', 'custom_old_rotation', 'custom_scale', 'custom_old_scale', 'custom_c3d',
                  'custom_rot', 'custom_rotc3d', 'custom_scaleuv', 'custom_flipuvx', 'custom_flipuvy', 'custom_linkscale',
                  'custom_linkscaleuv', 'custom_old_scaleuv', 'custom_offsetuv', 'custom_old_offsetuv', 'custom_scac3d', 'custom_sub',
-                 'custom_expand', 'custom_active_view', 'custom_propscaleuv', 'custom_props']
+                 'custom_expand', 'custom_active_view', 'custom_propscaleuv', 'custom_props', 'custom_propscale']
     for prop in list_prop:
         try:
             del bpy.context.object[prop]
@@ -312,6 +330,7 @@
         prop.custom_scale =  ob.custom_scale                  
         prop.custom_linkscale =  ob.custom_linkscale                                      
         prop.custom_scaleuv = ob.custom_scaleuv
+        prop.custom_propscale = ob.custom_propscale
         prop.custom_offsetuv =  ob.custom_offsetuv  
         prop.custom_linkscaleuv = ob.custom_linkscaleuv
         prop.custom_propscaleuv = ob.custom_propscaleuv
@@ -321,7 +340,6 @@
             prop.custom_image = bpy.data.textures['Texture for BProjection'].image.name
         except:
             do = 'nothing'
-        #bpy.ops.object.active_view(index = self.index)
         
         return {'FINISHED'}
 
@@ -341,7 +359,8 @@
         ob.custom_scaleuv = prop.custom_scaleuv
         ob.custom_propscaleuv = prop.custom_propscaleuv       
         ob.custom_rotation =  prop.custom_rotation                    
-        ob.custom_scale =  prop.custom_scale  
+        ob.custom_scale =  prop.custom_scale
+        ob.custom_propscale = prop.custom_propscale 
         ob.custom_location =  prop.custom_location                    
         if prop.custom_image != '':
             if bpy.data.textures['Texture for BProjection'].image.name != prop.custom_image:
@@ -382,6 +401,8 @@
             ob.custom_rotation = 0
             ob.custom_scaleuv =[1.0,1.0]
             ob.custom_offsetuv =[0.0,0.0]
+            ob.custom_propscaleuv = 1.0
+            ob.custom_propscale = 1.0
             if ob.custom_flipuvx == True:
                 ob.custom_flipuvx = False
             if ob.custom_flipuvy == True:
@@ -473,11 +494,12 @@
                 row.prop(ob,'custom_rotc3d',text="",icon='MANIPUL')            
                 row  = box.row(align =True)
                 row.label(text="Scale:")
-                row  = box.row(align =True)
-                row.prop(ob,'custom_scale',text='') 
+                row  = box.row(align =True) 
                 if ob.custom_linkscale :
+                    row.prop(ob, "custom_propscale",text="")
                     row.prop(ob, "custom_linkscale",text="",icon='LINKED')
                 else: 
+                    row.prop(ob,'custom_scale',text='')
                     row.prop(ob, "custom_linkscale",text="",icon='UNLINKED')
                 row.prop(ob,'custom_scac3d',text="",icon='MANIPUL')                            
                 row  = box.row(align =True)
@@ -526,6 +548,7 @@
         img = bpy.data.textures['Texture for BProjection'].image
         em = bpy.data.objects['Empty for BProjection']
         ob = context.object
+        cm = context.mode
                
         bpy.ops.object.editmode_toggle()
         f = ob.data.polygons
@@ -546,11 +569,11 @@
         if wasnul == False:
             bpy.ops.object.editmode_toggle()
         else:
-            bpy.ops.paint.texture_paint_toggle()
-                                   
-        #ob.custom_scale = [1,1]                       
-        ob.data.update()
-
+            if cm == 'PAINT_TEXTURE':
+                bpy.ops.object.mode_set(mode = 'TEXTURE_PAINT', toggle=False)
+            else:
+                bpy.ops.object.mode_set(mode = cm, toggle=False)
+                
         align_to_view(context)
         
         return {'FINISHED'}
@@ -635,7 +658,8 @@
 
         except:            
             createcustomprops(context)
-            bpy.ops.paint.texture_paint_toggle()
+            cm = bpy.context.mode
+            bpy.ops.object.mode_set(mode = 'OBJECT', toggle=False)
             
             context.space_data.show_relationship_lines = False
             
@@ -705,7 +729,10 @@
                         
             align_to_view(context)
             
-            bpy.ops.paint.texture_paint_toggle()
+            if cm == 'PAINT_TEXTURE':
+                bpy.ops.object.mode_set(mode = 'TEXTURE_PAINT', toggle=False)
+            else:
+                bpy.ops.object.mode_set(mode = cm, toggle=False)
             
         return {'FINISHED'}
 
@@ -727,7 +754,8 @@
     
     def execute(self, context):
         try:               
-            bpy.ops.paint.texture_paint_toggle()
+            cm = bpy.context.mode
+            bpy.ops.object.mode_set(mode = 'OBJECT', toggle=False)
             
             context.space_data.show_relationship_lines = True
             
@@ -792,7 +820,10 @@
                 if kmi.idname in ["object.intuitivescale"]:
                     km.keymap_items.remove(kmi)
             
-            bpy.ops.paint.texture_paint_toggle()
+            if cm == 'PAINT_TEXTURE':
+                bpy.ops.object.mode_set(mode = 'TEXTURE_PAINT', toggle=False)
+            else:
+                bpy.ops.object.mode_set(mode = cm, toggle=False)
             
             for i in ob.data.shape_keys.key_blocks:
                 bpy.ops.object.shape_key_remove()
@@ -910,7 +941,7 @@
             if 'S' in self.key:                
                 s = ob.custom_scale
                 if ob.custom_linkscale:
-                    ob.custom_scale = [s[0] + deltax/20, s[1]]
+                    ob.custom_propscale += deltax/20
                 else:
                     ob.custom_scale = [s[0] + deltax/20, s[1] + deltay/20]
                                           
@@ -943,6 +974,8 @@
             ob.custom_rotation = 0
             ob.custom_scaleuv =[1.0,1.0]
             ob.custom_offsetuv =[0.0,0.0]
+            ob.custom_propscaleuv = 1.0
+            ob.custom_propscale = 1.0
             if ob.custom_flipuvx == True:
                 ob.custom_flipuvx = False
             if ob.custom_flipuvy == True:
@@ -1085,4 +1118,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