I'm trying to extrude a single vertex several times in a loop for different directions. For that I'm using the function: bpy.ops.mesh.extrude_vertices_move(MESH_OT_extrude_verts_indiv=???,TRANSFORM_OT_translate={"value":(new_direction)})

If I use this function without the MESH_OT_extrude_verts_indiv it will extrude the last active vertex, wich is the one I just extruded. The problem is that I don't know what to put in MESH_OT_extrude_verts_indiv. I tried to put the vertex in that loop index, but I can't put a Vector type in it.

Can anyone give me an example of what to put in this MESH_OT_extrude_verts_indiv?

Here is my code:^

for k in range(0,5): 
    for v in bpy.context.active_object.data.vertices: 

#new_direction is a random vector

Use bmesh

enter image description here

Strongly recommend using bmesh instead of bpy.ops.mesh whenever you can.

Here is my understanding of the script needed. Extrudes the individual selected vertices randomly a number of repeats.

The operators return dictionary has the newly created vertices and edges.

import bpy
import bmesh
from mathutils import Vector
from random import uniform

context = bpy.context
ob = context.edit_object # edit mode!
me = ob.data
bm = bmesh.from_edit_mesh(me)
verts = [v for v in bm.verts if v.select]
for repeats in range(5):
    ret = bmesh.ops.extrude_vert_indiv(bm,
    for v in ret["verts"]: 
        v.co += Vector([uniform(-1, 1) for a in "xyz"])
    verts = ret["verts"]


If the idea is to extrude from the same vert repeat times, then remove the line

verts = ret["verts"}
| improve this answer | |

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.