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.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={
"number_cuts":5,
"smoothness":1,
"falloff":'INVERSE_SQUARE',
"object_index":0,
"edge_index":4,
"mesh_select_mode_init":(False, True, False)
},
TRANSFORM_OT_edge_slide={
"value":0,
"single_side":False,
"use_even":False,
"flipped":False,
"use_clamp":True,
"mirror":True,
"snap":False,
"snap_target":'CLOSEST',
"snap_point":(0, 0, 0),
"snap_align":False,
"snap_normal":(0, 0, 0),
"correct_uv":False,
"release_confirm":False,
"use_accurate":False})
bpy.ops.object.editmode_toggle()
```

