-
-
Save zeffii/6609319 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
BEGIN GPL LICENSE BLOCK | |
This program is free software; you can redistribute it and/or | |
modify it under the terms of the GNU General Public License | |
as published by the Free Software Foundation; either version 2 | |
of the License, or (at your option) any later version. | |
This program is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of | |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
GNU General Public License for more details. | |
You should have received a copy of the GNU General Public License | |
along with this program; if not, write to the Free Software Foundation, | |
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
END GPL LICENCE BLOCK | |
''' | |
bl_info = { | |
"name": "Vert tools : vert 2 intersection", | |
"author": "zeffii", | |
"version": (0, 0, 2), | |
"blender": (2, 6, 8), | |
"category": "Mesh", | |
"location": "View3D > EditMode > (w) Specials", | |
"wiki_url": "", | |
"tracker_url": "" | |
} | |
import bmesh | |
import bpy | |
from mathutils import geometry | |
def add_vertex_to_intersection(): | |
obj = bpy.context.object | |
me = obj.data | |
bm = bmesh.from_edit_mesh(me) | |
edges = [e for e in bm.edges if e.select] | |
if len(edges) == 2: | |
[[v1, v2], [v3, v4]] = [[v.co for v in e.verts] for e in edges] | |
iv = geometry.intersect_line_line(v1, v2, v3, v4) | |
iv = (iv[0] + iv[1]) / 2 | |
bm.verts.new(iv) | |
bmesh.update_edit_mesh(me) | |
class Vert2Intersection(bpy.types.Operator): | |
bl_idname = 'mesh.vertintersect' | |
bl_label = bl_info['name'] | |
bl_options = {'REGISTER', 'UNDO'} | |
@classmethod | |
def poll(self, context): | |
obj = context.active_object | |
return obj != None and obj.type == 'MESH' and obj.mode == 'EDIT' | |
def execute(self, context): | |
add_vertex_to_intersection() | |
return {'FINISHED'} | |
def menu_func(self, context): | |
self.layout.operator(Vert2Intersection.bl_idname, text="Place vertex at Intersection") | |
def register(): | |
bpy.utils.register_module(__name__) | |
bpy.types.VIEW3D_MT_edit_mesh_specials.append(menu_func) | |
def unregister(): | |
bpy.utils.unregister_module(__name__) | |
bpy.types.VIEW3D_MT_edit_mesh_specials.remove(menu_func) | |
if __name__ == "__main__": | |
register() |
VIEW3D_MT_edit_mesh_specials
is now VIEW3D_MT_edit_mesh_context_menu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This does not work under Blender v2.82 - when I press W it does not show menu (according to article HERE) so I have no clue where to find it at all!