[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1060] trunk/py/scripts/addons/ space_view3d_copy_attributes.py: SVN maintenance.

gsr b3d gsr.b3d at infernal-iceberg.com
Sat Sep 18 06:29:52 CEST 2010


Revision: 1060
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1060
Author:   gsrb3d
Date:     2010-09-18 06:29:49 +0200 (Sat, 18 Sep 2010)

Log Message:
-----------
SVN maintenance.

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

Property Changed:
----------------
    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	2010-09-18 03:48:35 UTC (rev 1059)
+++ trunk/py/scripts/addons/space_view3d_copy_attributes.py	2010-09-18 04:29:49 UTC (rev 1060)
@@ -1,764 +1,764 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-#  This program is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU General Public License
-#  as published by the Free Software Foundation; either version 2
-#  of the License, or (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#
-#  You should have received a copy of the GNU General Public License
-#  along with this program; if not, write to the Free Software Foundation,
-#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-# <pep8 compliant>
-
-bl_addon_info = {
-    'name': 'Copy Attributes Menu',
-    'author': 'Bassam Kurdali, Fabian Fricke, wiseman303',
-    'version': (0, 40),
-    'blender': (2, 5, 4),
-    'api': 31989,
-    '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&group_id=153&atid=468',
-    'category': '3D View'}
-
-__bpydoc__ = """
-Copy Menu
-
-
-"""
-import bpy
-import mathutils
-from mathutils import *
-
-
-def build_exec(loopfunc, func):
-    '''Generator function that returns exec functions for operators '''
-
-    def exec_func(self, context):
-        loopfunc(self, context, func)
-        return {'FINISHED'}
-    return exec_func
-
-
-def build_invoke(loopfunc, func):
-    '''Generator function that returns invoke functions for operators'''
-
-    def invoke_func(self, context, event):
-        loopfunc(self, context, func)
-        return {'FINISHED'}
-    return invoke_func
-
-
-def build_op(idname, label, description, fpoll, fexec, finvoke):
-    '''Generator function that returns the basic operator'''
-
-    class myopic(bpy.types.Operator):
-        bl_idname = idname
-        bl_label = label
-        bl_description = description
-        execute = fexec
-        poll = fpoll
-        invoke = finvoke
-    return myopic
-
-
-def genops(copylist, oplist, prefix, poll_func, loopfunc):
-    '''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])
-        opclass = build_op(prefix + op[0], "Copy " + op[1], op[2],
-           poll_func, exec_func, invoke_func)
-        oplist.append(opclass)
-
-
-def generic_copy(source, target, string=""):
-    ''' copy attributes from source to target that have string in them '''
-    for attr in dir(source):
-        if attr.find(string) > -1:
-            try:
-                setattr(target, attr, getattr(source, attr))
-            except:
-                pass
-    return
-
-
-def getmat(bone, active, context, ignoreparent):
-    '''Helper function for visual transform copy,
-       gets the active transform in bone space
-    '''
-    data_bone = context.active_object.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
-    if data_bone.parent:
-        parentposemat = Matrix(
-           context.active_object.pose.bones[data_bone.parent.name].matrix)
-        parentbonemat = Matrix(data_bone.parent.matrix_local)
-    else:
-        parentposemat = bonemat_local.copy().identity()
-        parentbonemat = bonemat_local.copy().identity()
-    if parentbonemat == parentposemat or ignoreparent:
-        newmat = bonemat_local.invert() * otherloc
-    else:
-        bonemat = parentbonemat.invert() * bonemat_local
-
-        newmat = bonemat.invert() * parentposemat.invert() * otherloc
-    return newmat
-
-
-def rotcopy(item, mat):
-    '''copy rotation to item from matrix mat depending on item.rotation_mode'''
-    if item.rotation_mode == 'QUATERNION':
-        item.rotation_quaternion = mat.rotation_part().to_quat()
-    elif item.rotation_mode == 'AXIS_ANGLE':
-        quat = mat.rotation_part().to_quat()
-        item.rotation_axis_angle = Vector([quat.axis[0],
-           quat.axis[1], quat.axis[2], quat.angle])
-    else:
-        item.rotation_euler = mat.rotation_part().to_euler(item.rotation_mode)
-
-
-def pLoopExec(self, context, funk):
-    '''Loop over selected bones and execute funk on them'''
-    active = context.active_pose_bone
-    selected = context.selected_pose_bones
-    selected.remove(active)
-    for bone in selected:
-        funk(bone, active, context)
-
-#The following functions are used o copy attributes frome active to bone
-
-
-def pLocLocExec(bone, active, context):
-    bone.location = active.location
-
-
-def pLocRotExec(bone, active, context):
-    rotcopy(bone, active.matrix_local.rotation_part())
-
-
-def pLocScaExec(bone, active, context):
-    bone.scale = active.scale
-
-
-def pVisLocExec(bone, active, context):
-    bone.location = getmat(bone, active, context, False).translation_part()
-
-
-def pVisRotExec(bone, active, context):
-    rotcopy(bone, getmat(bone, active,
-      context, not context.active_object.data.bones[bone.name].use_hinge))
-
-
-def pVisScaExec(bone, active, context):
-    bone.scale = getmat(bone, active, context,
-       not context.active_object.data.bones[bone.name].use_inherit_scale)\
-          .scale_part()
-
-
-def pDrwExec(bone, active, context):
-    bone.custom_shape = active.custom_shape
-
-
-def pLokExec(bone, active, context):
-    for index, state in enumerate(active.lock_location):
-        bone.lock_location[index] = state
-    for index, state in enumerate(active.lock_rotation):
-        bone.lock_rotation[index] = state
-    bone.lock_rotations_4d = active.lock_rotations_4d
-    bone.lock_rotation_w = active.lock_rotation_w
-    for index, state in enumerate(active.lock_scale):
-        bone.lock_scale[index] = state
-
-
-def pConExec(bone, active, context):
-    for old_constraint in  active.constraints.values():
-        new_constraint = bone.constraints.new(old_constraint.type)
-        generic_copy(old_constraint, new_constraint)
-
-
-def pIKsExec(bone, active, context):
-    generic_copy(active, bone, "ik_")
-
-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))
-
-
- at classmethod
-def pose_poll_func(cls, context):
-    return(context.mode == 'POSE')
-
-
-def pose_invoke_func(self, context, event):
-    wm = context.window_manager
-    wm.invoke_props_dialog(self)
-    return {'RUNNING_MODAL'}
-
-
-class CopySelectedPoseConstraints(bpy.types.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)
-
-    poll = pose_poll_func
-    invoke = pose_invoke_func
-
-    def draw(self, context):
-        layout = self.layout
-        props = self.properties
-        for idx, const in enumerate(context.active_pose_bone.constraints):
-            layout.prop(props, 'selection', index=idx, text=const.name,
-               toggle=True)
-
-    def execute(self, context):
-        active = context.active_pose_bone
-        selected = context.selected_pose_bones[:]
-        selected.remove(active)
-        for bone in selected:
-            for index, flag in enumerate(self.selection):
-                if flag:
-                    old_constraint = active.constraints[index]
-                    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
-
-genops(pose_copies, pose_ops, "pose.copy_", pose_poll_func, pLoopExec)
-
-
-class VIEW3D_MT_posecopypopup(bpy.types.Menu):
-    bl_label = "Copy Attributes"
-
-    def draw(self, context):
-        layout = self.layout
-        layout.operator_context = 'INVOKE_REGION_WIN'
-        for op in pose_copies:
-            layout.operator("pose.copy_" + op[0])
-        layout.operator("pose.copy_selected_constraints")
-        layout.operator("pose.copy", text="copy pose")
-
-
-def obLoopExec(self, context, funk):
-    '''Loop over selected objects and execute funk on them'''
-    active = context.active_object
-    selected = context.selected_objects[:]
-    selected.remove(active)
-    for obj in selected:
-        msg = funk(obj, active, context)
-    if msg:
-        self.report({msg[0]}, msg[1])
-
-#The following functions are used o copy attributes from
-#active to selected object
-
-
-def obLoc(ob, active, context):
-    ob.location = active.location
-
-

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list