1
$\begingroup$

I'm trying to select just the new vertices after using poke face, this is what I have so far, but it doesn't work if I use poke on multiple connected faces. Any ideas?

import bpy
bpy.ops.mesh.poke()
bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
bpy.ops.mesh.select_less()
$\endgroup$
1

2 Answers 2

2
$\begingroup$

Use bmesh.

Recommend using the bmesh module, to avoid mode toggling and other insanity.

Input the faces into the bmesh.ops.poke operator and it returns a dictionary of the newly created geometry. (faces and verts)

import bpy
import bmesh

context = bpy.context

ob = context.edit_object
me = ob.data
bm = bmesh.from_edit_mesh(me)

faces = [f for f in bm.faces if f.select]

poked = bmesh.ops.poke(
        bm,
        faces=faces,
        )
        
print("New verts", poked["verts"])
$\endgroup$
1
$\begingroup$

you might try the return value of the operator

poked = bpy.ops.mesh.poke()
verts = poked['verts']
for v in verts:
    v.select = True

You could also do select in object mode:

verts = [v.index for v in verts]
for v in verts:
    ob.data.vertices[v].select = True
ob.data.update()
$\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.