I want to write an add-on that will change the position and rotation of the selected camera on the fly. What code would I use to call this?
Note that I will want to first check whether the selected object is indeed a camera object before changing the position and rotation. There can be multiple cameras in a scene.
Thanks for both of your responses. How do I find out what the selected object is in a scene, though? There’s no guarantee that the camera is going to be called “Camera”. (Of course, I realize multiple objects can be selected – in that case, I just want to look at the first selected object that I find.)
import bpy
obj_act= bpy.context.active_object
print('Active object =', obj_act )
and for selected
import bpy
sel_objects = bpy.context.selected_objects
for obj in sel_objects:
print ('obj type =', obj.type,' name =', obj.name )