[Python] Add all selected bones to a new Keying Set

Hi everybody! This time I’d like to share with you all a script that I’ve made to help and boost the animation process in Blender 2.5 – 2.6 – 2.7

Keying_Set_Panel

In order to animate a character or any armature, is easy and fast to use animation shortcuts combined with the character’s keying sets. A Keying Set in Blender is a bunch of properties aggregated with a common name that allows the user to create new keyframest of all that properties just by pressing the key I with the proper keying set selected.

Overview

This script will create the keying set for the selected bones to animate easily and faster  your customized group of bones.

 

Armature example from CG Cookie Flex Rig
Armature example from CG Cookie Flex Rig

 

Infact it will create a new custom keying set in an armature, allowing you to keyframe location, rotation and scale of the selected bones

Example of some properties stored into a keying set

Some loc/rot/scale properties may be locked, so if all channels for a property are locked, that property will be excluded from the keying set.

The script

[http://www.pasteall.org/51874/python]

#############################################
''' 
Selected bones to keying set A script by blenderprops.altervista.org
'''
#############################################


# Keying Set: KeyingSet
import bpy


scene = bpy.context.scene


# Keying Set Level declarations
ks = scene.keying_sets.new(idname="KeyingSet", name="Rename_KeyingSet")
ks.bl_description = ""


ks.bl_options = {'INSERTKEY_XYZ_TO_RGB'}


# ID's that are commonly used (nome dell'armatura)
id_0 = bpy.context.selected_pose_bones[0].id_data


#Elenco delle bones
selected_bones = bpy.context.selected_pose_bones




for bo in selected_bones:
    bonename = bo.name
    if bo.lock_location[0] == False or bo.lock_location[1] == False or bo.lock_location[2] == False:
        ksp = ks.paths.add(id_0, 'pose.bones["'+bonename+'"].location', index=-1)
        
    if bo.lock_rotation_w == False or bo.lock_rotation[0] == False or bo.lock_rotation[1] == False or bo.lock_rotation[2] == False:
        ksp = ks.paths.add(id_0, 'pose.bones["'+bonename+'"].rotation_euler', index=-1)
        
    if bo.lock_scale[0] == False or bo.lock_scale[1] == False or bo.lock_scale[2] == False:
        ksp = ks.paths.add(id_0, 'pose.bones["'+bonename+'"].scale', index=-1)

How to use it

In order to create a keying set of the selected bones of a specific character:

  • Select all the bones of interest (eg the shapes of the face rig)
  • Just copy and paste the script into a text view inside Blender
  • Press “Run script”
  • Into the relative panel, rename the keying set changing the string “Rename_KeyingSet” (eh with Face_rig)

 

That’s all! Hope you’ll find this useful! For feature requests, questions or any trouble just ask me with a comment!

2 Risposte a “[Python] Add all selected bones to a new Keying Set”

  1. Thanks for the tutorial! I had a heck of a time finding it, though, since it was removed from Google due to a DMCA takedown notice by Fox Broadcasting (line 319 of the complaint; because they were taking down anything that might refer to their television show “Bones”, among others, and apparently delegated their research to a team of particularly dimwitted Rhesus monkeys).

    Anyway, your script was exactly what I was looking for (manipulating all selected bones), so you might want to send them a counter-notice to get it back into their search results, so other people looking for the same information will have an easier time of it.

  2. Really glad that the script is useful! I’ve told to the fox monkeys to dig a little bit more before removing posts from Google.. Thanks for reporting this!

    Sparazza

Rispondi a Anonimo Annulla risposta

Il tuo indirizzo email non sarà pubblicato.


*