1
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ duplicate ? blender.stackexchange.com/q/2515/5113 $\endgroup$
    – Chebhou
    Jan 8, 2016 at 18:10
  • $\begingroup$ 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. $\endgroup$ Jan 8, 2016 at 18:14
  • $\begingroup$ the one line solution is working fine check your full script $\endgroup$
    – Chebhou
    Jan 8, 2016 at 18:16

1 Answer 1

2
$\begingroup$

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.

$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .