I want to find out the direction of a certain axis in a normal, for example the Y axis. So for an edge finding the direction would be to subtract the location of its vertices. I want to use that normal direction to move a face along the Y direction of its normal rather than the Z axis. I'm looking for a python solution.
I've figured it out using
bm.face[#].calc_tangent_edge(). Although I can't figure out why it goes to X axis then to Y axis when selecting faces in other parts of the mesh. I also need a 90° equivalent of this tangent to able to use this on a gridify script.
import bpy import bmesh obj = bpy.context.edit_object me = obj.data bm = bmesh.from_edit_mesh(me) f = bm.select_history.active n = f.calc_tangent_edge() vec = 0.1 * n for v in f.verts: v.co += vec bmesh.update_edit_mesh(me, True)
Moving across a plane, horizontally
import bpy import bmesh threshold = 0.0001 obj = bpy.context.edit_object me = obj.data bm = bmesh.from_edit_mesh(me) f = bm.select_history.active normal = f.normal tangent1 = f.calc_tangent_edge() tangent2 = normal.cross(tangent1) if abs(tangent1.z) < threshold: vec = tangent1 # this tangent already is horizontal elif abs(tangent2.z) < threshold: vec = tangent2 else: ratio = tangent1.z / tangent2.z vec = tangent1 - tangent2*ratio vec.z = 0 # it's close to 0 but let's just round it exactly to 0 vec.normalize() vec *= .1 for v in f.verts: v.co += vec bmesh.update_edit_mesh(me, True)