Changeset View
Changeset View
Standalone View
Standalone View
io_export_after_effects.py
| Show All 17 Lines | |||||
| # <pep8 compliant> | # <pep8 compliant> | ||||
| bl_info = { | bl_info = { | ||||
| "name": "Export: Adobe After Effects (.jsx)", | "name": "Export: Adobe After Effects (.jsx)", | ||||
| "description": "Export cameras, selected objects & camera solution " | "description": "Export cameras, selected objects & camera solution " | ||||
| "3D Markers to Adobe After Effects CS3 and above", | "3D Markers to Adobe After Effects CS3 and above", | ||||
| "author": "Bartek Skorupa, (Adi Samsonoff)", | "author": "Bartek Skorupa, (Adi Samsonoff)", | ||||
| "version": (0, 0, 66), | "version": (0, 0, 67), | ||||
| "blender": (2, 80, 0), | "blender": (2, 80, 0), | ||||
| "location": "File > Export > Adobe After Effects (.jsx)", | "location": "File > Export > Adobe After Effects (.jsx)", | ||||
| "warning": "", | "warning": "", | ||||
| "doc_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/" | "doc_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/" | ||||
| "Scripts/Import-Export/Adobe_After_Effects", | "Scripts/Import-Export/Adobe_After_Effects", | ||||
| "category": "Import-Export", | "category": "Import-Export", | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | |||||
| # convert object bundle's matrix. Not ready yet. Temporarily not active | # convert object bundle's matrix. Not ready yet. Temporarily not active | ||||
| #def get_ob_bundle_matrix_world(cam_matrix_world, bundle_matrix): | #def get_ob_bundle_matrix_world(cam_matrix_world, bundle_matrix): | ||||
| # matrix = cam_matrix_basis | # matrix = cam_matrix_basis | ||||
| # return matrix | # return matrix | ||||
| # jsx script for AE creation | # jsx script for AE creation | ||||
| def write_jsx_file(file, data, selection, include_animation, include_active_cam, include_selected_cams, include_selected_objects, include_cam_bundles): | def write_jsx_file(file, data, selection, include_animation, include_active_cam, include_selected_cams, include_selected_objects, include_cam_bundles, object_anchor_point_type): | ||||
| print("\n---------------------------\n- Export to After Effects -\n---------------------------") | print("\n---------------------------\n- Export to After Effects -\n---------------------------") | ||||
| # store the current frame to restore it at the end of export | # store the current frame to restore it at the end of export | ||||
| curframe = data['curframe'] | curframe = data['curframe'] | ||||
| # create array which will contain all keyframes values | # create array which will contain all keyframes values | ||||
| js_data = { | js_data = { | ||||
| 'times': '', | 'times': '', | ||||
| 'cameras': {}, | 'cameras': {}, | ||||
| ▲ Show 20 Lines • Show All 333 Lines • ▼ Show 20 Lines | def write_jsx_file(file, data, selection, include_animation, include_active_cam, include_selected_cams, include_selected_objects, include_cam_bundles, object_anchor_point_type): | ||||
| # create objects (nulls) | # create objects (nulls) | ||||
| jsx_file.write('// ************** OBJECTS **************\n\n\n') | jsx_file.write('// ************** OBJECTS **************\n\n\n') | ||||
| for i, obj in enumerate(js_data['nulls']): | for i, obj in enumerate(js_data['nulls']): | ||||
| name_ae = obj | name_ae = obj | ||||
| jsx_file.write('var %s = newComp.layers.addNull();\n' % (name_ae)) | jsx_file.write('var %s = newComp.layers.addNull();\n' % (name_ae)) | ||||
| jsx_file.write('%s.threeDLayer = true;\n' % name_ae) | jsx_file.write('%s.threeDLayer = true;\n' % name_ae) | ||||
| jsx_file.write('%s.source.name = "%s";\n' % (name_ae, name_ae)) | jsx_file.write('%s.source.name = "%s";\n' % (name_ae, name_ae)) | ||||
| if object_anchor_point_type == 'CENTERED': | |||||
| jsx_file.write('%s.anchorPoint.setValue([%s.width / 2, %s.height / 2, 0]);\n' % (name_ae, name_ae, name_ae)) | |||||
| # Set values of properties, add kyeframes only where needed | # Set values of properties, add kyeframes only where needed | ||||
| if include_animation and js_data['nulls'][name_ae]['position_anim']: | if include_animation and js_data['nulls'][name_ae]['position_anim']: | ||||
| jsx_file.write('%s.property("position").setValuesAtTimes([%s],[%s]);\n' % (name_ae, js_data['times'], js_data['nulls'][obj]['position'])) | jsx_file.write('%s.property("position").setValuesAtTimes([%s],[%s]);\n' % (name_ae, js_data['times'], js_data['nulls'][obj]['position'])) | ||||
| else: | else: | ||||
| jsx_file.write('%s.property("position").setValue(%s);\n' % (name_ae, js_data['nulls'][obj]['position_static'])) | jsx_file.write('%s.property("position").setValue(%s);\n' % (name_ae, js_data['nulls'][obj]['position_static'])) | ||||
| if include_animation and js_data['nulls'][name_ae]['orientation_anim']: | if include_animation and js_data['nulls'][name_ae]['orientation_anim']: | ||||
| jsx_file.write('%s.property("orientation").setValuesAtTimes([%s],[%s]);\n' % (name_ae, js_data['times'], js_data['nulls'][obj]['orientation'])) | jsx_file.write('%s.property("orientation").setValuesAtTimes([%s],[%s]);\n' % (name_ae, js_data['times'], js_data['nulls'][obj]['orientation'])) | ||||
| else: | else: | ||||
| ▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | def write_jsx_file(file, data, selection, include_animation, include_active_cam, include_selected_cams, include_selected_objects, include_cam_bundles, object_anchor_point_type): | ||||
| data['scn'].frame_set(curframe) # set current frame of animation in blender to state before export | data['scn'].frame_set(curframe) # set current frame of animation in blender to state before export | ||||
| ########################################## | ########################################## | ||||
| # DO IT | # DO IT | ||||
| ########################################## | ########################################## | ||||
| def main(file, context, include_animation, include_active_cam, include_selected_cams, include_selected_objects, include_cam_bundles): | def main(file, context, include_animation, include_active_cam, include_selected_cams, include_selected_objects, include_cam_bundles, object_anchor_point_type): | ||||
| data = get_comp_data(context) | data = get_comp_data(context) | ||||
| selection = get_selected(context) | selection = get_selected(context) | ||||
| write_jsx_file(file, data, selection, include_animation, include_active_cam, include_selected_cams, include_selected_objects, include_cam_bundles) | write_jsx_file(file, data, selection, include_animation, include_active_cam, include_selected_cams, include_selected_objects, include_cam_bundles, object_anchor_point_type) | ||||
| print ("\nExport to After Effects Completed") | print ("\nExport to After Effects Completed") | ||||
| return {'FINISHED'} | return {'FINISHED'} | ||||
| ########################################## | ########################################## | ||||
| # ExportJsx class register/unregister | # ExportJsx class register/unregister | ||||
| ########################################## | ########################################## | ||||
| from bpy_extras.io_utils import ExportHelper | from bpy_extras.io_utils import ExportHelper | ||||
| from bpy.props import StringProperty, BoolProperty | from bpy.props import StringProperty, BoolProperty, EnumProperty | ||||
| class ExportJsx(bpy.types.Operator, ExportHelper): | class ExportJsx(bpy.types.Operator, ExportHelper): | ||||
| """Export selected cameras and objects animation to After Effects""" | """Export selected cameras and objects animation to After Effects""" | ||||
| bl_idname = "export.jsx" | bl_idname = "export.jsx" | ||||
| bl_label = "Export to Adobe After Effects" | bl_label = "Export to Adobe After Effects" | ||||
| filename_ext = ".jsx" | filename_ext = ".jsx" | ||||
| filter_glob: StringProperty(default="*.jsx", options={'HIDDEN'}) | filter_glob: StringProperty(default="*.jsx", options={'HIDDEN'}) | ||||
| Show All 18 Lines | include_selected_objects: BoolProperty( | ||||
| description="Export Selected Objects", | description="Export Selected Objects", | ||||
| default=True, | default=True, | ||||
| ) | ) | ||||
| include_cam_bundles: BoolProperty( | include_cam_bundles: BoolProperty( | ||||
| name="Camera 3D Markers", | name="Camera 3D Markers", | ||||
| description="Include 3D Markers of Camera Motion Solution for selected cameras", | description="Include 3D Markers of Camera Motion Solution for selected cameras", | ||||
| default=True, | default=True, | ||||
| ) | ) | ||||
| object_anchor_point_type: EnumProperty( | |||||
| items=[ | |||||
| ("DEFAULT", "Default", "Anchor point will be default (0,0,0)"), | |||||
| ("CENTERED", "Centered", "Anchor point will be centered"), | |||||
| ], | |||||
| name="Anchor Point for Objects", | |||||
| description="Anchor Point for Objects", | |||||
| default="DEFAULT", | |||||
| ) | |||||
| # include_ob_bundles = BoolProperty( | # include_ob_bundles = BoolProperty( | ||||
| # name="Objects 3D Markers", | # name="Objects 3D Markers", | ||||
| # description="Include 3D Markers of Object Motion Solution for selected cameras", | # description="Include 3D Markers of Object Motion Solution for selected cameras", | ||||
| # default=True, | # default=True, | ||||
| # ) | # ) | ||||
| def draw(self, context): | def draw(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| box = layout.box() | box = layout.box() | ||||
| box.label(text='Animation:') | box.label(text='Animation:') | ||||
| box.prop(self, 'include_animation') | box.prop(self, 'include_animation') | ||||
| box.label(text='Include Cameras and Objects:') | box.label(text='Include Cameras and Objects:') | ||||
| box.prop(self, 'include_active_cam') | box.prop(self, 'include_active_cam') | ||||
| box.prop(self, 'include_selected_cams') | box.prop(self, 'include_selected_cams') | ||||
| box.prop(self, 'include_selected_objects') | box.prop(self, 'include_selected_objects') | ||||
| box.label(text="Include Tracking Data:") | box.label(text="Include Tracking Data:") | ||||
| box.prop(self, 'include_cam_bundles') | box.prop(self, 'include_cam_bundles') | ||||
| box.prop(self, 'object_anchor_point_type') | |||||
| # box.prop(self, 'include_ob_bundles') | # box.prop(self, 'include_ob_bundles') | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| active = context.active_object | active = context.active_object | ||||
| selected = context.selected_objects | selected = context.selected_objects | ||||
| camera = context.scene.camera | camera = context.scene.camera | ||||
| ok = selected or camera | ok = selected or camera | ||||
| return ok | return ok | ||||
| def execute(self, context): | def execute(self, context): | ||||
| return main(self.filepath, context, self.include_animation, self.include_active_cam, self.include_selected_cams, self.include_selected_objects, self.include_cam_bundles) | return main(self.filepath, context, self.include_animation, self.include_active_cam, self.include_selected_cams, self.include_selected_objects, self.include_cam_bundles, self.object_anchor_point_type) | ||||
| def menu_func(self, context): | def menu_func(self, context): | ||||
| self.layout.operator(ExportJsx.bl_idname, text="Adobe After Effects (.jsx)") | self.layout.operator(ExportJsx.bl_idname, text="Adobe After Effects (.jsx)") | ||||
| def register(): | def register(): | ||||
| bpy.utils.register_class(ExportJsx) | bpy.utils.register_class(ExportJsx) | ||||
| Show All 9 Lines | |||||