Rotation Slider for a single Axis

Hi,

I’d like to rotate different objects using sliders in my Python-Panel.

What I found was this command:

col.prop(ob, "rotation_euler", text="Rotation")


However, the objects all have Rotation Constraints and can only be rotated around one axis each. So, is there a similar command that only displays a slider for a single axis (e.g. the “X”-axis)?

The Panel will be used for a robot-movement Simulation/Testing environment.

Any help would be greatly appreciated,
Hanshans

.prop() has an optional parameter index. Pass it a 0 for X rotation component.

Here’s an example, that takes X and Z euler rotation angles and puts them in an aligned column:

import bpy


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 = "object"

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

        obj = context.object

        col = layout.column(align=True)
        col.label("Rotation:")
        col.prop(obj, "rotation_euler", index=0, text="X")
        col.prop(obj, "rotation_euler", index=2, text="Z")


def register():
    bpy.utils.register_class(HelloWorldPanel)


def unregister():
    bpy.utils.unregister_class(HelloWorldPanel)


if __name__ == "__main__":
    register()


You need to set the label text manually, it will otherwise use the overall property name (which is “Euler Rotation” in this case, it doesn’t show X or Z using .index).

Thank you CodemanX, it works!

Is this documented in the API? Where can the parameter list be found?

Here in the API docs:
http://www.blender.org/documentation/blender_python_api_2_70a_release/bpy.types.UILayout.html?highlight=uilayout#bpy.types.UILayout.prop
(make sure you don’t miss the parameters after the list of possible “icon” values!)

You could also run this in Blender:

for p in bpy.types.UILayout.bl_rna.functions[‘prop’].parameters: print§