0
$\begingroup$

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')
```
$\endgroup$
1

1 Answer 1

0
$\begingroup$

try this:

enter image description here

create a cube, select it, then run the code.

In Edit mode you see the result of the picture.

Beware: this insets all faces, i hope you can adapt the code that it only insets one face, if not, let me know.

import bpy
import bmesh

me = bpy.context.object.data
bm = bmesh.new()
bm.from_mesh(me)
faces = bm.faces[:]

insetFaces=bmesh.ops.inset_individual(bm, faces=faces,thickness=.10, depth=.0)
    
bm.to_mesh(me)
bm.free()
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .