From a Python script I want to activate an object in order to enter editing mode and edit it. To select the desired object I use
bpy.context.scene.objects["Nombre_objeto"].select = True # (1)
What happens is that if before selecting the object another active object exists, when entering edit mode with bpy.ops.object.editmode_toggle()
, it enters the editing mode of the object that was previously active and not the object selected with ( 1).
I would like to know how I can leave an active object to edit its properties.
I hope someone can help me, thanks for the attention given. Annex Python code to run in Blender, so you can see what I mean exactly.
###INICIO-CÓDIGO###
import bpy
bpy.ops.mesh.primitive_uv_sphere_add(size=1, location=(-1,-2,0))
bpy.ops.object.duplicate_move()
nombre = 'c1'
bpy.context.object.name = nombre
bpy.data.objects[nombre].location=(1, 2, 0)
bpy.context.scene.objects["Esfera"].select = True
bpy.ops.object.editmode_toggle()
##<-- EJECUTAR SCRIPT -->##
###FIN-CÓDIGO###