Dev:Py/Scripts/3D interaction/Copy Attributes Menu

提供: wiki
< Dev:Py‎ | Scripts‎ | 3D interaction
2015年12月28日 (月) 04:24時点におけるwiki>Brechtによる版 (moved Dev:2.5/Py/Scripts/3D interaction/Copy Attributes Menu to Dev:Py/Scripts/3D interaction/Copy Attributes Menu: remove version namespace)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Description

The addon creates per-mode menus (currently for object mode and pose mode) mapped to ctrl-c. Each menu-item is an operator, currently all ops are auto-generated. The goal is to replicate and perhaps extend the functionality of ctrl-c in 2.5, to ease transition / fill in missing functionality in 2.5 - I don't think the goal is to have this as a permanent default UI item.

Adding Functionality

Add a new tuple to pose_copies or object copies (or, if you are filiing in a blank, uncomment it). the first item of the tuple is a unique string that will be part of the operator ID, the second is the operator user readable name, the third is it's tooltip, and finally, the last item in the tuple is the function you will need to code to add functionality. To code the functions look at eg. obMas:

def obMas(ob, active, context):
    ob.game.mass = active.game.mass
    return('INFO', "mass copied")

You need to have the same arg. list (obj, active, context).. ob refers to one of the selected objects, active to the active object, and context is obvious.

For the pose functions it's the same, except we have pose bones instead of objects:

def pLocLocExec(bone, active, context):
    bone.location = active.location

Note that both bone and active are pose bones.

Issues/TODO

  • Missing functionality from 2.4
  • Per constraint and per modifier copying ala 2.4; I need to figure out how to build the list and allow user to select items from it
  • in the register() function is a horrible hack: Windows Machines need to register the dynamically generated ops, while linux users need to unregister and then register them again , in order for operators to be valid. This should all not be needed due to metaclassing.
  • Keymap registration and unregistration could be done more elegantly.