I tried to answer a question on blenderartists from what I already know, and then it was pointed out to me that I should be able to use the property directly in the panel menu instead of creating the operator for it outside the menu like I did here:

import bpy

class AutoMergeBool(bpy.types.Operator):
    """Automerge Toggle"""
    bl_idname = "mesh.automerge_toggle"
    bl_label = "Automerge Toggle Operator"

    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        merge = bpy.context.scene.tool_settings

        if merge.use_mesh_automerge != True:
            merge.use_mesh_automerge = True
            merge.use_mesh_automerge = False
        return {'FINISHED'}

class CustomMenu(bpy.types.Menu):
    bl_label = "Custom Menu"
    bl_idname = "view3D.custom_menu"

    def draw(self, context):


def register():

def unregister():

if __name__ == "__main__":

Can anyone give me a single line example of how the property should be accessed in the layout so that it results in the bool? I already tried searching here and elsewhere and haven't found anything that works.


Instead of adding a layout.operator you would add a layout.prop, which would look like this:

self.layout.prop(context.scene.tool_settings, "use_mesh_automerge")

The first parameter in the parentheses is where the property is stored and the second is the name of the property you wish to access.

This results in this menu, with a property that can be toggled on and off:

enter image description here

  • $\begingroup$ Thank you, your explanation is worth as much as the solution itself. $\endgroup$ Jan 23 '19 at 2:27

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.