[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33776] trunk/blender: bugfix [#25290] Align on text gives a traceback

Campbell Barton ideasman42 at gmail.com
Sun Dec 19 08:05:30 CET 2010


Revision: 33776
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33776
Author:   campbellbarton
Date:     2010-12-19 08:05:29 +0100 (Sun, 19 Dec 2010)

Log Message:
-----------
bugfix [#25290] Align on text gives a traceback
       [#25284] Traceback error on "System Info" script

- Align was only working on mesh objects, now operate on all objects, missing boundbox's are treated as single points.
- obj.bound_box was returning all nan's for object types with no boundbox.
- ENUM_FLAG type enums were showing no text when displayed in operator redo panel.

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bpy/utils.py
    trunk/blender/release/scripts/op/object_align.py
    trunk/blender/source/blender/blenlib/BLI_math_vector.h
    trunk/blender/source/blender/blenlib/intern/math_vector.c
    trunk/blender/source/blender/editors/interface/interface_utils.c
    trunk/blender/source/blender/makesrna/intern/rna_object.c

Modified: trunk/blender/release/scripts/modules/bpy/utils.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/utils.py	2010-12-19 01:59:52 UTC (rev 33775)
+++ trunk/blender/release/scripts/modules/bpy/utils.py	2010-12-19 07:05:29 UTC (rev 33776)
@@ -560,7 +560,7 @@
     keyconfigs.active = kc_new
 
 
-def user_resource(type, path, create=False):
+def user_resource(type, path="", create=False):
     """
     Return a user resource path (normally from the users home directory).
 
@@ -588,7 +588,7 @@
                     traceback.print_exc()
                     target_path = ""
             elif not _os.path.isdir(target_path):
-                print("Path %r found but isn't a directory!" % path)
+                print("Path %r found but isn't a directory!" % target_path)
                 target_path = ""
 
     return target_path

Modified: trunk/blender/release/scripts/op/object_align.py
===================================================================
--- trunk/blender/release/scripts/op/object_align.py	2010-12-19 01:59:52 UTC (rev 33775)
+++ trunk/blender/release/scripts/op/object_align.py	2010-12-19 07:05:29 UTC (rev 33776)
@@ -26,208 +26,215 @@
 
     cursor = bpy.context.scene.cursor_location
 
-    Left_Up_Front_SEL = [[], [], []]
-    Right_Down_Back_SEL = [[], [], []]
+    Left_Up_Front_SEL = [0.0, 0.0, 0.0]
+    Right_Down_Back_SEL = [0.0, 0.0, 0.0]
 
     flag_first = True
 
+    objs = []
+
     for obj in bpy.context.selected_objects:
-        if obj.type == 'MESH':
+        matrix_world = obj.matrix_world
+		bb_world = [Vector(v[:]) * matrix_world for v in obj.bound_box]
+        objs.append((obj, bb_world))
 
-            bb_world = [Vector(v[:]) * obj.matrix_world for v in obj.bound_box]
+    if not objs:
+        return False
 
-            Left_Up_Front = bb_world[1]
-            Right_Down_Back = bb_world[7]
+    for obj, bb_world in objs:
+        Left_Up_Front = bb_world[1]
+        Right_Down_Back = bb_world[7]
 
-            # Active Center
+        # Active Center
 
-            if obj == bpy.context.active_object:
+        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
+            center_active_x = (Left_Up_Front[0] + Right_Down_Back[0]) / 2.0
+            center_active_y = (Left_Up_Front[1] + Right_Down_Back[1]) / 2.0
+            center_active_z = (Left_Up_Front[2] + Right_Down_Back[2]) / 2.0
 
-                size_active_x = (Right_Down_Back[0] - Left_Up_Front[0]) / 2
-                size_active_y = (Right_Down_Back[1] - Left_Up_Front[1]) / 2
-                size_active_z = (Left_Up_Front[2] - Right_Down_Back[2]) / 2
+            size_active_x = (Right_Down_Back[0] - Left_Up_Front[0]) / 2.0
+            size_active_y = (Right_Down_Back[1] - Left_Up_Front[1]) / 2.0
+            size_active_z = (Left_Up_Front[2] - Right_Down_Back[2]) / 2.0
 
-            # Selection Center
+        # Selection Center
 
-            if flag_first:
-                flag_first = False
+        if flag_first:
+            flag_first = False
 
+            Left_Up_Front_SEL[0] = Left_Up_Front[0]
+            Left_Up_Front_SEL[1] = Left_Up_Front[1]
+            Left_Up_Front_SEL[2] = Left_Up_Front[2]
+
+            Right_Down_Back_SEL[0] = Right_Down_Back[0]
+            Right_Down_Back_SEL[1] = Right_Down_Back[1]
+            Right_Down_Back_SEL[2] = Right_Down_Back[2]
+
+        else:
+            # X axis
+            if Left_Up_Front[0] < Left_Up_Front_SEL[0]:
                 Left_Up_Front_SEL[0] = Left_Up_Front[0]
+            # Y axis
+            if Left_Up_Front[1] < Left_Up_Front_SEL[1]:
                 Left_Up_Front_SEL[1] = Left_Up_Front[1]
+            # Z axis
+            if Left_Up_Front[2] > Left_Up_Front_SEL[2]:
                 Left_Up_Front_SEL[2] = Left_Up_Front[2]
 
+            # X axis
+            if Right_Down_Back[0] > Right_Down_Back_SEL[0]:
                 Right_Down_Back_SEL[0] = Right_Down_Back[0]
+            # Y axis
+            if Right_Down_Back[1] > Right_Down_Back_SEL[1]:
                 Right_Down_Back_SEL[1] = Right_Down_Back[1]
+            # Z axis
+            if Right_Down_Back[2] < Right_Down_Back_SEL[2]:
                 Right_Down_Back_SEL[2] = Right_Down_Back[2]
 
-            else:
-                # X axis
-                if Left_Up_Front[0] < Left_Up_Front_SEL[0]:
-                    Left_Up_Front_SEL[0] = Left_Up_Front[0]
-                # Y axis
-                if Left_Up_Front[1] < Left_Up_Front_SEL[1]:
-                    Left_Up_Front_SEL[1] = Left_Up_Front[1]
-                # Z axis
-                if Left_Up_Front[2] > Left_Up_Front_SEL[2]:
-                    Left_Up_Front_SEL[2] = Left_Up_Front[2]
+    center_sel_x = (Left_Up_Front_SEL[0] + Right_Down_Back_SEL[0]) / 2.0
+    center_sel_y = (Left_Up_Front_SEL[1] + Right_Down_Back_SEL[1]) / 2.0
+    center_sel_z = (Left_Up_Front_SEL[2] + Right_Down_Back_SEL[2]) / 2.0
 
-                # X axis
-                if Right_Down_Back[0] > Right_Down_Back_SEL[0]:
-                    Right_Down_Back_SEL[0] = Right_Down_Back[0]
-                # Y axis
-                if Right_Down_Back[1] > Right_Down_Back_SEL[1]:
-                    Right_Down_Back_SEL[1] = Right_Down_Back[1]
-                # Z axis
-                if Right_Down_Back[2] < Right_Down_Back_SEL[2]:
-                    Right_Down_Back_SEL[2] = Right_Down_Back[2]
+    # Main Loop
 
-    center_sel_x = (Left_Up_Front_SEL[0] + Right_Down_Back_SEL[0]) / 2
-    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
+    for obj, bb_world in objs:
 
-    # Main Loop
+        loc_world = obj.location
+        bb_world = [Vector(v[:]) * obj.matrix_world for v in obj.bound_box]
 
-    for obj in bpy.context.selected_objects:
-        if obj.type == 'MESH':
+        Left_Up_Front = bb_world[1]
+        Right_Down_Back = bb_world[7]
 
-            loc_world = obj.location
-            bb_world = [Vector(v[:]) * obj.matrix_world for v in obj.bound_box]
+        center_x = (Left_Up_Front[0] + Right_Down_Back[0]) / 2.0
+        center_y = (Left_Up_Front[1] + Right_Down_Back[1]) / 2.0
+        center_z = (Left_Up_Front[2] + Right_Down_Back[2]) / 2.0
 
-            Left_Up_Front = bb_world[1]
-            Right_Down_Back = bb_world[7]
+        positive_x = Right_Down_Back[0]
+        positive_y = Right_Down_Back[1]
+        positive_z = Left_Up_Front[2]
 
-            center_x = (Left_Up_Front[0] + Right_Down_Back[0]) / 2
-            center_y = (Left_Up_Front[1] + Right_Down_Back[1]) / 2
-            center_z = (Left_Up_Front[2] + Right_Down_Back[2]) / 2
+        negative_x = Left_Up_Front[0]
+        negative_y = Left_Up_Front[1]
+        negative_z = Right_Down_Back[2]
 
-            positive_x = Right_Down_Back[0]
-            positive_y = Right_Down_Back[1]
-            positive_z = Left_Up_Front[2]
+        obj_loc = obj.location
 
-            negative_x = Left_Up_Front[0]
-            negative_y = Left_Up_Front[1]
-            negative_z = Right_Down_Back[2]
+        if align_x:
 
-            obj_loc = obj.location
+            # Align Mode
 
-            if align_x:
+            if relative_to == 'OPT_4': # Active relative
+                if align_mode == 'OPT_1':
+                    obj_x = obj_loc[0] - negative_x - size_active_x
 
-                # Align Mode
+                elif align_mode == 'OPT_3':
+                    obj_x = obj_loc[0] - positive_x + size_active_x
 
-                if relative_to == 'OPT_4': # Active relative
-                    if align_mode == 'OPT_1':
-                        obj_x = obj_loc[0] - negative_x - size_active_x
+            else: # Everything else relative
+                if align_mode == 'OPT_1':
+                    obj_x = obj_loc[0] - negative_x
 
-                    elif align_mode == 'OPT_3':
-                        obj_x = obj_loc[0] - positive_x + size_active_x
+                elif align_mode == 'OPT_3':
+                    obj_x = obj_loc[0] - positive_x
 
-                else: # Everything else relative
-                    if align_mode == 'OPT_1':
-                        obj_x = obj_loc[0] - negative_x
+            if align_mode == 'OPT_2': # All relative
+                obj_x = obj_loc[0] - center_x
 
-                    elif align_mode == 'OPT_3':
-                        obj_x = obj_loc[0] - positive_x
+            # Relative To
 
-                if align_mode == 'OPT_2': # All relative
-                    obj_x = obj_loc[0] - center_x
+            if relative_to == 'OPT_1':
+                loc_x = obj_x
 
-                # Relative To
+            elif relative_to == 'OPT_2':
+                loc_x = obj_x + cursor[0]
 
-                if relative_to == 'OPT_1':
-                    loc_x = obj_x
+            elif relative_to == 'OPT_3':
+                loc_x = obj_x + center_sel_x
 
-                elif relative_to == 'OPT_2':
-                    loc_x = obj_x + cursor[0]
+            elif relative_to == 'OPT_4':
+                loc_x = obj_x + center_active_x
 
-                elif relative_to == 'OPT_3':
-                    loc_x = obj_x + center_sel_x
+            obj.location[0] = loc_x
 
-                elif relative_to == 'OPT_4':
-                    loc_x = obj_x + center_active_x
 
-                obj.location[0] = loc_x
+        if align_y:
 
+            # Align Mode
 
-            if align_y:
+            if relative_to == 'OPT_4': # Active relative
+                if align_mode == 'OPT_1':
+                    obj_y = obj_loc[1] - negative_y - size_active_y
 
-                # Align Mode
+                elif align_mode == 'OPT_3':
+                    obj_y = obj_loc[1] - positive_y + size_active_y
 
-                if relative_to == 'OPT_4': # Active relative
-                    if align_mode == 'OPT_1':
-                        obj_y = obj_loc[1] - negative_y - size_active_y
+            else: # Everything else relative
+                if align_mode == 'OPT_1':
+                    obj_y = obj_loc[1] - negative_y
 
-                    elif align_mode == 'OPT_3':
-                        obj_y = obj_loc[1] - positive_y + size_active_y

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list