From 9c02990ac13a25968d8ec15da15129617d3f25d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 21 Apr 2017 14:11:13 +0200 Subject: Alembic import: changing cache modifier path no longer discards object paths This allows, for example, the path of an Alembic file to be changed from absolute to relative, without having to reconstruct all object paths. --- tests/python/bl_alembic_import_test.py | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests/python') diff --git a/tests/python/bl_alembic_import_test.py b/tests/python/bl_alembic_import_test.py index cd23183ec06..33ccc49f301 100644 --- a/tests/python/bl_alembic_import_test.py +++ b/tests/python/bl_alembic_import_test.py @@ -85,6 +85,43 @@ class SimpleImportTest(unittest.TestCase): for ob in bpy.data.objects: self.assertEqual('Cube' in ob.name, ob.select) + def test_change_path(self): + import math + + fname = 'cube-rotating1.abc' + abc = self.testdir / fname + relpath = bpy.path.relpath(str(abc)) + + res = bpy.ops.wm.alembic_import(filepath=str(abc), as_background_job=False) + self.assertEqual({'FINISHED'}, res) + cube = bpy.context.active_object + + # Check that the file loaded ok. + bpy.context.scene.frame_set(10) + x, y, z = cube.matrix_world.to_euler('XYZ') + self.assertAlmostEqual(x, 0) + self.assertAlmostEqual(y, 0) + self.assertAlmostEqual(z, math.pi / 2, places=5) + + # Change path from absolute to relative. This should not break the animation. + bpy.context.scene.frame_set(1) + bpy.data.cache_files[fname].filepath = relpath + bpy.context.scene.frame_set(10) + + x, y, z = cube.matrix_world.to_euler('XYZ') + self.assertAlmostEqual(x, 0) + self.assertAlmostEqual(y, 0) + self.assertAlmostEqual(z, math.pi / 2, places=5) + + # Replace the Alembic file; this should apply new animation. + bpy.data.cache_files[fname].filepath = relpath.replace('1.abc', '2.abc') + bpy.context.scene.update() + + x, y, z = cube.matrix_world.to_euler('XYZ') + self.assertAlmostEqual(x, math.pi / 2, places=5) + self.assertAlmostEqual(y, 0) + self.assertAlmostEqual(z, 0) + def main(): global args -- cgit v1.2.3