share
BlenderHow can I add vertices to intersection of two edges?
[+77] [9] Keavon
[2013-09-18 03:22:40]
[ modeling mesh vertices ]
[ https://blender.stackexchange.com/questions/2976/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.

related: blender.stackexchange.com/questions/805/… Do you just want to add a vert there, or do you want to merge the existing verts? (see blender.stackexchange.com/questions/1759/…) - gandalf3
Either way. If it just adds the vert there, I can manually merge it. - Keavon
<kbd>CTRL</kbd> + <kbd>R</kbd> Sometimes finds those intersections - Vasco Cansado Carvalho
[+51] [2020-07-26 17:20:52] YPOC [ACCEPTED]

With Blender 2.8+ you can use the Auto Merge Tool to insert a vertex between intersecting edges.

enter image description here

Just enable the option Auto Merge and Split Edges & Faces in the Tool Shelf, then select a vertex and move it. Upon placing it down the tool will create vertices between the connected edges and the edges intersecting them.

If you don't want to move any vertices just select the intersecting edges or their vertices and press GEnter


(4) This is most definitely the best solution now! Thank you for making me aware of it. If you want to make sure to not move it at all, G Z 0 Enter would be the safest way to avoid moving it even a pixel. - Keavon
1
[+37] [2013-09-18 09:27:08] zeffii

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

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)

add_vertex_to_intersection()

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


This is now part of mesh_tinyCAD

A while back I added this feature to mesh_tinyCAD [2], 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.

[1] https://gist.github.com/zeffii/6609319
[2] https://github.com/zeffii/Blender_CAD_utils

You make it looks easy. - Ari
2
[+25] [2014-12-22 12:27:24] jubi

I found tinyCAD addon the most helpful solution for this problem. It can be downloaded here:

https://github.com/zeffii/Blender_CAD_utils

You can install several ways but the easiest is to download the zip linked in the readme [1] 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

tiny cad

[1] https://github.com/zeffii/mesh_tinyCAD/archive/master.zip

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
Unfortunately this also removes any faces connected to the edges. - gatzkerob
3
[+10] [2013-09-18 16:45:36] gandalf3

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

This is include with development builds of blender by default, but you will still have to enable it in the User preferences:

enter image description here

If you are using a release version, you can get it here [2]

Press Space> Snap Cursor menu > Cursor to edge intersection:

enter image description here

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:

enter image description here

Then select the vertices you want to merge with one of the ones on the intersection selected last and press AltM> At last:

enter image description here

Alternate Workflows

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

Array modifier

You could use the Array modifier [3] with an object offset, see this answer [4]

enter image description here

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:

enter image description here enter image description here

Extrude upwards, select all, then press AltE> Individual faces:

enter image description here

Delete the top vertices:

enter image description here

[1] http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/Dynamic_Spacebar_Menu
[2] http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/Dynamic_Spacebar_Menu
[3] http://wiki.blender.org/index.php/Doc:2.6/Manual/Modifiers/Generate/Array
[4] https://blender.stackexchange.com/a/567/599

(3) 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
4
[+8] [2013-09-18 04:23:21] Haunt_House

There are several approaches. The Dynamic Spacebar Addon answer [1] 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 [2] 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 [3] 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.

[1] https://blender.stackexchange.com/questions/805/is-there-any-good-way-to-snap-to-intersection
[2] http://wiki.blender.org/index.php/Doc:2.6/Manual/Modeling/Meshes/Editing/Subdividing/Knife_Subdivide
[3] http://wiki.blender.org/index.php/Doc:2.6/Manual/3D_interaction/Transform_Control/Snap_to_Mesh

5
[+7] [2016-01-15 01:23:48] TLousky

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.

enter image description here

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[0].verts ]
    p3, p4 = [ globCo( v.co, o ) for v in edges[1].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[0], 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' )

(1) I'd like to point out that matrix multiplications now use @ instead of *. "o: o.matrix_world * co" would become "o: o.matrix_world @ co" - Xylvier
6
[+7] [2020-06-16 22:14:32] Stainless

Just a brief contribution, no-code solution and perfect precision:

  1. Select the edges you want to intersect
  2. Extrude them out to make faces (direction doesn't matter much)
  3. Select the faces, Ctrl + F, Intersect (Knife)
  4. Expand the context menu that appears bottom-left (subtle)
  5. Under the Source drop-down menu, select Self Intersect
  6. Select all, merge by distance to merge vertices
  7. Delete the extra vertices which made up the temporary faces, and you're done!

Enjoy your new intersection.


7
[+1] [2018-08-12 15:08:11] KABLAMM

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.


8
[-1] [2020-10-28 11:52:32] validbit

Quick & Dirty solution

This I use and should work for you in any case (no cutting) without creating unnecessary geometry in the end. This method is manual and might not be fast for cases with multiple intersections in different locations.

  1. Fill in edges from verticies (select two vertices, F to fill edge)
  2. Extrude (E) half-length edge from any original vertex (in corners) (overlay any existing edge with one new while having snapping set to "Edge Center") Center Snapping
  3. Delete the half-length edge (X or DEL) as in "Only faces & vertices" (The vertex of the intersection will be preserved)

9