Last active
September 26, 2016 00:31
-
-
Save pcote/5af6a1087d03aed6fae15e59b2b240ab to your computer and use it in GitHub Desktop.
Blender addon script that toggles the extremeties (ie childless bones) of an armature.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
class ToggleExtremeties(bpy.types.Operator): | |
""" | |
Toggle whether or not to show or hide the extremity bones. | |
(ie the bones that don't have any children.) | |
""" | |
bl_idname = "armature.toggle_extremeties" | |
bl_label = "Toggle Bone Extremeties" | |
@classmethod | |
def poll(cls, cxt): | |
return cxt.active_object.type == "ARMATURE" | |
def execute(self, cxt): | |
skel = cxt.active_object | |
childless_bones = [b for b in skel.data.bones | |
if len(b.children) == 0] | |
for bone in childless_bones: | |
bone.hide = not bone.hide | |
return {"FINISHED"} | |
if __name__ == '__main__': | |
bpy.utils.register_class(ToggleExtremeties) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment