1
$\begingroup$

Currently in Blender you have two bevels:

-Ctrl+B (for edges and faces)

-Ctrl+Shift+B (for vertices).

I was trying to create an operator that will identify what mode you're in and activate the appropriate Bevel Tool.

I bound this script to a hotkey and it actually works, HOWEVER, it applies the bevel instantly without giving me the interactive mouse drag for offset and scroll wheel to change segments.

QUESTION: How can I activate the interactive version of the bevel tools from the operator script?

My current script:

import bpy

def main(context):
    #for ob in context.scene.objects:
        #print(ob)
    toolSettings = bpy.context.tool_settings
    if toolSettings.mesh_select_mode[1]:
        print('Edge Mode Active')
        bpy.ops.mesh.bevel(offset=0.48369, offset_pct=0, vertex_only=False)
    elif toolSettings.mesh_select_mode[0]:
        print('Vertex Mode Active')
        bpy.ops.mesh.bevel(offset=0.537019, offset_pct=0, vertex_only=True)


class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"

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

    def execute(self, context):
        main(context)
        return {'FINISHED'}


def register():
    bpy.utils.register_class(SimpleOperator)


def unregister():
    bpy.utils.unregister_class(SimpleOperator)


if __name__ == "__main__":
    register()

    # test call
    #bpy.ops.object.simple_operator()
$\endgroup$
0
$\begingroup$

Thanks to some outside help I found the commands I needed to activate the interactive version of the bevel tool from the script.

It's wrapped around an operator so it can easily be mapped to the "B" key for example.

import bpy

def main(context):

    toolSettings = bpy.context.tool_settings

    #Are we in Vertex Mode?
    if toolSettings.mesh_select_mode[0]:
        bpy.ops.mesh.bevel('INVOKE_DEFAULT', vertex_only=True)

    #Any other Mode...
    else:
        bpy.ops.mesh.bevel('INVOKE_DEFAULT')


class SmartBevel(bpy.types.Operator):

    """

    [Smart Bevel]

    Description:
    You no longer need 2 separate hotkeys to bevel vertices or edges/faces.
    Simply map the command to something like the "B" key under "3D View / Mesh / Mesh (Global) / Add New Keymap".

    Command:
    arc.smart_bevel

    (www.armoredColony.com)

    """

    bl_idname = "arc.smart_bevel"
    bl_label = "Smart Bevel (ARC)"

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

    def execute(self, context):
        main(context)
        return {'FINISHED'}

def register():
    bpy.utils.register_class(SmartBevel)

def unregister():
    bpy.utils.unregister_class(SmartBevel)

if __name__ == "__main__":
    register()
| improve this answer | |
$\endgroup$

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.