Skip to content

Instantly share code, notes, and snippets.

@CGArtPython
Created July 6, 2022 15:01
Show Gist options
  • Save CGArtPython/0353134fd626c896ea2bfb494dc9b96e to your computer and use it in GitHub Desktop.
Save CGArtPython/0353134fd626c896ea2bfb494dc9b96e to your computer and use it in GitHub Desktop.
Blender Python script to deselect faces using thier index
# give Python access to Blender's mesh manipulation functionality
import bmesh
# give Python access to Blender's functionality
import bpy
# add cube
bpy.ops.mesh.primitive_cube_add()
obj = bpy.context.active_object
# enable edit mode
bpy.ops.object.editmode_toggle()
# create a BMesh object to manipulate geometry data (must be done in edit mode)
bm = bmesh.from_edit_mesh(obj.data)
# make sure we can use the square brackets to access faces
bm.faces.ensure_lookup_table()
# deselect face with index 0
bm.faces[0].select = False
# deselect face with index 1
bm.faces[1].select = False
# deselect face with index 2
bm.faces[2].select = False
# disable edit mode
# bpy.ops.object.editmode_toggle()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment