I'm attempting to inset the top face of a cube using the Blender API using the code below. If anyone could help me understand why I am not seeing any inset within edit mode after running my script that would be much appreciated. The cube is successfully created, but no inset is visible.
Thanks in advance :)
bpy.ops.mesh.primitive_cube_add(size=1)
cube = bpy.context.object
bpy.context.view_layer.objects.active = cube
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_mode(type='FACE')
bpy.ops.mesh.select_all(action='DESELECT')
cube.data.polygons[4].select = True
bpy.ops.mesh.inset(thickness=0.2)
cube.data.update()
bpy.ops.object.mode_set(mode='OBJECT')
```
bpy.ops
are for interactive use through the UI and should be avoided in scripts because they depend on context. Using them through scripts may yield unexpected results at best, or fail entirely at worst. Manipulate data directly frombpy.data
instead. $\endgroup$