Post #1927: ![](https://blenderartists.org/user_avatar/blenderartists.org/colacuve/48/535989

📋 Metadata

🏷️ Tags

pie-menu scripting intermediate solved

  • Pie Menu Editor
  • Custom Icons
  • Python Scripting
  • Command tab
  • Custom tab
  • L.operator() function
  • L.prop() function

💬 Content

Colacuve:

How do I create a pie menu item that toggles between these two tool settings?

In this case you can use Command tab:

ts = C.scene.tool_settings; ts.transform_pivot_point = 'CURSOR' if ts.transform_pivot_point != 'CURSOR' else 'BOUNDING_BOX_CENTER'

If you want to change text and icon of the button depending on pivot point mode you need to use L.operator() function in Custom tab:

ts = C.scene.tool_settings; L.operator("pme.exec", text="Cursor" if ts.transform_pivot_point == 'CURSOR' else "Box", icon='PIVOT_CURSOR' if ts.transform_pivot_point == 'CURSOR' else 'PIVOT_BOUNDBOX').cmd = "ts = C.scene.tool_settings; ts.transform_pivot_point = 'CURSOR' if ts.transform_pivot_point != 'CURSOR' else 'BOUNDING_BOX_CENTER'"

Colacuve:

Currently, trying to discern when to use operator vs l.prop or what not is very difficult.

L.operator(...) function shows basic clickable button with customizable action.

L.prop() function shows widgets depending on the property type:

  • Boolean Property - check box or toggle button
  • Enum Property (your case) - drop down list or radio buttons
  • Int or Float Property - number input field or slider
  • String Property - text input field

❤️ 5 likes


🔗 View on Blender Artists