-
-
Save zeffii/11171754 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
import bpy | |
import bmesh | |
import mathutils | |
import math | |
from mathutils import Vector | |
obj = bpy.context.object | |
me = obj.data | |
bm = bmesh.from_edit_mesh(me) | |
verts = [v for v in bm.verts if (v.select and not v.hide)] | |
#if not len(verts) == 2: | |
# msg = "select two vertices" | |
# self.report({"WARNING"}, msg) | |
# return | |
v1, v2 = [v.co for v in verts] | |
print('vectors found:\n', v1, '\n', v2) | |
## test if shared z values | |
#if not (v1.z == v2.z): | |
# msg = "vert must share at least the z component" | |
# self.report({"WARNING"}, msg) | |
# return | |
amt = (0, 0, math.pi/2) | |
eul = mathutils.Euler(amt, 'XYZ') | |
mid_vec = v1.lerp(v2, 0.5) | |
perp_vec = (v1-mid_vec) | |
perp_vec.rotate(eul) | |
pt1 = mid_vec + perp_vec | |
pt2 = mid_vec - perp_vec | |
# get pt and pick fartest vertex from (projected) intersections | |
vec1 = bm.verts.new(pt1) | |
vec2 = bm.verts.new(pt2) | |
bm.edges.new((vec1, vec2)) | |
bmesh.update_edit_mesh(me) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment