The left convex hull is created in object mode
and the right convex hull is created in edit mode
I want the convex hull of selected verts only and not the entire object in the new object
import bpy
import bmesh
bm = bmesh.new()
bm.from_mesh(bpy.context.object.data)
if bpy.context.object.mode == 'EDIT':
verts = [v for v in bm.verts if v.select]
else:
verts = bm.verts
hull = bmesh.ops.convex_hull(bm, input=verts, use_existing_faces=True)
bmesh.ops.delete(bm, geom=hull["geom_unused"] + hull["geom_interior"], context='VERTS',)
name = 'Convex Hull'
mesh = bpy.data.meshes.new(name)
bm.to_mesh(mesh)
mesh.update()
bm.clear()
object = bpy.data.objects.new(name, mesh)
bpy.context.scene.collection.objects.link(object)