1

I have an issue finding the correct documentation online.

Example:

CTRL + A calls the following command:

bpy.ops.wm.call_menu(name="VIEW3D_MT_object_apply") 

And a selection option reads out the following command:

bpy.ops.object.transform_apply(scale=True)
bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)

Solution:

Now by trial and error I found out that if you want to call an operator it has to be formatted the following way:

row.operator("wm.call_menu", text="Apply Tans").name="VIEW3D_MT_object_apply"
row.operator("object.transform_apply", text="Apply Rot").rotation=True

name and rotation have to come after the operator closing bracket to pass that information to the operator.

Where can you in the Blender Python API find this information? I searched for it but do not find anything about the correct syntax.

Claas Kuhnen
  • 1,727
  • 4
  • 18
  • 40
  • duplicate ? http://blender.stackexchange.com/q/2515/5113 – Chebhou Jan 08 '16 at 18:10
  • I read this earlier and this option works by first generating a class that can execute the complete bpy command. Then command name is given to the button to operate/ execute. I am more interested in a solution that is only one line long - if that is actually possible. – Claas Kuhnen Jan 08 '16 at 18:14
  • the one line solution is working fine check your full script – Chebhou Jan 08 '16 at 18:16

1 Answers1

2

The docs have this information if you know what you're looking for.

http://www.blender.org/api/blender_python_api_current/.../wm.call_menu

In this case TextEditor > Templates > Python > UI Menu has a working example of how to trigger a specific menu

The UI source is often the most comprehensive documentation. For example space_view3d.py's class VIEW3D_MT_mirror(Menu) shows how to pass properties to an operator. As you have now seen

props = layout.operator("transform.mirror", text="Z Global")
props.constraint_axis = (False, False, True)
props.constraint_orientation = 'GLOBAL'

Here both constraint_axis and constraint_orientation are passed as values to bpy.ops.transform.mirror as soon as the button is pressed.

zeffii
  • 39,634
  • 9
  • 103
  • 186