mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 13:52:15 +01:00
feat(maya): added **RenderSetup** template support for avalon, utilizing rendersetup family
This commit is contained in:
parent
c24bedb961
commit
4e6ec22211
4 changed files with 144 additions and 0 deletions
|
|
@ -59,6 +59,7 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
|
|||
"review",
|
||||
"nukescript",
|
||||
"render",
|
||||
"rendersetup",
|
||||
"write",
|
||||
"rig",
|
||||
"plate"
|
||||
|
|
|
|||
53
pype/plugins/maya/create/create_rendersetup.py
Normal file
53
pype/plugins/maya/create/create_rendersetup.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import avalon.maya
|
||||
import pype.maya.lib as lib
|
||||
from maya import cmds
|
||||
|
||||
|
||||
class CreateRenderSetup(avalon.maya.Creator):
|
||||
"""Create rendersetup template json data"""
|
||||
|
||||
name = "rendersetup"
|
||||
label = "Render Setup Preset"
|
||||
family = "rendersetup"
|
||||
icon = "tablet"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(CreateRenderSetup, self).__init__(*args, **kwargs)
|
||||
|
||||
# here we can pre-create renderSetup layers, possibly utlizing
|
||||
# presets for it.
|
||||
|
||||
# _____
|
||||
# / __\__
|
||||
# | / __\__
|
||||
# | | / \
|
||||
# | | | |
|
||||
# \__| | |
|
||||
# \__| |
|
||||
# \_____/
|
||||
|
||||
# from pypeapp import config
|
||||
# import maya.app.renderSetup.model.renderSetup as renderSetup
|
||||
# presets = config.get_presets(project=os.environ['AVALON_PROJECT'])
|
||||
# layer = presets['plugins']['maya']['create']['renderSetup']["layer"]
|
||||
|
||||
# rs = renderSetup.instance()
|
||||
# rs.createRenderLayer(layer)
|
||||
|
||||
self.options = {"useSelection": False} # Force no content
|
||||
|
||||
def process(self):
|
||||
exists = cmds.ls(self.name)
|
||||
assert len(exists) <= 1, (
|
||||
"More than one renderglobal exists, this is a bug"
|
||||
)
|
||||
|
||||
if exists:
|
||||
return cmds.warning("%s already exists." % exists[0])
|
||||
|
||||
with lib.undo_chunk():
|
||||
instance = super(CreateRenderSetup, self).process()
|
||||
|
||||
self.data["renderSetup"] = "42"
|
||||
null = cmds.sets(name="null_SET", empty=True)
|
||||
cmds.sets([null], forceElement=instance)
|
||||
50
pype/plugins/maya/load/load_rendersetup.py
Normal file
50
pype/plugins/maya/load/load_rendersetup.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
from avalon import api
|
||||
import maya.app.renderSetup.model.renderSetup as renderSetup
|
||||
from avalon.maya import lib
|
||||
from maya import cmds
|
||||
import json
|
||||
|
||||
|
||||
class RenderSetupLoader(api.Loader):
|
||||
"""
|
||||
This will load json preset for RenderSetup, overwriting current one.
|
||||
"""
|
||||
|
||||
families = ["rendersetup"]
|
||||
representations = ["json"]
|
||||
defaults = ['Main']
|
||||
|
||||
label = "Load RenderSetup template"
|
||||
icon = "tablet"
|
||||
color = "orange"
|
||||
|
||||
def load(self, context, name, namespace, data):
|
||||
|
||||
from avalon.maya.pipeline import containerise
|
||||
# from pype.maya.lib import namespaced
|
||||
|
||||
asset = context['asset']['name']
|
||||
namespace = namespace or lib.unique_namespace(
|
||||
asset + "_",
|
||||
prefix="_" if asset[0].isdigit() else "",
|
||||
suffix="_",
|
||||
)
|
||||
|
||||
with open(self.fname, "r") as file:
|
||||
renderSetup.instance().decode(
|
||||
json.load(file), renderSetup.DECODE_AND_OVERWRITE, None)
|
||||
|
||||
nodes = []
|
||||
null = cmds.sets(name="null_SET", empty=True)
|
||||
nodes.append(null)
|
||||
|
||||
self[:] = nodes
|
||||
if not nodes:
|
||||
return
|
||||
|
||||
return containerise(
|
||||
name=name,
|
||||
namespace=namespace,
|
||||
nodes=nodes,
|
||||
context=context,
|
||||
loader=self.__class__.__name__)
|
||||
40
pype/plugins/maya/publish/extract_rendersetup.py
Normal file
40
pype/plugins/maya/publish/extract_rendersetup.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
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))
|
||||
Loading…
Add table
Add a link
Reference in a new issue