ayon-core/pype/plugins/maya/publish/extract_rendersetup.py
Milan Kolar cab44138cb simplyfy model maya reference loader and add proxy classes for backwards compatibility
remove dots from extensions to prevents double dots in names
2019-07-17 15:26:16 +02:00

40 lines
1.1 KiB
Python

import json
import os
import pype.api
import maya.app.renderSetup.model.renderSetup as renderSetup
class ExtractRenderSetup(pype.api.Extractor):
"""
Produce renderSetup template file
This will save whole renderSetup to json file for later use.
"""
label = "Extract RenderSetup"
hosts = ["maya"]
families = ["rendersetup"]
def process(self, instance):
parent_dir = self.staging_dir(instance)
json_filename = "{}.json".format(instance.name)
json_path = os.path.join(parent_dir, json_filename)
with open(json_path, "w+") as file:
json.dump(
renderSetup.instance().encode(None),
fp=file, indent=2, sort_keys=True)
if "representations" not in instance.data:
instance.data["representations"] = []
representation = {
'name': 'json',
'ext': 'json',
'files': json_filename,
"stagingDir": parent_dir,
}
instance.data["representations"].append(representation)
self.log.info(
"Extracted instance '%s' to: %s" % (instance.name, json_path))