Creation, loading, and management of animations

This commit is contained in:
Simone Barbieri 2020-02-10 14:55:04 +00:00
parent 951dcfca3e
commit 2b6e90ffe0
4 changed files with 404 additions and 0 deletions

View file

@ -0,0 +1,47 @@
import os
import avalon.blender.workio
import pype.api
class ExtractAnimation(pype.api.Extractor):
"""Extract as animation."""
label = "Animation"
hosts = ["blender"]
families = ["animation"]
optional = True
def process(self, instance):
# Define extract output file path
stagingdir = self.staging_dir(instance)
filename = f"{instance.name}.blend"
filepath = os.path.join(stagingdir, filename)
# Perform extraction
self.log.info("Performing extraction..")
# Just save the file to a temporary location. At least for now it's no
# problem to have (possibly) extra stuff in the file.
avalon.blender.workio.save_file(filepath, copy=True)
#
# # Store reference for integration
# if "files" not in instance.data:
# instance.data["files"] = list()
#
# # instance.data["files"].append(filename)
if "representations" not in instance.data:
instance.data["representations"] = []
representation = {
'name': 'blend',
'ext': 'blend',
'files': filename,
"stagingDir": stagingdir,
}
instance.data["representations"].append(representation)
self.log.info("Extracted instance '%s' to: %s", instance.name, representation)