I am trying to use bpy.ops for things like separating meshes, changing bpy.context.mode, adding modifiers and deleting meshes. However, I am unsure how to change which object bpy.ops operates on.
Here is my code
object.select_set(True)
bpy.ops.object.delete()
I have heard to avoid bpy.ops but I do not know any alternatives to my usages of bpy.ops so any suggestions on alternatives would be appreciated.
Thank You!
bpy.data.objects.remove(obj)for this specific usecase. However in general what you are looking for is an operator override. I set out to create a list of them out there maybe it will be of some help https://blender.stackexchange.com/questions/248274/a-comprehensive-list-of-operator-overrides – Gorgious Jun 17 '22 at 19:12bpy.context.temp_override()[(https://docs.blender.org/api/current/bpy.types.Context.html#bpy.types.Context.temp_override) – Marty Fouts Jun 17 '22 at 21:05