I have my 3D cursor snapped to a vertice.
What is the best way to move the cursor n units along a given edge?
3 Answers
Bmesh helper script
For those interested in a scripting solution, here is a little helper script to place the cursor on an edge.
Test script.
- Run in edit mode
- Have an edge as active element.
- Place the 3d cursor close to one end, this will be the zero location
- Edit the pc variable to how far in percent along edge from one end to another. 0 will snap the cursor to closest end. One third will move it one third of the way to other end.
- The global length of the edge is written to system console.
Test script.
import bpy
import bmesh
pc = 1 / 3
context = bpy.context
scene = context.scene
ob = context.edit_object
mw = ob.matrix_world
me = ob.data
bm = bmesh.from_edit_mesh(me)
e = bm.select_history.active
assert(type(e) == bmesh.types.BMEdge)
v1, v2 = sorted((v.co for v in e.verts), key=lambda o: (scene.cursor_location - o).length)
scene.cursor_location = v1 + pc * (v2 - v1)
print("Global Edge Length: ", (v2 - v1).length)
Notes:
Could extend this to have a UI by making an operator.
A native workaround to achieve this is to subdivide the edge creating a new temporary vertice, which can be moved in local orientation, and then set the 3D cursor to that vertice.
- Select the edge
- Ctrl+E > Subdivide
- Select the vertice, and use local transformations to move it where you want it. This can be done by moving the 3D cursor to the start of the edge (Alt+S > Cursor To Selection), then selecting your new subdivided vertice and doing Alt+S > Selection To Cursor, Then if for example moving along the y-axis 10cm press G+Y+Y+0.1 (depending on the scene Unit settings). Enabling Properties > Mesh Analysis > Edge Lengths helps too.
- Move your cursor to selection again, and undo the changes, the cursor will remain.
Download the Enhanced 3D Cursor and install.
Select your starting vertice and open prioperties (N) and under 3D Cursor Tools choose "Set" and change the transform orientation to "Local" or "Normal".
Press F10 and on the lower left you get an X/Y/Z box to enter your local transforms.
Press LBM carefully without moving the mouse to apply the move.
This only works if your edge is the local or normal to the vertice - ie if you have a vertice with 3 edges coming off it, it will probably only work for one of those edges. You might be able to do other edges by creating a Custom Transform Orientation (Properties (N) > Transform Orientations > New)