Post #599: fj

📋 Metadata

  • Author: roaoao
  • Date: 2017-03-13 00:33:31
  • Type: answer
  • Quality Score: 8/10
  • Reply to: post_00598

🏷️ Tags

macro scripting advanced solved

  • Macro Editor
  • Python Scripting
  • Modal Editor

💬 Content

fjg3d:

I made a merge verts macro based on the lasso dissolve example. I set it up to move the 3d cursor and merge at the cursor location which can be handy.

It would also be useful to merge to an active vertex. I know lasso doesn’t make active components, but using the code found in the stackexchange answer by codemanx here, (after removing the section that deselects the element) we can make active the nearest component to the cursor On Release. I got it working as a Stack Key, but it doesn’t work when I call the menu in a Macro. (I put it in place of the set 3d cursor in the image). Any ideas?

You can use this command to activate a vertex under the mouse:

bpy.ops.view3d.select(extend=True)

Also you have to modify the Merge command because it won’t work if there is no active element at the beginning of the macro:

(bpy.ops.mesh.merge(type='LAST'))

We have added round braces (…) - in this case PME generates a new sub-operator for the macro. Which will check active vertex right before Merge tool.

Note if you what to use this macro in some button (for example in pie menu) you can add this command as the first item to pause the macro (press LMB resume it):

bpy.ops.pme.modal_dummy()

🔗 View on Blender Artists