What is the correct way to in the UV editor perform an X or Y mirror as one command for a pie operator?

pie.operator("transform.mirror()", text="Mirror").constraint_axis='True, False, False'

Based on what I saw in the console:

bpy.ops.transform.mirror(constraint_axis=(True, False, False), constraint_orientation='GLOBAL', proportional='DISABLED', proportional_edit_falloff='SPHERE', proportional_size=0.0323492)

I struggle to understand the logic because I was able to successfully do this with a different snapping command


has to be written as

pie.operator("uv.snap_cursor", text="Snap Cursor to Selected").target='SELECTED'

Alternatively I could just define an operator and call the name via a pie button but I feel this makes the script longer than needed

  • $\begingroup$ lose the parentheses and add ones at the end pie.operator("transform.mirror", text="Mirror").constraint_axis=(True, False, False) $\endgroup$
    – Chebhou
    Jan 18 '16 at 0:30
  • $\begingroup$ Actually I tried this. What happens is that you start the mirror command and have to press x or y for the direction. the constraint definition will be ignored. $\endgroup$ Jan 18 '16 at 0:50
  • $\begingroup$ try clicking the leftMouse without specifying the axis and read the executed command in blender you'll see it is not ignored $\endgroup$
    – Chebhou
    Jan 18 '16 at 0:54
  • $\begingroup$ My eyes fool me. True without the constraint it goes into asking you. With the data it executes what you define and still enables you to overwrite it via X or Y or press LMB. $\endgroup$ Jan 18 '16 at 0:59

The description of the operator can be found here.

bpy.types.UILayout.operator returns an bpy.types.OperatorProperties object.

So if you need to assign multiple presets, assign it to a local variable first

op_props = pie.operator("transform.mirror", text="Mirror")
op_props.constraint_axis = True, False, True

When the operator's invoke method is called the operator may use user input to set its properties or run modal, before finally running its execute method.

To skip the invocation you might try:

pie.operator_context = "EXEC_DEFAULT"
pie.operator("transform.mirror").constraint_axis = True, False, True

pie.operator_context = "INVOKE_DEFAULT"

See UILayout.operator_context for the available options


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.