Removing mesh from object without using mesh vertice indexes or IDs

Hey :slight_smile:

I was wondering if there was a way to remove a mesh from an object (composed of multiple meshes), without messing with the vertex order/ID of the other meshes :thinking:

Hello and welcome to BlenderArtists.


I'm not sure if vertex groups count as mesh IDs, but you can assign individual mesh pieces to one or more separate vertex groups for easier selecting / deselecting.

If you’d prefer, you can also use a small Python script that you run to delete all mesh pieces that are in a certain vertex group as well.

This script will select any desired vertex group, then while in edit-mode, select and delete all vertices in that particular vertex group.

import bpy

# VARIABLES
OBJ = bpy.data.objects["Cube"]
VERTEX_GROUP_INDEX = 1

bpy.ops.object.mode_set(mode="OBJECT")
bpy.ops.object.select_all(action="DESELECT")
OBJ.select_set(True)
bpy.ops.object.mode_set(mode="EDIT")
bpy.ops.mesh.select_all(action="DESELECT")
OBJ.vertex_groups.active_index = VERTEX_GROUP_INDEX
bpy.ops.object.vertex_group_select()
bpy.ops.mesh.delete(type="VERT")
bpy.ops.object.mode_set(mode="OBJECT")
bpy.ops.object.select_all(action="DESELECT")