2
$\begingroup$

I want to select a number of evenly spaced vertices from a mesh. I have tried Checker-Deselect (not been able to find settings that would do), and also made a vertex group first (with the highlighted vertices), and then subsurface modified to increase vertices in between. Problem is, the new vertices are also in the vertex group, so I can't select them.

Here is an image for reference of what I would like to achieve:

enter image description here

$\endgroup$
2
  • $\begingroup$ Are the vertices supposed to be unevenly spaced? For example you have four unselected verts between each vert going on rows, but in columns you have five or three unselected verts between the selected ones. $\endgroup$
    – Rekov
    Commented Feb 23, 2020 at 23:25
  • $\begingroup$ @Rekov Evenly spaced would be preferred, but if there is a generic solution with more freedom that would be helpful too! $\endgroup$
    – Geo Vogler
    Commented Feb 23, 2020 at 23:28

1 Answer 1

2
$\begingroup$

If a known mesh can use the index

If the mesh is created from a grid via the operator or a bmesh we know the order of the vertex indices, and how many rows and columns.

In the example in question it appears to be a 22 x 22 vertex grid.

enter image description here

For a default grid, as viewed from top, the bottom left hand corner is index 0, up to 21 along bottom row, 22 to 43 the next row up and so on.

Hence we can use these indices to select using div and mod.

Test script for 22 x 22 vert grid, selecting every fifth row, every third column, starting from row 2 column 4

import bpy
import bmesh

context = bpy.context
me = context.edit_object.data

bm = bmesh.from_edit_mesh(me)

#example in question has 22 x 22 vert grid
rows = 22
cols = 22

# choose every 5 rows, 3 columns
r = 5
c = 3
# offset (eg make (2, 4) == (0, 0)
ro = 2
co = 4

for v in bm.verts:
    i = v.index
    row, col = i // cols + ro, i % rows + co
    v.select = not row % r and not col % c

bmesh.update_edit_mesh(me)

Note the order can be changed using sort.

For example to sort along x

bm.verts.sort(key=lamda v: v.co.x)

for a default aligned xy grid will order up the columns.

$\endgroup$

You must log in to answer this question.

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