fix camera always exported even when unchecked

main
pullusb 2024-10-15 16:04:27 +02:00
parent 09eca87060
commit adbb813410
1 changed files with 7 additions and 6 deletions

View File

@ -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"}