Skip to content

Instantly share code, notes, and snippets.

@pcote
Last active September 26, 2016 00:31
Show Gist options
  • Save pcote/5af6a1087d03aed6fae15e59b2b240ab to your computer and use it in GitHub Desktop.
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.
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