From b6e695eef3c2a7257349d7a49baf46bf038bc911 Mon Sep 17 00:00:00 2001 From: Pullusb Date: Wed, 20 Jul 2022 18:09:28 +0200 Subject: [PATCH] fix 2D position for AE from linux 1.0.1 - fix: `Export Camera 2D Position To AE` file format not working on windows when export from linux (add CRLF terminator to generated text file) --- CHANGELOG.md | 4 ++++ OP_export_to_ae.py | 17 +++++++++++------ __init__.py | 2 +- fn.py | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f36b34..c62a4e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ Activate / deactivate layer opacity according to prefix Activate / deactivate all masks using MA layers --> +1.0.1 + +- fix: `Export Camera 2D Position To AE` file format not working on windows when export from linux (add CRLF terminator to generated text file) + 1.0.0 - fix: activate Z pass on newly created viewlayers diff --git a/OP_export_to_ae.py b/OP_export_to_ae.py index dfcaf9b..34d41e3 100644 --- a/OP_export_to_ae.py +++ b/OP_export_to_ae.py @@ -1,3 +1,4 @@ +from encodings import utf_8 import bpy # import bpy_extras from bpy_extras.object_utils import world_to_camera_view # as cam_space @@ -46,12 +47,13 @@ def export_AE_objects_position_keys(): scn = bpy.context.scene result = {} - + print(f'Exporting 2d position (scene range: {scn.frame_start} - {scn.frame_end})') for fr in range(scn.frame_start,scn.frame_end + 1): - scn.frame_set(fr) + print(f'frame: {fr}') + scn.frame_set(fr) - for o in C.selected_objects: + for o in bpy.context.selected_objects: if not result.get(o.name): result[o.name] = [] proj2d = world_to_camera_view(scn, scn.camera, o.matrix_world.to_translation()) # + Vector((.5,.5,0)) @@ -67,7 +69,7 @@ def export_AE_objects_position_keys(): txt = fn.get_ae_keyframe_clipboard_header(scn) for v in value: - txt += '\t%s\t%s\t%s\t\n'%(v[0],v[1],v[2]) + txt += '\t%s\t%s\t%s\t0\t\n'%(v[0],v[1],v[2]) # add 0 for Z (probably not needed) txt += '\n\nEnd of Keyframe Data\n' # keyframe txt footer @@ -75,8 +77,11 @@ def export_AE_objects_position_keys(): keyfile = blend.parent / 'render' / f'pos_{name}.txt' keyfile.parent.mkdir(parents=False, exist_ok=True) - print(f'exporting keys for {name}') - with open(keyfile, 'w') as fd: + print(f'exporting keys for {name} at {keyfile}') + + ## save forcing CRLF terminator (DOS style, damn windows) + ## in case it's exported from linux + with open(keyfile, 'w', newline='\r\n') as fd: fd.write(txt) diff --git a/__init__.py b/__init__.py index 4a36da5..48673e3 100644 --- a/__init__.py +++ b/__init__.py @@ -2,7 +2,7 @@ bl_info = { "name": "GP Render", "description": "Organise export of gp layers through compositor output", "author": "Samuel Bernou", - "version": (1, 0, 0), + "version": (1, 0, 1), "blender": (2, 93, 0), "location": "View3D", "warning": "", diff --git a/fn.py b/fn.py index 1d62d75..98e5e62 100644 --- a/fn.py +++ b/fn.py @@ -1246,7 +1246,7 @@ def get_ae_keyframe_clipboard_header(scn): t += '\tSource Pixel Aspect Ratio\t1\n' t += '\tComp Pixel Aspect Ratio\t1\n\n' t += 'Transform\tPosition\n' - t += '\tFrame\tX pixels\tY pixels\tyZ pixels\t\n' + t += '\tFrame\tX pixels\tY pixels\tZ pixels\t\n' return t