Outcome

Draw only the X-axis rotation lock for the active object:

L.prop(C.object, "lock_rotation", text="X", index=0) if C.object else L.label(text="Select an object")

The control edits Blender’s real Object.lock_rotation[0] value and updates like the native checkbox.

Steps

  1. Add a Custom item to a Pie Menu, Popup Dialog, or Panel Group.

  2. Identify the Blender data owner and array property. Here they are C.object and lock_rotation.

  3. Pass the component through index=:

    • index=0 for X
    • index=1 for Y
    • index=2 for Z
  4. Keep the active-object guard so the menu still opens when nothing is selected.

  5. Change the label to match the component or the workflow, rather than leaving an ambiguous unlabeled checkbox.

For all three axes, paste this complete one-line Custom expression:

obj = C.object; row = L.row(align=True) if obj else None; row.prop(obj, "lock_rotation", text="X", index=0) if obj else L.label(text="Select an object"); row.prop(obj, "lock_rotation", text="Y", index=1) if obj else None; row.prop(obj, "lock_rotation", text="Z", index=2) if obj else None

The repeated guards keep every row.prop() call away from a missing active object. For more complex conditional layouts, use a readable external script instead of extending this one-line form.

Where this pattern helps

  • one transform-lock axis;
  • one component of a color or vector property;
  • a compact layout where the complete multi-value widget is too wide;
  • a task-specific panel that should expose only the component users are expected to change.

Pitfalls

  • The index belongs to UILayout.prop(), not inside the RNA property name.
  • Check the property’s length before adapting the example. Not every array has three components.
  • C.object is the active object, not every selected object.
  • Use a Custom item because L is PME’s current UILayout; a Command item does not draw persistent controls.
  • Do not replace a single indexed control with three independent PME Properties unless you actually need separate stored values. The native RNA property is already the source of truth.

Sources