2
$\begingroup$

The area I am trying to speed up is when you press AltM and then click "At Last" or "At First". I would like to set up two buttons that when pressed would merge "At Last" or "At First".

$\endgroup$
4
$\begingroup$

The first step is to find out what command is being called when you merge 2 vertices. You can find that out by doing a merge, then checking the info window at the top. You can see me do this in this GIF:

enter image description here

From here, I know the command I want to activate is bpy.ops.mesh.merge. Now all I have to do is map a shortcut to this function. This can be done pretty easily without scripting.

  1. Go to File > User Preferences > Input > 3D View > Mesh
  2. Go to the bottom and click Add New.
  3. Click the drop down next to the "none" label for the shortcut you just added.
  4. In the text input box where you see "none" written, change it to say mesh.merge.
  5. At the bottom you should see a property show up that's grayed out that says "At Center". Click that drop down and change it to "At First".
  6. Use the buttons on the right side of this dialog to make the shortcut that will activate this function. In my example below, I have decided to use Ctrl Alt M

enter image description here

Be sure to save user settings if you want this shortcut to be active every time you open Blender.

$\endgroup$
  • $\begingroup$ One last question, i have a Razer Tartarus and wanted to know if i can set it up to act like extra keys instead of binding them to other keys $\endgroup$ – Clue Less Mar 2 '18 at 6:48
2
$\begingroup$

Not choosing Merge type from menu with mouse.

There are a number of ways to choose merge type without having to click the particular menu item with the mouse.

Shortcut

The short cut for merge is AltM which brings up the menu. Notice each option has a letter underlined.

enter image description here

For "At First" the A is underlined. Hence can choose merge at first via AltMA, "At Last" with AltML etc.

Merge on Mesh Tools 3D view panel.

The merge menu is available on the 3D view tools panel when in edit mode on a mesh. Similarly to above can click the menu and press A

enter image description here

Scripting

In the tooltip we see the operator is bpy.ops.mesh.merge(type='FIRST') Right clicking the menu and choosing "View Source" and it will take us to the UI code (that produces the layout you see)

enter image description here

To have a button for each option will use the UILayout.operator_enum(..) layout. Example below, edited from Text Editor > Templates > Python > UI Panel Simple template.

import bpy

class MeshMergePanel(bpy.types.Panel):
    """Merge Panel in Mesh Tools"""
    bl_label = "Merge"
    bl_idname = "MESH_PT_merge"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_category = "Tools"

    @classmethod
    def poll(self, context):
        return context.mode == 'EDIT_MESH'

    def draw(self, context):
        layout = self.layout
        col = layout.column()
        col.operator_enum("mesh.merge", "type")

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

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

if __name__ == "__main__":
    register()

Which produces this layout

enter image description here

$\endgroup$
0
$\begingroup$

I thought about this a great deal and now I am here to give you this little trick:

Map keyboard shortcut Shift+LMB on the merge tool, then use it and watch magic happen:)

P.S.: hold LMB when using it

$\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.