# How to use shortcut 'J' to connect two vertices using shortest path?

I've noticed the following behavior several times and I found it quite annoying. Many times when I select 2 vertices and press J to cut a set of edges through, it's not going through the expected shortest path.

The correct shortest path is the yellow line. What is the logic Blender used to determine it to place the vertex in this position? Since both the start and end vertices have the same Z position, I would find it more logical if it didn't take a "random" z value and just use the same z-value as the selected vertices. How do I configure Blender to make sure it goes through the shortest path?

Out of curiosity I also tried removing one face to see how it behaves in this example:

Anyone any idea?

• Interesting question.. what path-finding algorithm is Blender using? It would be nice if someone could look it up. Commented Jul 11, 2023 at 11:28
• The correct shortest path might be the yellow line in your example above, but actually I don't know where it is stated that this tool would create the shortest path? At least it is not in the Blender Manual. You have an n-gon there with parallel lines at different lengths as well as non-perpendicular corners. In the same way that a Loop Cut changes from orthogonal to diagonal when getting closer to a diagonal border, the Connect Vertex Path behaves in a similar way, only that it is not limited to work on quads like the Loop Cut tool. Commented Jul 11, 2023 at 12:06

As you can see in the answer by @СергейЛенов the thing here is, that you have an extrusion there. It would not matter if it is inward or outward, the important thing is that the edge to which the vertex in the front belongs to is at an angle. If it was just an inset but flat face (like shown in the answer), the cut would be straight. Even if you made a second inset, as long as the edge angle is 0°, the cut will be straight. I don't know how the edge angle is used for calculation of the cut, but at least I can show examples how this influences the cut.

Here are a few cubes.

• #1 has a simple flat inset face, the edges connect to the corner vertex have angles of 0°.
• The same goes for #2 with a secondary flat inset face.
• #3 has the second inset moved a little outward so that the edges have angles of about 30.2° and 41.7°.
• #4 has the second inset moved even further outwards, the angles are now 78.0° / 87.5°.
• On #5 the face is only as far out as #3, but the face is larger so that the angles are the same as on #4.
• #6 is a simple outward extrusion, the angles are now all 90°.

Now look at the new edges that result from using the Connect Vertex Path tool to the left of the cube.

• #1 and #2 where the connected edges have an angle of 0°, the new edge is completely horizontal (which means the shortest path here).
• #3 with an angle of 30.2° cuts the border slightly higher.
• #4 with a sharper angle of 78.0° is even higher, #5 with different inset size but same angles has the the cut at the same height.
• #6 at last with 90° gets an even higher cut - and if you had scaled the extruded face larger so that the angle exceeds 90° it would have gone higher still.

However, this does not provide any solution on how you could avoid that or which calculation is doing this on edge angles different from 0°. I can only tell you, non-flat faces will result in non-straight connecting paths.

• thanks for your inputs Gordon! Commented Jul 11, 2023 at 16:47
• @HarryMcKenzie As it seems after some experimenting, not only the edge angle has an influence but also the width from the vertex to the border... but I really have no idea how to find out how this is calculated. Commented Jul 12, 2023 at 7:25

As far as I understand, this already works on the principle of the shortest path. Try to repeat all your actions with a 2x2 cube and insert 0.5 m, and you will get the result you need. And if it doesn't work out, then most likely the problem lies somewhere in the grid

Before Hotkey

After Hotkey

## PROBLEM

Just now I somehow managed to get the same problem as you and in general Height = 0.16769 (And should be on the same line with the points we need) Insert = 0.38736

If you calculate the length of the wrong path and this:

0.16769^2+2^2= 4,02812 > √ 4,02812 = 2,00702 (1 side)

0.16769^2+0,38736^2 = 0.178168 > √ 0,178168 = 0,4221 (2 side)

2,00702 + 0,4221 = 2,42912

Now let's calculate the path of the right path

2 + 0.38736 = 2.38736

That is, for some reason, he began to follow a longer path, although the idea should be the opposite

In the end, I can only say that I solve this problem when I changed the cube and started everything from the beginning

• I don't think he really wants to know how to correct this (in the example you could simply edge slide the vertex that's off downwards and snap it to the height of the others) so a redo is not the solution (and maybe not possible sometimes), he asks why it behaves like this and if there is a way to make it behave differently. Like when you are using the Loop Cut tool and press F, you can toggle which edge the cut angle should match. By the way, you "somehow" managed to get the same problem: the reason is the inward extrusion, just in case you are wondering why it behaves differently. Commented Jul 11, 2023 at 12:51

use the knife option then? it doesnt take that long and i think it'll fix it