From adbb813410f7098e0e248c205738fe9974c8aeaa Mon Sep 17 00:00:00 2001 From: pullusb Date: Tue, 15 Oct 2024 16:04:27 +0200 Subject: [PATCH] fix camera always exported even when unchecked --- OP_export_to_ae.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/OP_export_to_ae.py b/OP_export_to_ae.py index 8a0ab8c..39b591d 100644 --- a/OP_export_to_ae.py +++ b/OP_export_to_ae.py @@ -36,7 +36,7 @@ def Export_AE_2d_position_json_data(): pix_pos = Vector((pos[0]*rx, (1-pos[1])*ry)) ''' -def export_ae_transforms(directory, selection=None, camera=None, exposition=True, prefix='ae_', suffix='', fr=False, export_format='txt'): +def export_ae_transforms(directory, selection=None, camera=None, exposition=True, prefix='ae_', suffix='', fr=False, export_format='txt', export_cam=True): """ Export After Effects transform data for selected objects and camera in Blender. @@ -181,7 +181,7 @@ def export_ae_transforms(directory, selection=None, camera=None, exposition=True "comp_pixel_aspect_ratio": 1, 'objects': objs_keyframe_data } - if camera is not None: + if export_cam: #camera is not None: keyframe_data['camera'] = cam_key_frame_data Path(directory, f'{prefix}keyframe_data{suffix}.json').write_text(json.dumps(keyframe_data, indent=4), encoding='utf-8') @@ -192,7 +192,7 @@ def export_ae_transforms(directory, selection=None, camera=None, exposition=True keyframe_data_txt = get_keyframe_data_txt(keyframe_data, exposition=exposition) Path(directory, f'{prefix}{name}{suffix}.txt').write_text(keyframe_data_txt, newline='\r\n') - if camera is not None: + if export_cam: #camera is not None: keyframe_data_txt = get_keyframe_data_txt(cam_key_frame_data, exposition=False) Path(directory, f'{prefix}{camera.name}{suffix}.txt').write_text(keyframe_data_txt, newline='\r\n') @@ -313,11 +313,11 @@ class GPEXP_OT_export_anim_to_ae(bpy.types.Operator, ExportHelper): print('Output directory: ', output_path) cam = None - if self.use_active_camera and context.scene.camera: + if context.scene.camera: cam = context.scene.camera if cam and cam in objects_selection: - ## Remove active camera from objects + ## Remove active camera from objects list objects_selection.pop(objects_selection.index(cam)) print('Export AE transform from objects:') @@ -330,7 +330,8 @@ class GPEXP_OT_export_anim_to_ae(bpy.types.Operator, ExportHelper): exposition=self.exposition, prefix='ae_', fr=self.data_lang == 'FR', - export_format=self.file_format) + export_format=self.file_format, + export_cam=self.use_active_camera) self.report({'INFO'}, f'File(s) saved in folder: {output_path}') return {"FINISHED"}