0
$\begingroup$

I have an object that consists of two polygons. I'm trying to get a vertices count for the first polygon so I can select it's last two vertexes by index. I know that it starts at Index 1.

I can use

bm.verts[firstindex].select = True

bm.verts[secondindex].select = True

and then

bpy.ops.mesh.loop_multi_select(ring=False)

to select the edge loop, but is there any way I can get a vertex count only for the vertices in the edge loop? Thanks.

$\endgroup$
1
$\begingroup$

Or you could also do:

import bpy
import bmesh

selected_verts = [v for v in bpy.context.active_object.data.vertices if v.select]
count = len(selected_verts)
print(count)
```
$\endgroup$
  • $\begingroup$ This just gives me a value of zero for my selected edge loop. I tried selecting every vertex and ran this and it still gave me zero for the count value. $\endgroup$ – James Oct 5 at 21:47
  • 1
    $\begingroup$ Is the edge loop the boundary of the mesh? Did you select the vertex in edit mode? $\endgroup$ – Quantic_Solver Oct 8 at 10:00
  • $\begingroup$ Thanks, changing the mode to Edit did the trick. I must have had it in Object mode last time. Oops. $\endgroup$ – James Oct 8 at 18:01
0
$\begingroup$
import bpy
import bmesh

    mode = bpy.context.active_object.mode
    selectedVerts = [v for v in bpy.context.active_object.data.vertices if v.select]
    count=0
    for v in selectedVerts:
        count+=1
        print(count)

bpy.ops.object.mode_set(mode=mode)
$\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.