2

hi im looking for correct context attribute to toggle on / off with shortcut key at input editor XRAY armature because i find use it often and decided to make it as shortcut

enter image description here

i tried the following context attribute but gives error

  1. active_object.data.show_x_ray
  2. Object.Show_x_ray

thank you for answers

2 Answers2

3

Set your custom keyboard shortcut like this:

Custom keyboard shortcut for toggling X-ray display

Key points

  • When setting toggle shortcuts use wm.context_toggle
  • When it pertains to the active object use active_object. followed by the last part of your context attribute name, which in this case is show_x_ray
  • If you add this to the list under the Object Mode section the shortcut will only trigger X-ray display while you are in Object Mode, which frees up your keyboard shortcut to be used for something else in Edit Mode, etc. If you add it under 3D View (Global) the keyboard shortcut will trigger it in all 3D View modes.
Mentalist
  • 19,092
  • 7
  • 94
  • 166
0

Close with Object. Without getting too technical you will not find a data_path containing capitals. Any one of

bpy.ops.wm.context_toggle(data_path="object.show_x_ray")
bpy.ops.wm.context_toggle(data_path="active_object.show_x_ray")
bpy.ops.wm.context_toggle(data_path="scene.objects.active.show_x_ray")

The python console C is a shortcut for bpy.context, and [ctrl-space] is autocomplete. With the armature selected, typing C.ob[ctrl-space] completes to C.object. Add a . and again gives you the list of properties.

batFINGER
  • 84,216
  • 10
  • 108
  • 233