I'm making a script to automate some steps I do quite often. In the script I need to change the active selection from one object to another to work on that object and then return the active selection to the first one, e.g. I have a cube and a circle, both separated objects, I do some things with the cube and then I have to select the circle to do some other operations, then when I'm done with that, I want to select the cube to keep working with it, thanks in advance.
I found the answer here.
The way you make an object active is through the overwrite of:
so if you have a Cube named 'Cube', and you want to make it active, you will do:
cube = bpy.data.objects['Cube'] bpy.context.scene.objects.active = cube