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".
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:
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.
- Go to
File > User Preferences > Input > 3D View > Mesh
- Go to the bottom and click
- Click the drop down next to the "none" label for the shortcut you just added.
- In the text input box where you see "none" written, change it to say
- 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".
- 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
Ctrl Alt M
Be sure to save user settings if you want this shortcut to be active every time you open Blender.
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.
The short cut for merge is AltM which brings up the menu. Notice each option has a letter underlined.
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
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)
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
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