0
$\begingroup$

I want to create a small Script that works with any object, but I need to create a new Vertex group of the selected vertices with Python

Mesh before running the script Mesh after running the script

import bpy

# Modeling
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.extrude_region_move(MESH_OT_extrude_region
{"use_normal_flip":False, "mirror":False}, TRANSFORM_OT_translate={"value": 
(0, 0, 0.5), "orient_type":'GLOBAL', "orient_matrix":((1, 0, 0), (0, 1, 0), 
(0, 0, 1)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, 
True), "mirror":False, "use_proportional_edit":False, 
"proportional_edit_falloff":'SMOOTH', "proportional_size":1, 
"use_proportional_connected":False, "use_proportional_projected":False, 
"snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), 
"snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, 
"cursor_transform":False, "texture_space":False, "remove_on_cancel":False, 
"release_confirm":False, "use_accurate":False})
bpy.ops.transform.edge_bevelweight(value=1)

# New Vertex group from selected vertex

bpy.ops.object.vertex_group_add()
$\endgroup$
  • $\begingroup$ bpy.ops.object.vertex_group_add() docs.blender.org/api/current/bpy.types.VertexGroup.html $\endgroup$ – A M Oct 21 at 9:06
  • $\begingroup$ Could you please post code examples as text. $\endgroup$ – batFINGER Oct 21 at 11:35
  • $\begingroup$ @AM Thank you, your help has helped me move forward, now what I don't know is: How could I change the name of the Vertex group? $\endgroup$ – Jhon Oct 21 at 18:53
  • $\begingroup$ @batFINGER I just added the code, How could I change the name of the Vertex group? $\endgroup$ – Jhon Oct 21 at 18:53

Your Answer

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

Browse other questions tagged or ask your own question.