# How can I add vertices to intersection of two edges?

I need to put a point at the intersection of two edges. Below is a picture with red circles around where I need points to be placed. If all you really want is to add a vertex at the position of intersection, then something like this script would work: (this even adds the vertex at the projected intersection of two lines, or the closest point if they never intersect)

import bmesh
import bpy
from mathutils import geometry

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 + iv) / 2
bm.verts.new(iv)
bmesh.update_edit_mesh(me)



this does not attach the vertex to any edges/faces. Here it is packaged as an addon accessible from: W > Place vertex at intersection

This is now part of mesh_tinyCAD

A while back I added this feature to mesh_tinyCAD, and called it (Vertex to Intersection) V2X. I use it to add guide-vertices to intersections and it is less potentially destructive than the XALL or VTX operations.

• You make it looks easy. – Ari Sep 12 '18 at 1:55

You can install several ways but the easiest is to download the zip linked in the readme and use the Install from File option in UserPreferences > Addons. Then you can enable it as usual.

To use it, just select intersecting edges, press W and select TinyCAD > TinyCAD XALL • Great find. This is the question that originally brought me to this site, and this addon is the only solution I've really liked so far. – user7952 Dec 22 '14 at 13:26

To expand on Haunt_house's answer, to place a vertex at the intersection you can use the Dynamic spacebar addon

This is include with development builds of blender by default, but you will still have to enable it in the User preferences: If you are using a release version, you can get it here

Press Space> Snap Cursor menu > Cursor to edge intersection: This snaps the 3D cursor the the intersection between the selected edges.

Now you can add a new mesh (press ShiftA while still in edit mode) and then press ShiftS> Selection to cursor: Then select the vertices you want to merge with one of the ones on the intersection selected last and press AltM> At last: # Alternate Workflows

For something like this, You might be better off with a different workflow:

## Array modifier

You could use the Array modifier with an object offset, see this answer Note that in the above image, the plane object as been rotated -120 degrees in object mode.

(This would be similar to Haunt_house's solution of using different objects)

## Primitives

You might be able to use a primitive to get the desired geometry, Add a circle and set the vertices to 3 in the Redo menu or the F6 menu:  Extrude upwards, select all, then press AltE> Individual faces: Delete the top vertices: • I would suggest you remove the Alternate Workflows section because they are specific only to the model I showed in the example and not helpful to anyone else visiting this question. – Keavon Jun 13 '15 at 9:19

There are several approaches. The Dynamic Spacebar Addon answer might be one of them.

Here are some other:

1. Instead of creating the three parts in Edit Mode, create them in Object Mode as linked copies with AltD and rotate them. If you now go into editmode, you can adjust the length by using G and restraining to a local axis by pressing X, Y, or Z twice. With enough zoom you can adjust the verts to meet and then merge them with AltM or the Magnet Tool. Remove Doubles should work too.

2. You can use the Knife. Select all verts, zoom in a lot and cut the edges with ShiftK (shift to cut all edges) where they intersect. Then clean up.

3. You can select the verts of the upper vertical part, and move them up until they meet the side part's edges. Then use the cursor as pivot point with Dot. Copy one of them and rotate it 120 degrees around the cursor to get the third intersection point.

4. You can use the Knife Project Tool to cut them

5. You can use a three sided cylinder and extrude it outward. While in Face Select mode, select the three sides and use Mesh>>Extrude>>Individual Faces (if you have cubes instead of planes in your example). Sometimes reversing the workflow is a good idea.

6. You can use Vertex slide. Select the vertices and press G twice, then slide the vertices along the edges.

7. If the placement of the parts isn't critical, you can use the Magnet to snap the edges together.

8. The ordinary Knife Tool has snapping functionality. With everything selected, snap it to both ends of an edge and the intersecting edge will be cut.

So, I had to play with this until I solved it in the basic mathematical sense. So, here's a solution that will work for a pair of edges that really intersect, and it will also edd a vertex at the intersection point.

To activate:

1. Open a text editor window and create a new text file.
2. Paste the code from below there.
3. Select the intersecting edges.
4. Press Run Script. Here's the code:

import bpy, bmesh
from mathutils import Vector

globCo = lambda co, o: o.matrix_world * co

def find_intersection( edges, o ):
# Calculate global locations of edge verts
p1, p2 = [ globCo( v.co, o ) for v in edges.verts ]
p3, p4 = [ globCo( v.co, o ) for v in edges.verts ]

v1 = p2 - p1 # Edge 1 line vector
v2 = p4 - p3 # Edge 2 line vector

# Calcualte intersection
# Based on paramteric line equation: (x,y,z) = p0 + t * lineVec
numer = v2.y * ( p3.x - p1.x ) + v2.x * ( p1.y - p3.y )
denom = v1.x * v2.y - v1.y * v2.x
t1    = numer / denom

co = Vector( [ getattr( p1, i ) + t1 * getattr( v1, i ) for i in 'xyz' ] )

bpy.context.scene.cursor_location = co

return co

o  = bpy.context.object
if o.mode == 'EDIT':
bm    = bmesh.from_edit_mesh( o.data )
edges = [ e for e in bm.edges if e.select ]

if len( edges ) == 2:
co = find_intersection( edges, o )

# Split edges and add new vert to newly created edges
for e in edges:
p1, p2 = [ globCo( v.co, o ) for v in e.verts ]
fac = ( co - p1 ).length / ( p2 - p1 ).length
bmesh.utils.edge_split( e, e.verts, fac )

# Remove doubles
bpy.ops.mesh.select_mode( type = 'VERT' )
bpy.ops.mesh.select_all( action = 'SELECT' )
bpy.ops.mesh.remove_doubles()
bpy.ops.mesh.select_all( action = 'DESELECT' )


Another way that I find easier is to just use the knife tool (K). Press K then left click near the intersection, draw the line over the intersection and left click again, then hit enter. This creates three new vertices, one of which is at the intersection. Delete the others and fill in any faces that get removed and you are done.