2
$\begingroup$

Selecting an intersecting point in a line.

Ideally, all points in the line, not just one.

Just for visualization, here is a line.

enter image description here

And there are the points between the start and end of the line.

enter image description here

I would like to know how, in Python, if you had selected the points A and B (like in the second image), you were able to select ideally not one (but that would be an acceptable answer for something I could work off of), but all the points (1, 2, 3, and 4) between aforementioned A and B.

The important thing is that A and B are random points in 3D space. They are not flat against the ground (for example with coords 0x, 3y, 0z); but they are always connected as a line.

If someone could help me out here, that would be great. The Blender documentation is unfortunately not as good as Adobe's so I can't do everything (really anything) myself anymore.

$\endgroup$
1
  • 1
    $\begingroup$ If you are just looking for a tool to select everything between, you can just hold Ctrl when you select the second vertex to select the shortest path between the two. $\endgroup$
    – HISEROD
    Feb 8, 2021 at 23:07

1 Answer 1

3
$\begingroup$

As HISEROD pointed out, if you click on one vertex to select it, and then hold CTRL before clicking another, you will select the shortest path to that vertex:

If you indeed need a script solution, here it is:

import bpy

index1 = 105
index2 = 165

bpy.ops.object.mode_set(mode = 'OBJECT')
obj = bpy.context.active_object
bpy.ops.object.mode_set(mode = 'EDIT') 
bpy.ops.mesh.select_mode(type="VERT")
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.object.mode_set(mode = 'OBJECT')
obj.data.vertices[index1].select = True
obj.data.vertices[index2].select = True

bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.shortest_path_select(edge_mode='SELECT', use_fill=False)
$\endgroup$
1
  • $\begingroup$ Thank you, this is good. $\endgroup$ Feb 8, 2021 at 23:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .