property ui question

I am making a simple script for a rig and I want to display the X rotation_euler axis of a bone as a single property in the UI.

The issue that I have is two fold, first:
I want it as a slider “slider=True” with the min being -90 and max being +90, but how do I set this without creating a custom property? the bones defult min/max is 10,000.00 can this be changed? or can I define a min max for a slider separate to the property?

How do I display this property as a single property, Its part of a FloatVectorProperty so whenever I try to display it in the ui it has the Y & Z axis as well. Is it possible to display only one value from a VectorProperty?

I have looked at creating a custom property with a min and max value and it displays correctly, but trying to use that instead of the Xaxis causes loads of problems for the animator so the prop in the ui needs to be the same as the actual Xaxis prop for keying purposes.

Any Ideas?

Property limits can be set for custom properties (bpy.props) only.

You can create a custom property and give it an update callback, to set the actual rotation_euler.x.

It’s also possible to just show a part of a property by using prop(…, index=NUMBER):

import bpy
from math import radians

class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "bone"

    def draw(self, context):
        layout = self.layout
        wm = context.window_manager
        pbone = context.active_pose_bone
        if pbone is not None:
            layout.label("X of rotation_euler:")
            layout.prop(pbone, "rotation_euler", index=0, text="X")
            layout.label("Custom property:")
            layout.prop(wm, "pbone_x", slider=True)

def update_cb(self, context):
    pbone = context.active_pose_bone
    if pbone is not None:
        pbone.rotation_euler.x = self.pbone_x

def register():
    bpy.types.WindowManager.pbone_x = bpy.props.FloatProperty(

def unregister():
    del bpy.types.WindowManager.pbone_x

if __name__ == "__main__":

Thank youCoDEmanX"index=0" was what I was after :smiley:

I have used the update callback, the issue is that the animator wants to be able to add keys via the property ui and do other stuff that requires it to be the Xaxis like see the keyframe color indication. I could just override the Xaxis with a driver connected to the custom property and use that for animation, but then that would cause a lot of other issues.

Is there no way to display a slider with a custom range or limit? I remember reading some were about getting a property to display like another property? but cant seem to find that info, might be mad

Anyways thanks for your help :smiley:

Well, you can add a single driver to x rotation and set the scripted expression to the full path of an armature object’s pose bone and give it an ID property. This can be done in the UI, bone tab in properties editor, custom properties panel. You can click “edit” and change the boundaries.

Yea, that was the original setup. the issue with that is that you can no longer use the rotation manipulators in the 3Dview.

I guess I will have to compromise and not have it as a slider or with limits, :frowning:

Any better Ideas?

You may improve CoDEmanX’s example slightly:

def fget(self):
    return self.rotation_euler.x

def fset(self, value):
    self.rotation_euler.x = value

bpy.types.PoseBone.custom_float = \
    name = "test",
    get = fget,
    set = fset,

Though this does not solve the keying thing.

Ok I have a bit of an ugly hack:

This is not ideal because its really ugly, I could live with it if I could get rig of one of the number readouts, either have the slider not display a number or have the Xaxis prop display an icon? I don’t know though.

The other solution is that I try and recreate all of the feedback/interaction that the animator wants ie key-frame indication and add a “add/remove keyframe” button:

This looks better but is still a compromise, ie the star means a key frame is on that frame. A yellow slider would be better :frowning:

Any Ideas?

Just been looking into the whole star idea a bit more.

I could just have a gold star for when a key-frame is on that frame and have it like a toggle, so that the feedback could also double as an input. ie the animator could toggle on the star to add a key-frame or toggle off the star to delete a key-frame.

Hmm. adding a key-frame to a single fcurve at a certain frame is easy but how do you determine that there is or is not already a key-frame on that fcurve at that frame?