How to use loopcut_slide operation without any UI? So i need to perform some basic loop cut and slide operators on a mesh.
The edge index is known and the slide amount is also fixed.
using override method from How do I override context for bpy.ops.mesh.loopcut? i am able to perform the cut successfully inside blender script editor.
but when run without the UI the the script gives an error.
I would also like to know if there is an alternate non-UI based methods to perform loop cuts with proper UV updates
here's an example version which adds loop cuts and smooth operation. tested on Blender 2.83 script editor
import bpy

bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)

bpy.ops.mesh.primitive_cube_add(enter_editmode=False, align='WORLD', location=(0, 0, 0))
bpy.ops.object.editmode_toggle()


win      = bpy.context.window
scr      = win.screen
areas3d  = [area for area in scr.areas if area.type == 'VIEW_3D']
region   = [region for region in areas3d[0].regions if region.type == 'WINDOW']

override = {'window':win,
            'screen':scr,
            'area'  :areas3d[0],
            'region':region[0],
            'scene' :bpy.context.scene,
            }


bpy.ops.mesh.loopcut_slide(override, 
MESH_OT_loopcut={
&quot;number_cuts&quot;:5, 
&quot;smoothness&quot;:1, 
&quot;falloff&quot;:'INVERSE_SQUARE', 
&quot;object_index&quot;:0, 
&quot;edge_index&quot;:4, 
&quot;mesh_select_mode_init&quot;:(False, True, False)
}, 
TRANSFORM_OT_edge_slide={
&quot;value&quot;:0,
&quot;single_side&quot;:False,
&quot;use_even&quot;:False,
&quot;flipped&quot;:False,
&quot;use_clamp&quot;:True,
&quot;mirror&quot;:True,
&quot;snap&quot;:False,
&quot;snap_target&quot;:'CLOSEST',
&quot;snap_point&quot;:(0, 0, 0),
&quot;snap_align&quot;:False,
&quot;snap_normal&quot;:(0, 0, 0),
&quot;correct_uv&quot;:False,
&quot;release_confirm&quot;:False,
&quot;use_accurate&quot;:False})

bpy.ops.object.editmode_toggle()

```
bmesh bisect does exactly this...but its not automated like bpy loopcut so make sure to select all the faces you need to cut and you'll need to provide the cutting location &amp; direction yourself.
import bpy
import bmesh
import math
import mathutils

bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)
bpy.ops.mesh.primitive_plane_add(enter_editmode=False, align='WORLD', location=(0, 0, 0))

def bmesh_loopcut(bm,face_list,direction_axis,center='auto'):
    for f in bm.faces:
        f.select = False
    bm.faces.ensure_lookup_table()  
    for f in face_list:
        bm.faces[f].select = True

    edges = [e for e in bm.edges if e.select == True]
    faces = [f for f in bm.faces if f.select == True]
    
    if center=='auto':    
        weights = [f.calc_area() for f in faces]
        weighted_centres = [f.calc_area() * f.calc_center_median() for f in faces]
        cutting_point = sum(weighted_centres, mathutils.Vector()) / sum(weights)
    else:
        cutting_point = bpy.context.scene.cursor.location
    geom = []
    geom.extend(edges)
    geom.extend(faces) 

    result = bmesh.ops.bisect_plane(bm,dist=0.01,geom=geom,plane_co=cutting_point,plane_no=direction_axis)



# Make a new BMesh
bm = bmesh.new()

obj = bpy.context.object

ob = obj
me = ob.data 
bm = bmesh.new() 
bm.from_mesh(me)


face_cut=([0])
bmesh_loopcut(bm,face_cut,[1,0,0])
    
bm.to_mesh(me)
bm.free()
me.update()

```