[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2839] trunk/py/scripts/addons/ space_view3d_copy_attributes.py: a little nicer use of matrix types, no functional changes

Campbell Barton ideasman42 at gmail.com
Sat Dec 31 10:59:41 CET 2011


Revision: 2839
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2839
Author:   campbellbarton
Date:     2011-12-31 09:59:39 +0000 (Sat, 31 Dec 2011)
Log Message:
-----------
a little nicer use of matrix types, no functional changes

Modified Paths:
--------------
    trunk/py/scripts/addons/space_view3d_copy_attributes.py

Modified: trunk/py/scripts/addons/space_view3d_copy_attributes.py
===================================================================
--- trunk/py/scripts/addons/space_view3d_copy_attributes.py	2011-12-31 09:52:48 UTC (rev 2838)
+++ trunk/py/scripts/addons/space_view3d_copy_attributes.py	2011-12-31 09:59:39 UTC (rev 2839)
@@ -26,10 +26,10 @@
     "api": 42846,
     'location': 'View3D > Ctrl-C',
     'description': 'Copy Attributes Menu from Blender 2.4',
-    'wiki_url': 'http://wiki.blender.org/index.php/Extensions:2.5/Py/'\
-        'Scripts/3D_interaction/Copy_Attributes_Menu',
-    'tracker_url': 'https://projects.blender.org/tracker/index.php?'\
-        'func=detail&aid=22588',
+    'wiki_url': 'http://wiki.blender.org/index.php/Extensions:2.5/Py/'
+                'Scripts/3D_interaction/Copy_Attributes_Menu',
+    'tracker_url': 'https://projects.blender.org/tracker/index.php?'
+                   'func=detail&aid=22588',
     'category': '3D View'}
 
 import bpy
@@ -92,14 +92,14 @@
     '''Helper function for visual transform copy,
        gets the active transform in bone space
     '''
-    data_bone = context.active_object.data.bones[bone.name]
+    obj_act = context.active_object
+    data_bone = obj_act.data.bones[bone.name]
     #all matrices are in armature space unless commented otherwise
     otherloc = active.matrix  # final 4x4 mat of target, location.
-    bonemat_local = Matrix(data_bone.matrix_local)  # self rest matrix
+    bonemat_local = data_bone.matrix_local.copy()  # self rest matrix
     if data_bone.parent:
-        parentposemat = Matrix(
-           context.active_object.pose.bones[data_bone.parent.name].matrix)
-        parentbonemat = Matrix(data_bone.parent.matrix_local)
+        parentposemat = obj_act.pose.bones[data_bone.parent.name].matrix.copy()
+        parentbonemat = data_bone.parent.matrix_local.copy()
     else:
         parentposemat = parentbonemat = Matrix()
     if parentbonemat == parentposemat or ignoreparent:
@@ -117,8 +117,7 @@
         item.rotation_quaternion = mat.to_3x3().to_quaternion()
     elif item.rotation_mode == 'AXIS_ANGLE':
         quat = mat.to_3x3().to_quaternion()
-        item.rotation_axis_angle = Vector([quat.axis[0],
-           quat.axis[1], quat.axis[2], quat.angle])
+        item.rotation_axis_angle = quat.axis[:] + (quat.angle, )
     else:
         item.rotation_euler = mat.to_3x3().to_euler(item.rotation_mode)
 



More information about the Bf-extensions-cvs mailing list