INNER CODE UNIT · Python
reset_cameras
VITA-Group/Diffusion4D · rendering/blender.py:34
def reset_cameras() -> None:
"""Resets the cameras in the scene to a single default camera."""
# Delete all existing cameras
bpy.ops.object.select_all(action="DESELECT")
bpy.ops.object.select_by_type(type="CAMERA")
bpy.ops.object.delete()
# Create a new camera with default properties
bpy.ops.object.camera_add()
# Rename the new camera to 'NewDefaultCamera'
new_camera = bpy.context.active_object
new_camera.name = "Camera"
# Set the new camera as the active camera for the scene
scene.camera = new_camera