[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3193] contrib/py/scripts/addons/ space_view3d_paint_bprojection.py: BProjection: add the possibility to scale the plan according to the 3D Cursor in the x and y axis

geo kgeo kgeogeo at hotmail.com
Sat Mar 31 14:36:05 CEST 2012


Revision: 3193
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3193
Author:   kgeogeo
Date:     2012-03-31 12:35:53 +0000 (Sat, 31 Mar 2012)
Log Message:
-----------
BProjection: add the possibility to scale the plan according to the 3D Cursor in the x and y axis

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-03-31 11:05:24 UTC (rev 3192)
+++ contrib/py/scripts/addons/space_view3d_paint_bprojection.py	2012-03-31 12:35:53 UTC (rev 3193)
@@ -142,10 +142,30 @@
         e = bpy.data.objects['Empty for BProjection'].location
         c = c3d
         ce = e - c
-        v = view3d_utils.location_3d_to_region_2d(context.area.regions[4], sd.region_3d,c + ((ce)/ob.custom_old_scale.x)*ob.custom_scale.x)   
-        print(ce,c,v)
-        res = [round(v.x),round(v.y)]        
-        ob.custom_location = res    
+        delta = ob.custom_old_scale - ob.custom_scale
+        xmove = False
+        ymove = False
+        v=[]
+        if delta.x != 0.0:
+            xmove = True
+        if delta.y != 0.0:
+            ymove = True    
+        
+        if xmove and not ob.custom_linkscale:
+            v = view3d_utils.location_3d_to_region_2d(context.area.regions[4], sd.region_3d, c + ce/ob.custom_old_scale.x*ob.custom_scale.x) 
+            res = [round(v.x),ob.custom_location[1]]
+            ob.custom_location = res             
+
+        if ymove and not ob.custom_linkscale:
+            v = view3d_utils.location_3d_to_region_2d(context.area.regions[4], sd.region_3d, c + ce/ob.custom_old_scale.y*ob.custom_scale.y) 
+            res = [ob.custom_location[0], round(v.y)]
+            ob.custom_location = res
+        
+        if ob.custom_linkscale and xmove:
+            v = view3d_utils.location_3d_to_region_2d(context.area.regions[4], sd.region_3d, c + ce/ob.custom_old_scale.x*ob.custom_scale.x) 
+            res = [round(v.x),round(v.y)]        
+            ob.custom_location = res
+            
     else:
         align_to_view(context)
     
@@ -240,7 +260,8 @@
             col.prop(ob, "custom_rot",text="Rotate around selection", icon='ROTATE')
             col = layout.column(align =True)
             col.prop(ob,'custom_location', text='Plane Properties')
-            col.prop(ob,'custom_z') 
+            col.prop(ob,'custom_z')
+            col = layout.column(align =True) 
             col.prop(ob,'custom_rotation')
             col.prop(ob,'custom_rotc3d',text="Rotate around 3D Cursor",icon='MANIPUL')            
             row = layout.row()



More information about the Bf-extensions-cvs mailing list