How to rotate a 'non-active' object with python? I have a laptop model and I want to be able to control the rotation of the screen through python. I have a basic menu with a slider. I had an armature and a bone and I got that working but it only worked when it was selected and in pose mode, however I want to be able to control it regardless of whether its selected or not. So I removed the bone and separated the screen from the body. But now its the same thing, I can only get the screen to rotate when it's selected...

This is the line of code that rotates the screen:

bpy.context.object..rotation_euler[0] = (self.screen_rotation * 0) + ((1 - self.screen_rotation) * 1.58825)


How can I make so I can rotate the screen without it having to be selected?
You could lookup the object by its name:

o = bpy.data.objects["Cube"] # Cube represents the name of your object


and manipulate the rotation

o.rotation_euler[0] = (self.screen_rotation * 0) + ((1 - self.screen_rotation) * 1.58825)