mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
added collectors for rendering
This commit is contained in:
parent
9e809b4aa3
commit
932ae63de3
2 changed files with 131 additions and 0 deletions
30
colorbleed/plugins/maya/publish/collect_maya_workspace.py
Normal file
30
colorbleed/plugins/maya/publish/collect_maya_workspace.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import os
|
||||
|
||||
import pyblish.api
|
||||
|
||||
from maya import cmds
|
||||
|
||||
|
||||
class CollectMayaWorkspace(pyblish.api.ContextPlugin):
|
||||
"""Inject the current workspace into context"""
|
||||
|
||||
order = pyblish.api.CollectorOrder - 0.5
|
||||
label = "Maya Workspace"
|
||||
|
||||
hosts = ['maya']
|
||||
version = (0, 1, 0)
|
||||
|
||||
def process(self, context):
|
||||
workspace = cmds.workspace(rootDirectory=True, query=True)
|
||||
if not workspace:
|
||||
# Project has not been set. Files will
|
||||
# instead end up next to the working file.
|
||||
workspace = cmds.workspace(dir=True, query=True)
|
||||
|
||||
# Maya returns forward-slashes by default
|
||||
normalised = os.path.normpath(workspace)
|
||||
|
||||
context.set_data('workspaceDir', value=normalised)
|
||||
|
||||
# For backwards compatibility
|
||||
context.set_data('workspace_dir', value=normalised)
|
||||
101
colorbleed/plugins/maya/publish/collect_renderlayers.py
Normal file
101
colorbleed/plugins/maya/publish/collect_renderlayers.py
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
import os
|
||||
from maya import cmds
|
||||
|
||||
import pyblish.api
|
||||
|
||||
from avalon import maya, api
|
||||
|
||||
class CollectMindbenderMayaRenderlayers(pyblish.api.ContextPlugin):
|
||||
"""Gather instances by active render layers"""
|
||||
|
||||
order = pyblish.api.CollectorOrder
|
||||
hosts = ["maya"]
|
||||
label = "Render Layers"
|
||||
|
||||
def process(self, context):
|
||||
|
||||
registered_root = api.registered_root()
|
||||
asset_name = os.environ["AVALON_ASSET"]
|
||||
|
||||
current_file = context.data["currentFile"]
|
||||
relative_file = current_file.replace(registered_root, "{root}")
|
||||
source_file = relative_file.replace("\\", "/")
|
||||
|
||||
renderlayers = cmds.ls(type="renderLayer")
|
||||
for layer in renderlayers:
|
||||
if layer.endswith("defaultRenderLayer"):
|
||||
continue
|
||||
|
||||
data = {"family": "Render Layers",
|
||||
"families": ["colorbleed.renderlayer"],
|
||||
"publish": cmds.getAttr("{}.renderable".format(layer)),
|
||||
|
||||
"startFrame": self.get_render_attribute("startFrame"),
|
||||
"endFrame": self.get_render_attribute("endFrame"),
|
||||
"byFrameStep": self.get_render_attribute("byFrameStep"),
|
||||
"renderer": self.get_render_attribute("currentRenderer"),
|
||||
|
||||
# instance subset
|
||||
"asset": asset_name,
|
||||
"subset": layer,
|
||||
"setMembers": layer,
|
||||
|
||||
# "time": context.data["time"],
|
||||
"author": context.data["user"],
|
||||
"source": source_file}
|
||||
|
||||
# Apply each user defined attribute as data
|
||||
for attr in cmds.listAttr(layer, userDefined=True) or list():
|
||||
try:
|
||||
value = cmds.getAttr("{}.{}".format(layer, attr))
|
||||
except Exception:
|
||||
# Some attributes cannot be read directly,
|
||||
# such as mesh and color attributes. These
|
||||
# are considered non-essential to this
|
||||
# particular publishing pipeline.
|
||||
value = None
|
||||
|
||||
data[attr] = value
|
||||
|
||||
# Include (optional) global settings
|
||||
# TODO(marcus): Take into account layer overrides
|
||||
try:
|
||||
avalon_globals = maya.lsattr("id", "avalon.renderglobals")[0]
|
||||
except IndexError:
|
||||
pass
|
||||
else:
|
||||
_globals = maya.read(avalon_globals)
|
||||
data["renderGlobals"] = self.get_global_overrides(_globals)
|
||||
|
||||
instance = context.create_instance(layer)
|
||||
instance.data.update(data)
|
||||
|
||||
def get_render_attribute(self, attr):
|
||||
return cmds.getAttr("defaultRenderGlobals.{}".format(attr))
|
||||
|
||||
def get_global_overrides(self, globals):
|
||||
"""
|
||||
Get all overrides with a value, skip those without
|
||||
|
||||
Here's the kicker. These globals override defaults in the submission
|
||||
integrator, but an empty value means no overriding is made.
|
||||
Otherwise, Frames would override the default frames set under globals.
|
||||
|
||||
Args:
|
||||
globals (dict) collection of render globals
|
||||
|
||||
Returns:
|
||||
dict: only overrides with values
|
||||
"""
|
||||
keys = ["pool", "group", "frames", "priority"]
|
||||
read_globals = {}
|
||||
for key in keys:
|
||||
value = globals[key]
|
||||
if not value:
|
||||
continue
|
||||
read_globals[key.capitalize()] = value
|
||||
|
||||
if not read_globals:
|
||||
self.log.info("Submitting without overrides")
|
||||
|
||||
return read_globals
|
||||
Loading…
Add table
Add a link
Reference in a new issue