[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30647] trunk/blender/release/scripts/op/ object.py: fix for error in select hierarchy if no children exist.

Campbell Barton ideasman42 at gmail.com
Fri Jul 23 07:49:14 CEST 2010


Revision: 30647
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30647
Author:   campbellbarton
Date:     2010-07-23 07:49:12 +0200 (Fri, 23 Jul 2010)

Log Message:
-----------
fix for error in select hierarchy if no children exist.

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

Modified: trunk/blender/release/scripts/op/object.py
===================================================================
--- trunk/blender/release/scripts/op/object.py	2010-07-23 05:31:11 UTC (rev 30646)
+++ trunk/blender/release/scripts/op/object.py	2010-07-23 05:49:12 UTC (rev 30647)
@@ -113,46 +113,48 @@
         return context.object
 
     def execute(self, context):
-        objs = context.selected_objects
+        select_new = []
+        act_new = None
+        
+        
+        selected_objects = context.selected_objects
         obj_act = context.object
 
-        if context.object not in objs:
-            objs.append(context.object)
+        if context.object not in selected_objects:
+            selected_objects.append(context.object)
 
-        if not self.properties.extend:
-            # for obj in objs:
-            #     obj.select = False
-            bpy.ops.object.select_all(action='DESELECT')
-
         if self.properties.direction == 'PARENT':
-            parents = []
-            for obj in objs:
+            for obj in selected_objects:
                 parent = obj.parent
 
                 if parent:
-                    parents.append(parent)
-
                     if obj_act == obj:
-                        context.scene.objects.active = parent
+                        act_new = parent
 
-                    parent.select = True
-                
-            if parents:
-                return {'CANCELLED'}
+                    select_new.append(parent)
 
         else:
-            children = []
-            for obj in objs:
-                children += list(obj.children)
-                for obj_iter in children:
-                    obj_iter.select = True
+            for obj in selected_objects:
+                select_new.extend(obj.children)
 
-            children.sort(key=lambda obj_iter: obj_iter.name)
-            context.scene.objects.active = children[0]
+            if select_new:
+                select_new.sort(key=lambda obj_iter: obj_iter.name)
+                act_new = select_new[0]
 
-        return {'FINISHED'}
+        # dont edit any object settings above this
+        if select_new:
+            if not self.properties.extend:
+                bpy.ops.object.select_all(action='DESELECT')
 
+            for obj in select_new:
+                obj.select = True
 
+            context.scene.objects.active = act_new
+            return {'FINISHED'}
+            
+        return {'CANCELLED'}
+
+
 class SubdivisionSet(bpy.types.Operator):
     '''Sets a Subdivision Surface Level (1-5)'''
 





More information about the Bf-blender-cvs mailing list