Implement ExtractColorbleedAlembic

This commit is contained in:
Roy Nieterau 2017-06-28 18:24:18 +02:00
parent 80719c6488
commit 08e5ca43db

View file

@ -1,12 +1,12 @@
import os
import copy
from maya import cmds
import avalon.maya
import colorbleed.api
from colorbleed.maya.lib import extract_alembic
class ExtractAlembic(colorbleed.api.Extractor):
class ExtractColorbleedAlembic(colorbleed.api.Extractor):
"""Extract Alembic Cache
This extracts an Alembic cache using the `-selection` flag to minimize
@ -17,18 +17,35 @@ class ExtractAlembic(colorbleed.api.Extractor):
families = ["colorbleed.model",
"colorbleed.pointcache",
"colorbleed.proxy"]
optional = True
def process(self, instance):
parent_dir = self.staging_dir(instance)
filename = "%s.abc" % instance.name
path = os.path.join(parent_dir, filename)
options = dict()
options = copy.deepcopy(instance.data)
# Collect the start and end including handles if any provided
# otherwise assume frame 1 as startFrame and the same as endFrame
start = instance.data.get("startFrame", 1)
end = instance.data.get("endFrame", start)
handles = instance.data.get("handles", 0)
if handles:
start -= handles
end += handles
options['frameRange'] = (start, end)
options['selection'] = True
# Default verbosity to False
options['verbose'] = instance.data.get("verbose", False)
# Collect instance options if found in `instance.data`
# for specific settings (for user customization)
for key in ["renderableOnly", "writeColorSets"]:
if key in instance.data:
options[key] = instance.data[key]
with avalon.maya.suspended_refresh():
with avalon.maya.maintained_selection():
nodes = instance[:]
cmds.select(nodes, replace=True, noExpand=True)
extract_alembic(file=path, **options)