From 9b2114bdb18648ea21bcc9d894a33961b053df5c Mon Sep 17 00:00:00 2001 From: duckz Date: Tue, 9 May 2023 13:57:44 +0800 Subject: [PATCH] Fixing camera not switching --- main/exporter.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main/exporter.py b/main/exporter.py index f2b098e..93fb7d1 100644 --- a/main/exporter.py +++ b/main/exporter.py @@ -299,12 +299,18 @@ def render_and_save_nfts(input): log.info(f"\nDNA Code:{full_single_dna}") + active_camera = False for c in dna_dictionary: collection = dna_dictionary[c] if collection != '0': bpy.data.collections[collection].hide_render = False bpy.data.collections[collection].hide_viewport = False + # Detect camera in collection + for ob in bpy.data.collections[collection].objects: + if ob.type == 'CAMERA': + active_camera = ob + time_start_2 = time.time() # Main paths for batch sub-folders: @@ -332,6 +338,10 @@ def render_and_save_nfts(input): if os.path.exists(file_path): os.remove(file_path) + # Switching Camera + if active_camera: + bpy.context.scene.camera = active_camera + # Generation/Rendering: if input.enable_images: