Simple Ui panel Information

This should be simple one for some of you experienced scritpers out there. I am finishing up a rig. I simple need panels for turning on and off the bone layers and panels for sets of shape keys. I would like these to be accessible from posemode. I have tried to follow a few tutorials and tried editing some examples but just can’t seem to get in to work. Could you give me the basic outline of the script? I think that something may have changed in the scripting because some of the tutorial files don’t even work now. Thanks

Also if there is a site that explains these principles well please let me know. I have programed before but can’t seem to make heads or tails of the api information.


do you want a button to turn on/off all bone layers of active object at once?

not sure about shape keys… armatures/bones don’t support them, do you mean the shapekeys of the mesh object, which is parented to the armature you work with?

I hear ya, Monte. I’ve learned and worked with over a dozen different programming languages over the last twenty-odd years, but the Blender Python API just mystifies me. Perhaps the trouble is that I have to learn Python at the same time as learning Blender’s subset/variation of the language.

Anyway, you’re not alone in this.

I need button for each bone layer I have bones on, to turn them on and off (view) and panels for sliders for different sets of shapekeys that I am not controlling with bones. If I could get an example of each that is well labeled (documented ) I think I could go from there.


Layers ARE available in pose mode?!

Still don’t understand shapekeys… they aren’t part of an armature, do you want a panel to show the shapekeys of something else but the active armature object? How to know which object to use??

I Understand they are available in pose mode. I need the Panel Available in posemode too. This requires and certain line in the script. I just want the panel for the shapekeys available in posemode so you can pose the facial parts they work with. I’m not looking to see how to do it but rather how to script a panel showing them.

@ @Sackadoo
Heck I have even programed in python a little for creating custome ui panels in maya. There has to be a good set of tutorials out there somewhere.

Well, if all you want to do is build a panel with buttons to turn bone layers on and off…

Here is part of the script generated by Rigify:

import bpy
from mathutils import Matrix, Vector
from math import acos

rig_id = "k5r0i46z8d031115"

class RigLayers(bpy.types.Panel):
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_label = "Rig Layers"
    bl_idname = rig_id + "_PT_rig_layers"

    def poll(self, context):
            return ("rig_id") == rig_id)
        except (AttributeError, KeyError, TypeError):
            return False

    def draw(self, context):
        layout = self.layout
        col = layout.column()

        row = col.row()
        row.prop(, 'layers', index=2, toggle=True, text='Head')

        row = col.row()
        row.prop(, 'layers', index=0, toggle=True, text='Torso')

        row = col.row()
        row.prop(, 'layers', index=4, toggle=True, text='Fingers')
        row.prop(, 'layers', index=5, toggle=True, text='(Tweak)')

        row = col.row()
        row.prop(, 'layers', index=6, toggle=True, text='Arm.L (FK)')
        row.prop(, 'layers', index=8, toggle=True, text='Arm.R (FK)')

        row = col.row()
        row.prop(, 'layers', index=7, toggle=True, text='Arm.L (IK)')
        row.prop(, 'layers', index=9, toggle=True, text='Arm.R (IK)')

        row = col.row()
        row.prop(, 'layers', index=10, toggle=True, text='Leg.L (FK)')
        row.prop(, 'layers', index=12, toggle=True, text='Leg.R (FK)')

        row = col.row()
        row.prop(, 'layers', index=11, toggle=True, text='Leg.L (IK)')
        row.prop(, 'layers', index=13, toggle=True, text='Leg.R (IK)')

        row = col.row()
        row = col.row()

        row = col.row()
        row.prop(, 'layers', index=28, toggle=True, text='Root')

def register():

def unregister():


The RigLayers class is a very simple example of this type of panel.

bl_space_type: the window where the panel will show up which is actually the numeric properties side-pane thingie (I really don’t know how to refer to some of these divisions of windows; I’ve seen them called all kinds of things, so maybe no one is sure)

bl_label: that’s the heading that will show up in the title area of your panel

rig_id: that’s a variable that Rigify stuffs into Armature -> Custom Properties.

If you want to see it in action, just run Blender and add an Armature -> Human (Meta-Rig). Don’t bother setting up the rig for any particular mesh, just go to the Properties window -> Armature tab and look for Rigify Buttons. Click ‘Generate.’

The full script I’ve partially quoted above will show up in the Text Editor window. You’ll have to select it from the pop-up script list (it just says New at start-up) and pick

I don’t know of any good Blender Python tutorials, I’m afraid. I’ve seen a few, but no one really gives a good overview of how to wrap your head around the structure of Blender Python. I haven’t seen anything on how to lay a good foundation, what the differences are between regular Python and Blender Python (if any)… none of that stuff.

But maybe the above code will help you get a handle on this one, small task you’ve set for yourself.

@ Rontarrant
Thank you, thats working fine. Now I just have to figure out sliders. If you happen to have found something for them please post it. Otherwise I will see if I can find them in the rigify script.

Thanks again for your help

If you generate a Rigify rig, the script also builds some sliders in a second panel called Rig Main Properties. The code for those will show up in the Text Editor in a class named RigUI. Look at any statement starting with:

if is_selected(...)

and whatever is contained within the body of the if should be the code that builds the slider.

Any idea what to replece

with to allow the panel to show up all the time?

Thanks for the links but I think these go way beyond what I want to do. All I want to do with the shape keys is duplicate the slider of some of them in the UI panel since I have a ton of them. I will separate them in different panels I can toggle up or down. (show or hide).
So what would the equivalent code of

    row = col.row()        

row.prop(, ‘layers’, index=11, toggle=True, text=‘Leg.L (IK)’)
row.prop(, ‘layers’, index=13, toggle=True, text=‘Leg.R (IK)’)

to show the shape key slider in the UI panel. If possible I would like these to show up while the actual armature is selected as that is when I would use them. I have already connected many of the shape keys to bones but the rest I want to use in this manor.

Also I created a couple of custom properties for the IK I would like to duplicate into the UI panel.



All I want to do with the shape keys is duplicate the slider of some of them in the UI panel since I have a ton of them.

I did a simple video tutorial on how to do this. Thinking the 7~10 minute part of this video:

This will give you a slider in the UI for a shapekey when in pose mode. The only thing python does for you in the case of shapekeys is allow you to define the appearance of the panel a little bit more… I’ve attached a .blend file that uses my shapekey example from the video and has a python script that creates a custom panel & slider for the shapekey. It is the same code you would use for an fk/ik switch, if you’ve written one of them.

Joe, the character in my signature, has rig layers and custom sliders for the fk/ik switches defined by a python script. To create the file I attached, I just cut alot of code out, changed a few names and done…

feel free to ask questions, but I might not have the answers…



example.blend (442 KB)

Hi Monte,

Cobbled together a sample file for you, the default scene and the simple Panel template is used.
The cube has 1 basis and 2 relative shapekeys Basis, Key 1 and Key 2.

I have shown how to both add sliders for the keys on the mesh and have also set up a driver to demonstrate that method as well.
There are pros and cons … put in some keyframes and see where they end up. The prop driver method confines the keys to one action, which is handy when getting into more complex animations using NLA etc re syncing the shapekey action.

Notice the poll method will make the panel only show when the armature is selected. It can be extended for pose mode.

Also the Key 2 prop slider will only show when Bone is selected.

Should be a bit to get you going.


'owdy, long time no see… Apologies if I’ve duped info here as I haven’t checked out your vid.


sk.blend (89.7 KB)

Thank batFinger and Revot_Randy for your help. If I am understanding this right then, in order for the shape keys on the mesh to show up in pose mode of the armature I have to create a custom property for each shape key on a bone in the armature. I do know how to do that. What I was hoping to do was simply have the shape key slider available in the UI panel while animating the model. These shapekeys are expression and visemes that I don’t think really need bones on the armature(just too many Bones in the long run. There are already 95 of them. ) But by all the answers I am getting, this can only be done by creating a custom property for each of the shape keys. Is that right?

Can I create a bunch of custom properties on one bone? or do I need a bone for each shapekey?

I think I understand the IK switches, I just need to put the custom properties on a bone and not on the armature object.

Sorry I am having such a difficult time with this. I do appreciate the help. I am going to attach the file to see if that helps at all. I am trying to create a base rig from the Daz Studio Genisis character that I can then add one shape key too and have almost all the functionality that it does in DazStudio. I hpoe that makes sense.

Thanks again

Here’s a quick hack:

It’s an addon which adds a Shape Key panel to the Armature tab in Properties editor.

It let’s you pick an object and you then get that object’s shape keys incl. the sliders for keyframing animations.

Note: I removed all buttons which don’t work anyway, like move up/down, add/remove shape key… They use operators which work on the active object, but the active one is an armature. So they simply fail, nothing happens. You need to select e.g. the mesh object and go to Mesh data tab to add/remove shape keys etc.


btw. there is a pin icon at the very top of the properties editor, below the tab bar. You can pin down datablocks, so the panels won’t change when you change the active object. You could select the armature, pin down, select mesh and edit it while the prop editor will keep showing the armature stuff like layers.

Unfortunately, it doesn’t work the other way around: mesh object pinned down for shape keys while armature object is active - some panels like the shake keys disappear if you pin it down… dunno why blender does this oO

@ batFinger. I did realize after posting that some of the question I could figure out myself. I was just letting it all out at the time.

I really appreciate the help. I am learning a lot from all of the posts.

I got the bone layers to work fine, But couldn’t get anything else to work. So i created basically a copy of the code from the layers with a different name and it does nothing. Are there some bugs floating around that would cause this. I know the code works because it is working in one script but not as a new class and not as a new script. There are no errors shown, the script just does nothing.

Thanks again.


if you copied the layer code, it will of course do nothing, as the panel code relies on an armature being active. If you select a mesh object, it will try to use that object but there are no bone layers for meshes.

Did you try the addon i posted for the shape keys? Something similar should work for the bone layers as well, but you can actually use that pin down function to fixate the bone layer panel


I did try your script and I am getting the following error with it:

Traceback (most recent call last):
File “C:\Users\Owner\Documents\GenesisBlenderRig\GenesisBlenderRig.blend\ShapeKeysPanel”, line 60, in draw
TypeError: UILayout.template_list(): error with argument 1, “data” - expected a AnyType type, not str

location: <unknown location>:-1

works fine here, you probably need a more recent build

I used blender-2.65-r54287-win64