chore(auto_export): further experimentation

This commit is contained in:
kaosat.dev 2024-03-19 14:19:32 +01:00
parent 1c51d10da7
commit 87c03657e5
2 changed files with 10 additions and 9 deletions

View File

@ -28,13 +28,14 @@ def remove_unwanted_custom_properties(object):
def duplicate_object(object): def duplicate_object(object):
obj_copy = object.copy() obj_copy = object.copy()
# FIXME: orphan data comes from this one # FIXME: orphan data comes from this one
if object.data: """if object.data:
data = object.data.copy() data = object.data.copy()
obj_copy.data = data obj_copy.data = data"""
if object.animation_data and object.animation_data.action: copy_animation_data(object, obj_copy)
"""if object.animation_data and object.animation_data.action:
if obj_copy.animation_data == None: if obj_copy.animation_data == None:
obj_copy.animation_data_create() obj_copy.animation_data_create()
obj_copy.animation_data.action = object.animation_data.action.copy() obj_copy.animation_data.action = object.animation_data.action.copy()"""
return obj_copy return obj_copy
# TODO: rename actions # TODO: rename actions
@ -43,13 +44,13 @@ def copy_animation_data(source, target):
data = source.data.copy() data = source.data.copy()
target.data = data""" target.data = data"""
if source.animation_data and source.animation_data.action: if source.animation_data and source.animation_data.action:
print("source", source.animation_data.action.name) print("current action name", source.animation_data.action.name)
print("copying animation data for", source.name, target.animation_data) print("copying animation data from", source.name, "to", target.name)
if target.animation_data == None: """if target.animation_data == None:
target.animation_data_create() target.animation_data_create()
target.animation_data.action = source.animation_data.action.copy() target.animation_data.action = source.animation_data.action.copy()"""
# alternative method, using the build in link animation operator # alternative method, using the build in link animation operator
with bpy.context.temp_override(active_object=source, selected_editable_objects=[target]): with bpy.context.temp_override(active_object=source, selected_editable_objects=[target]):
bpy.ops.object.make_links_data(type='ANIMATION') bpy.ops.object.make_links_data(type='ANIMATION')

View File

@ -57,7 +57,7 @@ def test_export_complex(setup_data):
export_props = { export_props = {
"main_scene_names" : ['World'], "main_scene_names" : ['World'],
"library_scene_names": ['Library'], "library_scene_names": ['Library'],
#"export_format":'GLTF_SEPARATE' # "export_format":'GLTF_SEPARATE'
} }
stored_settings = bpy.data.texts[".gltf_auto_export_settings"] if ".gltf_auto_export_settings" in bpy.data.texts else bpy.data.texts.new(".gltf_auto_export_settings") stored_settings = bpy.data.texts[".gltf_auto_export_settings"] if ".gltf_auto_export_settings" in bpy.data.texts else bpy.data.texts.new(".gltf_auto_export_settings")
stored_settings.clear() stored_settings.clear()