[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26878] trunk/blender/release/scripts/op/ object_align.py: Align Objects operator: Added align relative to Active object

Daniel Salazar zanqdo at gmail.com
Sun Feb 14 00:29:26 CET 2010


Revision: 26878
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26878
Author:   zanqdo
Date:     2010-02-14 00:29:26 +0100 (Sun, 14 Feb 2010)

Log Message:
-----------
Align Objects operator: Added align relative to Active object

Modified Paths:
--------------
    trunk/blender/release/scripts/op/object_align.py

Modified: trunk/blender/release/scripts/op/object_align.py
===================================================================
--- trunk/blender/release/scripts/op/object_align.py	2010-02-13 23:18:28 UTC (rev 26877)
+++ trunk/blender/release/scripts/op/object_align.py	2010-02-13 23:29:26 UTC (rev 26878)
@@ -26,8 +26,6 @@
 
     cursor = bpy.context.scene.cursor_location
 
-    # Selection BB
-
     Left_Up_Front_SEL = [[],[],[]]
     Right_Down_Back_SEL = [[],[],[]]
     
@@ -40,7 +38,16 @@
         Left_Up_Front = bb_world[1]
         Right_Down_Back = bb_world[7]
 
+        # Active Center
 
+        if obj == bpy.context.active_object:
+            
+            center_active_x = ( Left_Up_Front[0] + Right_Down_Back[0] ) / 2
+            center_active_y = ( Left_Up_Front[1] + Right_Down_Back[1] ) / 2
+            center_active_z = ( Left_Up_Front[2] + Right_Down_Back[2] ) / 2
+
+        # Selection Center
+
         if flag_first:
             flag_first = False
     
@@ -77,7 +84,7 @@
     center_sel_y = ( Left_Up_Front_SEL[1] + Right_Down_Back_SEL[1] ) / 2
     center_sel_z = ( Left_Up_Front_SEL[2] + Right_Down_Back_SEL[2] ) / 2
 
-    # End Selection BB
+    # Main Loop
 
     for obj in bpy.context.selected_objects:
         
@@ -105,6 +112,9 @@
             
             elif relative_to == 'OPT_3':
                 loc_x = obj_x + center_sel_x
+
+            elif relative_to == 'OPT_4':
+                loc_x = obj_x + center_active_x
             
             obj.location[0] = loc_x
 
@@ -121,6 +131,9 @@
             
             elif relative_to == 'OPT_3':
                 loc_y = obj_y + center_sel_y
+
+            elif relative_to == 'OPT_4':
+                loc_y = obj_y + center_active_y
             
             obj.location[1] = loc_y
 
@@ -137,6 +150,9 @@
             
             elif relative_to == 'OPT_3':
                 loc_z = obj_z + center_sel_z
+
+            elif relative_to == 'OPT_4':
+                loc_z = obj_z + center_active_z
             
             obj.location[2] = loc_z
 
@@ -153,7 +169,8 @@
     relative_to = bpy.props.EnumProperty(items=(
             ('OPT_1', "Scene Origin", ""),
             ('OPT_2', "3D Cursor", ""),
-            ('OPT_3', "Selection", "")
+            ('OPT_3', "Selection", ""),
+            ('OPT_4', "Active", "")
             ),
         name="Relative To:",
         description="",
@@ -187,4 +204,4 @@
         self.layout.operator(AlignObjects.bl_idname,
         text="Align Objects")
 
-bpy.types.VIEW3D_MT_transform.append(menu_func)
+bpy.types.VIEW3D_MT_transform.append(menu_func)
\ No newline at end of file





More information about the Bf-blender-cvs mailing list