3
$\begingroup$

Can someone please help me understand the values for the arguments in the function bmesh.ops.simlar_verts(bm, verts, type, thresh, compare)

I understand that:
bm- is the bmesh you are working on
verts- is a list of BMVerts to base the selection on
thresh- is some kind of distance based threshold

But what on earth do the int values for type and compare relate to?

I have played around with the values and have noted they select different patterns of vertices but I can't figure out the pattern. The docs don't appear to have any information for the values.

If you can explain to me what these values relate to or point me in the direction of an answer I would be extremely grateful.

$\endgroup$
2
$\begingroup$

Check the source where docs are lacking.

Similarly to this answer re bmesh.ops.delete look at source of bmesh/intern/bmesh_operators.h

On compare

enum {
    SIM_CMP_EQ = 0,
    SIM_CMP_GT,
    SIM_CMP_LT
};

The int enum values for equality is 0, greater than 1, and less than 2.

On types

/* similar vertex selection slot values */
enum {
    SIMVERT_NORMAL = 0,
    SIMVERT_FACE,
    SIMVERT_VGROUP,
    SIMVERT_EDGE
};

On types it appears to check, 0 checks normals, 1 linked faces, 2 vertex group, and 3 linked edges.

Note

The bmesh similar operators appear to have been removed from 2.8

$\endgroup$
  • $\begingroup$ Ok, so I've taken your advice and checked the source code mentioned and the file source/blender/bmesh/intern/bmesh_operators.h. Your evaluation of the values for compare appear to be correct. type has one extra value at the beginning of the enum for 'normals'. I have tested this again and it now makes sense. Thanks for you response! $\endgroup$ – timdar Jan 24 at 14:27
  • $\begingroup$ Cool, glad you sorted it. wondered about that since normals are mentioned in docs. Apologies Had to rush off so posted a bit half-assed. Similar $\endgroup$ – batFINGER Jan 24 at 15:41
1
$\begingroup$

So building upon @batFingers answer and diving into the source code as suggested, the following values for compare and type are:

compare
0 - Equal to
1 - Greater than
2 - Less than

type
0 - Normals . . (The angle between normals)
1 - Faces . . (The number of adjacent faces)
2 - Vertex Group . . (Only search within the vertex group)
3 - Edges . . (The number of adjacent edges)


For example, if you have a basic grid and go:

mesh.ops.similar_verts(yourBmesh, verts=[aCornerVert], type=1, thresh=0.0, compare=0)

This will look at the number of adjacent faces(type=1) equal to(compare=0) the vert inputted, which in our case is a corner vert(I used 99). Each corner vert of the grid only has one adjacent face and so therefor each corner vert will be returned from this call.

An image captured from Blenders 3D viewport showing the resulting corner vertices being selected


If you go:

mesh.ops.similar_verts(yourBmesh, verts=[anEdgeVert], type=3, thresh=0.0, compare=0)

This will search the number of adjacent edges to the vert and/or verts supplied. Again, if you supplied a single vert from our grid(I used 89) which is on an edge but not a corner(has three adjacent edges) then all other verts with 3 adjacent edges will also be selected.

An image captured from Blenders 3D viewport showing the resulting edge vertices being selected

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.