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)
main
Pullusb 2022-07-20 18:09:28 +02:00
parent 2f7834ac94
commit b6e695eef3
4 changed files with 17 additions and 8 deletions

View File

@ -14,6 +14,10 @@ Activate / deactivate layer opacity according to prefix
Activate / deactivate all masks using MA layers 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 1.0.0
- fix: activate Z pass on newly created viewlayers - fix: activate Z pass on newly created viewlayers

View File

@ -1,3 +1,4 @@
from encodings import utf_8
import bpy import bpy
# import bpy_extras # import bpy_extras
from bpy_extras.object_utils import world_to_camera_view # as cam_space 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 scn = bpy.context.scene
result = {} 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): for fr in range(scn.frame_start,scn.frame_end + 1):
print(f'frame: {fr}')
scn.frame_set(fr) scn.frame_set(fr)
for o in C.selected_objects: for o in bpy.context.selected_objects:
if not result.get(o.name): if not result.get(o.name):
result[o.name] = [] result[o.name] = []
proj2d = world_to_camera_view(scn, scn.camera, o.matrix_world.to_translation()) # + Vector((.5,.5,0)) 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) txt = fn.get_ae_keyframe_clipboard_header(scn)
for v in value: 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 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 = blend.parent / 'render' / f'pos_{name}.txt'
keyfile.parent.mkdir(parents=False, exist_ok=True) keyfile.parent.mkdir(parents=False, exist_ok=True)
print(f'exporting keys for {name}') print(f'exporting keys for {name} at {keyfile}')
with open(keyfile, 'w') as fd:
## 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) fd.write(txt)

View File

@ -2,7 +2,7 @@ bl_info = {
"name": "GP Render", "name": "GP Render",
"description": "Organise export of gp layers through compositor output", "description": "Organise export of gp layers through compositor output",
"author": "Samuel Bernou", "author": "Samuel Bernou",
"version": (1, 0, 0), "version": (1, 0, 1),
"blender": (2, 93, 0), "blender": (2, 93, 0),
"location": "View3D", "location": "View3D",
"warning": "", "warning": "",

2
fn.py
View File

@ -1246,7 +1246,7 @@ def get_ae_keyframe_clipboard_header(scn):
t += '\tSource Pixel Aspect Ratio\t1\n' t += '\tSource Pixel Aspect Ratio\t1\n'
t += '\tComp Pixel Aspect Ratio\t1\n\n' t += '\tComp Pixel Aspect Ratio\t1\n\n'
t += 'Transform\tPosition\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 return t