[Bf-extensions-cvs] [9d7cfcd8] master: Copy Attributes Menu: Add a message about needed selection, cleanup

lijenstina noreply at git.blender.org
Sat Oct 7 01:27:22 CEST 2017


Commit: 9d7cfcd8a9b5a07ba18626bde0490ea456a7f943
Author: lijenstina
Date:   Sat Oct 7 01:26:22 2017 +0200
Branches: master
https://developer.blender.org/rBA9d7cfcd8a9b5a07ba18626bde0490ea456a7f943

Copy Attributes Menu: Add a message about needed selection, cleanup

Bump version to 0.4.8

Pep 8 cleanup
Imports as tuples
Update wiki link
Consistent property definitions

Add a menu label info about the needed selection if poll is false
Add missing info strings to location, rotation an scale functions
Add separators for the Object mode CTRL + C menu

Fix the broken generation of Layer Menus by defining them explicitly
The code for registering menus was removed

===================================================================

M	space_view3d_copy_attributes.py

===================================================================

diff --git a/space_view3d_copy_attributes.py b/space_view3d_copy_attributes.py
index d171d2c2..7e810da1 100644
--- a/space_view3d_copy_attributes.py
+++ b/space_view3d_copy_attributes.py
@@ -21,17 +21,28 @@
 bl_info = {
     "name": "Copy Attributes Menu",
     "author": "Bassam Kurdali, Fabian Fricke, Adam Wiseman",
-    "version": (0, 4, 7),
+    "version": (0, 4, 8),
     "blender": (2, 63, 0),
     "location": "View3D > Ctrl-C",
     "description": "Copy Attributes Menu from Blender 2.4",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
                 "Scripts/3D_interaction/Copy_Attributes_Menu",
     "category": "3D View",
 }
 
 import bpy
 from mathutils import Matrix
+from bpy.types import (
+        Operator,
+        Menu,
+        )
+from bpy.props import (
+        BoolVectorProperty,
+        StringProperty,
+        )
+
+# First part of the operator Info message
+INFO_MESSAGE = "Copy Attributes: "
 
 
 def build_exec(loopfunc, func):
@@ -55,7 +66,7 @@ def build_invoke(loopfunc, func):
 def build_op(idname, label, description, fpoll, fexec, finvoke):
     """Generator function that returns the basic operator"""
 
-    class myopic(bpy.types.Operator):
+    class myopic(Operator):
         bl_idname = idname
         bl_label = label
         bl_description = description
@@ -66,7 +77,7 @@ def build_op(idname, label, description, fpoll, fexec, finvoke):
 
 
 def genops(copylist, oplist, prefix, poll_func, loopfunc):
-    """Generate ops from the copy list and its associated functions """
+    """Generate ops from the copy list and its associated functions"""
     for op in copylist:
         exec_func = build_exec(loopfunc, op[3])
         invoke_func = build_invoke(loopfunc, op[3])
@@ -76,7 +87,7 @@ def genops(copylist, oplist, prefix, poll_func, loopfunc):
 
 
 def generic_copy(source, target, string=""):
-    """ copy attributes from source to target that have string in them """
+    """Copy attributes from source to target that have string in them"""
     for attr in dir(source):
         if attr.find(string) > -1:
             try:
@@ -92,7 +103,7 @@ def getmat(bone, active, context, ignoreparent):
     """
     obj_act = context.active_object
     data_bone = obj_act.data.bones[bone.name]
-    #all matrices are in armature space unless commented otherwise
+    # all matrices are in armature space unless commented otherwise
     otherloc = active.matrix  # final 4x4 mat of target, location.
     bonemat_local = data_bone.matrix_local.copy()  # self rest matrix
     if data_bone.parent:
@@ -110,11 +121,11 @@ def getmat(bone, active, context, ignoreparent):
 
 
 def rotcopy(item, mat):
-    """copy rotation to item from matrix mat depending on item.rotation_mode"""
+    """Copy rotation to item from matrix mat depending on item.rotation_mode"""
     if item.rotation_mode == 'QUATERNION':
         item.rotation_quaternion = mat.to_3x3().to_quaternion()
     elif item.rotation_mode == 'AXIS_ANGLE':
-        rot = mat.to_3x3().to_quaternion().to_axis_angle()  # returns (Vector((x, y, z)), w)
+        rot = mat.to_3x3().to_quaternion().to_axis_angle()    # returns (Vector((x, y, z)), w)
         axis_angle = rot[1], rot[0][0], rot[0][1], rot[0][2]  # convert to w, x, y, z
         item.rotation_axis_angle = axis_angle
     else:
@@ -129,8 +140,8 @@ def pLoopExec(self, context, funk):
     for bone in selected:
         funk(bone, active, context)
 
-#The following functions are used o copy attributes frome active to bone
 
+# The following functions are used o copy attributes frome active to bone
 
 def pLocLocExec(bone, active, context):
     bone.location = active.location
@@ -178,7 +189,7 @@ def pLokExec(bone, active, context):
 
 
 def pConExec(bone, active, context):
-    for old_constraint in  active.constraints.values():
+    for old_constraint in active.constraints.values():
         new_constraint = bone.constraints.new(old_constraint.type)
         generic_copy(old_constraint, new_constraint)
 
@@ -194,28 +205,31 @@ def pBBonesExec(bone, active, context):
         object.data.bones[bone.name],
         "bbone_")
 
-pose_copies = (('pose_loc_loc', "Local Location",
-                "Copy Location from Active to Selected", pLocLocExec),
-                ('pose_loc_rot', "Local Rotation",
-                "Copy Rotation from Active to Selected", pLocRotExec),
-                ('pose_loc_sca', "Local Scale",
-                "Copy Scale from Active to Selected", pLocScaExec),
-                ('pose_vis_loc', "Visual Location",
-                "Copy Location from Active to Selected", pVisLocExec),
-                ('pose_vis_rot', "Visual Rotation",
-                "Copy Rotation from Active to Selected", pVisRotExec),
-                ('pose_vis_sca', "Visual Scale",
-                "Copy Scale from Active to Selected", pVisScaExec),
-                ('pose_drw', "Bone Shape",
-                "Copy Bone Shape from Active to Selected", pDrwExec),
-                ('pose_lok', "Protected Transform",
-                "Copy Protected Tranforms from Active to Selected", pLokExec),
-                ('pose_con', "Bone Constraints",
-                "Copy Object Constraints from Active to Selected", pConExec),
-                ('pose_iks', "IK Limits",
-                "Copy IK Limits from Active to Selected", pIKsExec),
-                ('bbone_settings', "BBone Settings",
-                "Copy BBone Settings from Active to Selected", pBBonesExec),)
+
+pose_copies = (
+        ('pose_loc_loc', "Local Location",
+        "Copy Location from Active to Selected", pLocLocExec),
+        ('pose_loc_rot', "Local Rotation",
+        "Copy Rotation from Active to Selected", pLocRotExec),
+        ('pose_loc_sca', "Local Scale",
+        "Copy Scale from Active to Selected", pLocScaExec),
+        ('pose_vis_loc', "Visual Location",
+        "Copy Location from Active to Selected", pVisLocExec),
+        ('pose_vis_rot', "Visual Rotation",
+        "Copy Rotation from Active to Selected", pVisRotExec),
+        ('pose_vis_sca', "Visual Scale",
+        "Copy Scale from Active to Selected", pVisScaExec),
+        ('pose_drw', "Bone Shape",
+        "Copy Bone Shape from Active to Selected", pDrwExec),
+        ('pose_lok', "Protected Transform",
+        "Copy Protected Tranforms from Active to Selected", pLokExec),
+        ('pose_con', "Bone Constraints",
+        "Copy Object Constraints from Active to Selected", pConExec),
+        ('pose_iks', "IK Limits",
+        "Copy IK Limits from Active to Selected", pIKsExec),
+        ('bbone_settings', "BBone Settings",
+        "Copy BBone Settings from Active to Selected", pBBonesExec),
+        )
 
 
 @classmethod
@@ -229,11 +243,15 @@ def pose_invoke_func(self, context, event):
     return {'RUNNING_MODAL'}
 
 
-class CopySelectedPoseConstraints(bpy.types.Operator):
+class CopySelectedPoseConstraints(Operator):
     """Copy Chosen constraints from active to selected"""
     bl_idname = "pose.copy_selected_constraints"
     bl_label = "Copy Selected Constraints"
-    selection = bpy.props.BoolVectorProperty(size=32, options={'SKIP_SAVE'})
+
+    selection = BoolVectorProperty(
+            size=32,
+            options={'SKIP_SAVE'}
+            )
 
     poll = pose_poll_func
     invoke = pose_invoke_func
@@ -252,17 +270,18 @@ class CopySelectedPoseConstraints(bpy.types.Operator):
             for index, flag in enumerate(self.selection):
                 if flag:
                     old_constraint = active.constraints[index]
-                    new_constraint = bone.constraints.new(\
-                       active.constraints[index].type)
+                    new_constraint = bone.constraints.new(
+                                        active.constraints[index].type
+                                        )
                     generic_copy(old_constraint, new_constraint)
         return {'FINISHED'}
 
-pose_ops = []  # list of pose mode copy operators
 
+pose_ops = []  # list of pose mode copy operators
 genops(pose_copies, pose_ops, "pose.copy_", pose_poll_func, pLoopExec)
 
 
-class VIEW3D_MT_posecopypopup(bpy.types.Menu):
+class VIEW3D_MT_posecopypopup(Menu):
     bl_label = "Copy Attributes"
 
     def draw(self, context):
@@ -283,7 +302,7 @@ def obLoopExec(self, context, funk):
     for obj in selected:
         msg = funk(obj, active, context)
     if msg:
-        self.report({msg[0]}, msg[1])
+        self.report({msg[0]}, INFO_MESSAGE + msg[1])
 
 
 def world_to_basis(active, ob, context):
@@ -293,9 +312,9 @@ def world_to_basis(active, ob, context):
     mat = P * local
     return(mat)
 
-#The following functions are used o copy attributes from
-#active to selected object
 
+# The following functions are used o copy attributes from
+# active to selected object
 
 def obLoc(ob, active, context):
     ob.location = active.location
@@ -315,6 +334,7 @@ def obVisLoc(ob, active, context):
         ob.location = mat.to_translation()
     else:
         ob.location = active.matrix_world.to_translation()
+    return('INFO', "Object location copied")
 
 
 def obVisRot(ob, active, context):
@@ -323,6 +343,7 @@ def obVisRot(ob, active, context):
         rotcopy(ob, mat.to_3x3())
     else:
         rotcopy(ob, active.matrix_world.to_3x3())
+    return('INFO', "Object rotation copied")
 
 
 def obVisSca(ob, active, context):
@@ -331,6 +352,7 @@ def obVisSca(ob, active, context):
         ob.scale = mat.to_scale()
     else:
         ob.scale = active.matrix_world.to_scale()
+    return('INFO', "Object scale copied")
 
 
 def obDrw(ob, active, context):
@@ -349,12 +371,12 @@ def obDrw(ob, active, context):
 
 def obOfs(ob, active, context):
     ob.time_offset = active.time_offset
-    return('INFO', "time offset copied")
+    return('INFO', "Time offset copied")
 
 
 def obDup(ob, active, context):
     generic_copy(active, ob, "dupli")
-    return('INFO', "duplication method copied")
+    return('INFO', "Duplication method copied")
 
 
 def obCol(ob, active, context):
@@ -363,7 +385,7 @@ def obCol(ob, active, context):
 
 def obMas(ob, active, context):
     ob.game.mass = active.game.m

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list