[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38779] trunk/blender/release/scripts/ startup/bl_operators/object.py: fix [#28095] Select Pattern don' t select all the bone in edit mode

Campbell Barton ideasman42 at gmail.com
Thu Jul 28 09:55:10 CEST 2011


Revision: 38779
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38779
Author:   campbellbarton
Date:     2011-07-28 07:55:09 +0000 (Thu, 28 Jul 2011)
Log Message:
-----------
fix [#28095] Select Pattern don't select all the bone in edit mode
& some style changes.

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

Modified: trunk/blender/release/scripts/startup/bl_operators/object.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/object.py	2011-07-28 07:10:39 UTC (rev 38778)
+++ trunk/blender/release/scripts/startup/bl_operators/object.py	2011-07-28 07:55:09 UTC (rev 38779)
@@ -16,7 +16,7 @@
 #
 # ##### END GPL LICENSE BLOCK #####
 
-# <pep8 compliant>
+# <pep8-80 compliant>
 
 import bpy
 from bpy.props import StringProperty, BoolProperty, EnumProperty, IntProperty
@@ -54,22 +54,36 @@
         else:
             pattern_match = (lambda a, b:
                                  fnmatch.fnmatchcase(a.upper(), b.upper()))
-
+        is_ebone = False
         obj = context.object
         if obj and obj.mode == 'POSE':
             items = obj.data.bones
+            if not self.extend:
+                bpy.ops.pose.select_all(action='DESELECT')
         elif obj and obj.type == 'ARMATURE' and obj.mode == 'EDIT':
             items = obj.data.edit_bones
+            if not self.extend:
+                bpy.ops.armature.select_all(action='DESELECT')
+            is_ebone = True
         else:
             items = context.visible_objects
+            if not self.extend:
+                bpy.ops.object.select_all(action='DESELECT')
 
         # Can be pose bones or objects
         for item in items:
             if pattern_match(item.name, self.pattern):
                 item.select = True
-            elif not self.extend:
-                item.select = False
 
+                # hrmf, perhaps there should be a utility function for this.
+                if is_ebone:
+                    item.select_head = True
+                    item.select_tail = True
+                    if item.use_connect:
+                        item_parent = item.parent
+                        if item_parent is not None:
+                            item_parent.select_tail = True
+
         return {'FINISHED'}
 
     def invoke(self, context, event):
@@ -107,7 +121,8 @@
 
 
 class SelectHierarchy(bpy.types.Operator):
-    '''Select object relative to the active objects position in the hierarchy'''
+    '''Select object relative to the active objects position''' \
+    '''in the hierarchy'''
     bl_idname = "object.select_hierarchy"
     bl_label = "Select Hierarchy"
     bl_options = {'REGISTER', 'UNDO'}
@@ -332,53 +347,90 @@
             ob_add_shape(ob_other, orig_key_name)
 
             # editing the final coords, only list that stores wrapped coords
-            target_shape_coords = [v.co for v in ob_other.active_shape_key.data]
+            target_shape_coords = [v.co for v in
+                                   ob_other.active_shape_key.data]
 
             median_coords = [[] for i in range(len(me.vertices))]
 
             # Method 1, edge
             if mode == 'OFFSET':
                 for i, vert_cos in enumerate(median_coords):
-                    vert_cos.append(target_coords[i] + (orig_shape_coords[i] - orig_coords[i]))
+                    vert_cos.append(target_coords[i] +
+                                    (orig_shape_coords[i] - orig_coords[i]))
 
             elif mode == 'RELATIVE_FACE':
                 for face in me.faces:
                     i1, i2, i3, i4 = face.vertices_raw
                     if i4 != 0:
                         pt = barycentric_transform(orig_shape_coords[i1],
-                            orig_coords[i4], orig_coords[i1], orig_coords[i2],
-                            target_coords[i4], target_coords[i1], target_coords[i2])
+                                                   orig_coords[i4],
+                                                   orig_coords[i1],
+                                                   orig_coords[i2],
+                                                   target_coords[i4],
+                                                   target_coords[i1],
+                                                   target_coords[i2],
+                                                   )
                         median_coords[i1].append(pt)
 
                         pt = barycentric_transform(orig_shape_coords[i2],
-                            orig_coords[i1], orig_coords[i2], orig_coords[i3],
-                            target_coords[i1], target_coords[i2], target_coords[i3])
+                                                   orig_coords[i1],
+                                                   orig_coords[i2],
+                                                   orig_coords[i3],
+                                                   target_coords[i1],
+                                                   target_coords[i2],
+                                                   target_coords[i3],
+                                                   )
                         median_coords[i2].append(pt)
 
                         pt = barycentric_transform(orig_shape_coords[i3],
-                            orig_coords[i2], orig_coords[i3], orig_coords[i4],
-                            target_coords[i2], target_coords[i3], target_coords[i4])
+                                                   orig_coords[i2],
+                                                   orig_coords[i3],
+                                                   orig_coords[i4],
+                                                   target_coords[i2],
+                                                   target_coords[i3],
+                                                   target_coords[i4],
+                                                   )
                         median_coords[i3].append(pt)
 
                         pt = barycentric_transform(orig_shape_coords[i4],
-                            orig_coords[i3], orig_coords[i4], orig_coords[i1],
-                            target_coords[i3], target_coords[i4], target_coords[i1])
+                                                   orig_coords[i3],
+                                                   orig_coords[i4],
+                                                   orig_coords[i1],
+                                                   target_coords[i3],
+                                                   target_coords[i4],
+                                                   target_coords[i1],
+                                                   )
                         median_coords[i4].append(pt)
 
                     else:
                         pt = barycentric_transform(orig_shape_coords[i1],
-                            orig_coords[i3], orig_coords[i1], orig_coords[i2],
-                            target_coords[i3], target_coords[i1], target_coords[i2])
+                                                   orig_coords[i3],
+                                                   orig_coords[i1],
+                                                   orig_coords[i2],
+                                                   target_coords[i3],
+                                                   target_coords[i1],
+                                                   target_coords[i2],
+                                                   )
                         median_coords[i1].append(pt)
 
                         pt = barycentric_transform(orig_shape_coords[i2],
-                            orig_coords[i1], orig_coords[i2], orig_coords[i3],
-                            target_coords[i1], target_coords[i2], target_coords[i3])
+                                                   orig_coords[i1],
+                                                   orig_coords[i2],
+                                                   orig_coords[i3],
+                                                   target_coords[i1],
+                                                   target_coords[i2],
+                                                   target_coords[i3],
+                                                   )
                         median_coords[i2].append(pt)
 
                         pt = barycentric_transform(orig_shape_coords[i3],
-                            orig_coords[i2], orig_coords[i3], orig_coords[i1],
-                            target_coords[i2], target_coords[i3], target_coords[i1])
+                                                   orig_coords[i2],
+                                                   orig_coords[i3],
+                                                   orig_coords[i1],
+                                                   target_coords[i2],
+                                                   target_coords[i3],
+                                                   target_coords[i1],
+                                                   )
                         median_coords[i3].append(pt)
 
             elif mode == 'RELATIVE_EDGE':
@@ -416,7 +468,8 @@
                     if use_clamp:
                         # clamp to the same movement as the original
                         # breaks copy between different scaled meshes.
-                        len_from = (orig_shape_coords[i] - orig_coords[i]).length
+                        len_from = (orig_shape_coords[i] -
+                                    orig_coords[i]).length
                         ofs = co - target_coords[i]
                         ofs.length = len_from
                         co = target_coords[i] + ofs
@@ -498,7 +551,13 @@
                             mesh_other.tag = True
 
                             if len(mesh_other.faces) != len_faces:
-                                self.report({'WARNING'}, "Object: %s, Mesh: '%s' has %d faces, expected %d\n" % (obj_other.name, mesh_other.name, len(mesh_other.faces), len_faces))
+                                self.report({'WARNING'}, "Object: %s, Mesh: "
+                                            "'%s' has %d faces, expected %d\n"
+                                            % (obj_other.name,
+                                               mesh_other.name,
+                                               len(mesh_other.faces),
+                                               len_faces),
+                                               )
                             else:
                                 uv_other = mesh_other.uv_textures.active
                                 if not uv_other:




More information about the Bf-blender-cvs mailing list