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
-
Add a Custom item to a Pie Menu, Popup Dialog, or Panel Group.
-
Identify the Blender data owner and array property. Here they are
C.objectandlock_rotation. -
Pass the component through
index=:index=0for Xindex=1for Yindex=2for Z
-
Keep the active-object guard so the menu still opens when nothing is selected.
-
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 NoneThe 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.objectis the active object, not every selected object.- Use a Custom item because
Lis PME’s currentUILayout; 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.
Related
- Choose Command, Property, Menu, Hotkey, or Custom
- Show object dimensions in a PME layout
- Make a PME Property Editor slider