mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 21:32:15 +01:00
Initial working version
This commit is contained in:
parent
fec94a508e
commit
bbd9f001e4
14 changed files with 1422 additions and 18 deletions
|
|
@ -142,9 +142,20 @@ class RenderSettings(object):
|
|||
current_aovs = AOVInterface().getAOVs()
|
||||
remove_aovs = render_settings["remove_aovs"]
|
||||
if remove_aovs:
|
||||
# Remove fetched AOVs
|
||||
# Remove fetched AOVs
|
||||
AOVInterface().removeAOVs(current_aovs)
|
||||
|
||||
# Need to reset the cameras renderable state after
|
||||
# "unifiedRenderGlobalsRevertToDefault".
|
||||
renderable_by_camera = {}
|
||||
for camera in cmds.ls(type="camera"):
|
||||
renderable_by_camera[camera] = cmds.getAttr(camera + ".renderable")
|
||||
|
||||
mel.eval("unifiedRenderGlobalsRevertToDefault")
|
||||
|
||||
for camera, value in renderable_by_camera.items():
|
||||
cmds.setAttr(camera + ".renderable", value)
|
||||
|
||||
img_ext = arnold_render_presets["image_format"]
|
||||
img_prefix = arnold_render_presets["image_prefix"]
|
||||
aovs = arnold_render_presets["aov_list"]
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ from .workfile_template_builder import (
|
|||
)
|
||||
from ayon_core.tools.workfile_template_build import open_template_ui
|
||||
from .workfile_template_builder import MayaTemplateBuilder
|
||||
from .testing import run_tests, test_create, test_publish, test_load
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -202,6 +203,33 @@ def install(project_settings):
|
|||
command=update_placeholder
|
||||
)
|
||||
|
||||
testing_menu = cmds.menuItem(
|
||||
"Testing",
|
||||
subMenu=True,
|
||||
tearOff=True,
|
||||
parent=MENU_NAME
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Run Tests",
|
||||
parent=testing_menu,
|
||||
command=lambda *args: run_tests()
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Test Create",
|
||||
parent=testing_menu,
|
||||
command=lambda *args: test_create()
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Test Publish",
|
||||
parent=testing_menu,
|
||||
command=lambda *args: test_publish()
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Test Load",
|
||||
parent=testing_menu,
|
||||
command=lambda *args: test_load()
|
||||
)
|
||||
|
||||
cmds.setParent(MENU_NAME, menu=True)
|
||||
|
||||
def add_scripts_menu(project_settings):
|
||||
|
|
|
|||
|
|
@ -420,7 +420,7 @@ class RenderlayerCreator(NewCreator, MayaCreatorBase):
|
|||
# By RenderLayerCreator.create we make it so that the renderlayer
|
||||
# instances directly appear even though it just collects scene
|
||||
# renderlayers. This doesn't actually 'create' any scene contents.
|
||||
self.collect_instances()
|
||||
return self.collect_instances()
|
||||
|
||||
def create_singleton_node(self):
|
||||
if self._get_singleton_node():
|
||||
|
|
@ -444,6 +444,7 @@ class RenderlayerCreator(NewCreator, MayaCreatorBase):
|
|||
host_name = self.create_context.host_name
|
||||
rs = renderSetup.instance()
|
||||
layers = rs.getRenderLayers()
|
||||
instances = []
|
||||
for layer in layers:
|
||||
layer_instance_node = self.find_layer_instance_node(layer)
|
||||
if layer_instance_node:
|
||||
|
|
@ -484,6 +485,9 @@ class RenderlayerCreator(NewCreator, MayaCreatorBase):
|
|||
|
||||
instance.transient_data["layer"] = layer
|
||||
self._add_instance_to_context(instance)
|
||||
instances.append(instance)
|
||||
|
||||
return instances
|
||||
|
||||
def find_layer_instance_node(self, layer):
|
||||
connected_sets = cmds.listConnections(
|
||||
|
|
|
|||
14
client/ayon_core/hosts/maya/api/testing/__init__.py
Normal file
14
client/ayon_core/hosts/maya/api/testing/__init__.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from .lib import run_tests
|
||||
|
||||
from .tests import (
|
||||
test_create,
|
||||
test_publish,
|
||||
test_load,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"run_tests",
|
||||
"test_create",
|
||||
"test_publish",
|
||||
"test_load",
|
||||
]
|
||||
8
client/ayon_core/hosts/maya/api/testing/lib.py
Normal file
8
client/ayon_core/hosts/maya/api/testing/lib.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
from .tests import test_create, test_publish, test_load
|
||||
|
||||
|
||||
def run_tests():
|
||||
test_create()
|
||||
test_publish()
|
||||
test_load()
|
||||
print("Testing was successfull!")
|
||||
1129
client/ayon_core/hosts/maya/api/testing/tests.ma
Normal file
1129
client/ayon_core/hosts/maya/api/testing/tests.ma
Normal file
File diff suppressed because it is too large
Load diff
174
client/ayon_core/hosts/maya/api/testing/tests.py
Normal file
174
client/ayon_core/hosts/maya/api/testing/tests.py
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
import traceback
|
||||
import os
|
||||
|
||||
import maya.cmds as cmds
|
||||
|
||||
import pyblish.util
|
||||
|
||||
from ayon_core.pipeline import registered_host
|
||||
from ayon_core.pipeline.create import CreateContext
|
||||
from ayon_core.hosts.maya.api.workfile_template_builder import (
|
||||
MayaTemplateBuilder
|
||||
)
|
||||
|
||||
|
||||
# Needed for transition phase for asset/subset renaming. Can be hardcoded once
|
||||
# transition is done.
|
||||
product_key_name = "productName"
|
||||
product_type_key_name = "productType"
|
||||
|
||||
|
||||
def test_create():
|
||||
"""Test re-creating instances in workfile.
|
||||
TODO:
|
||||
- Arnold Scene Source
|
||||
- Assembly
|
||||
- Camera Rig
|
||||
- Layout
|
||||
- Matchmove
|
||||
- Maya USD
|
||||
- Multi-shot Layout
|
||||
- Multiverse Look
|
||||
- Multiverse USD Asset
|
||||
- Multiverse USD Composition
|
||||
- Multiverse USD Override
|
||||
- Pointcache
|
||||
- Proxy Alembic
|
||||
- Redshift Proxy
|
||||
- Set Dress
|
||||
- Unreal - Skeletal Mesh
|
||||
- Unreal - Static Mesh
|
||||
- Unreal - Yeti Cache
|
||||
- Vray Proxy
|
||||
- Vray Scene
|
||||
- Xgen
|
||||
- Yeti Cache
|
||||
- Yeti Rig
|
||||
"""
|
||||
|
||||
host = registered_host()
|
||||
context = CreateContext(host)
|
||||
create_data = []
|
||||
instances_to_remove = []
|
||||
for instance in context.instances:
|
||||
# Ignoring "workfile" instance cause we cant recreate that while inside
|
||||
# it.
|
||||
if instance.data[product_type_key_name] == "workfile":
|
||||
continue
|
||||
|
||||
creator_plugin = context.creators[instance.data["creator_identifier"]]
|
||||
|
||||
instance_data_keys = [
|
||||
"folderPath",
|
||||
"task",
|
||||
"variant",
|
||||
product_type_key_name
|
||||
]
|
||||
instance_data = {x: instance.data[x] for x in instance_data_keys}
|
||||
|
||||
hierarchy = {}
|
||||
if "instance_node" in instance.data:
|
||||
members = cmds.sets(instance.data["instance_node"], query=True)
|
||||
hierarchy[instance.data["instance_node"]] = cmds.ls(
|
||||
members, type="dagNode"
|
||||
)
|
||||
for set in cmds.ls(members, type="objectSet"):
|
||||
hierarchy[set] = cmds.sets(set, query=True)
|
||||
|
||||
create_data.append(
|
||||
{
|
||||
"plugin": creator_plugin,
|
||||
"hierarchy": hierarchy,
|
||||
"args": [
|
||||
instance.data[product_key_name],
|
||||
instance_data,
|
||||
{"use_selection": False}
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
instances_to_remove.append(instance)
|
||||
|
||||
context.remove_instances(instances_to_remove)
|
||||
|
||||
for data in create_data:
|
||||
data["plugin"].create(*data["args"])
|
||||
for set, nodes in data["hierarchy"].items():
|
||||
if not nodes:
|
||||
continue
|
||||
|
||||
cmds.sets(nodes, forceElement=set)
|
||||
|
||||
print("Create was successfull!")
|
||||
|
||||
|
||||
def test_publish():
|
||||
"""Test publishing."""
|
||||
|
||||
context = pyblish.util.publish()
|
||||
success = True
|
||||
error_message = ""
|
||||
for result in context.data["results"]:
|
||||
if result["success"]:
|
||||
continue
|
||||
|
||||
success = False
|
||||
|
||||
err = result["error"]
|
||||
formatted_traceback = "".join(
|
||||
traceback.format_exception(
|
||||
type(err),
|
||||
err,
|
||||
err.__traceback__
|
||||
)
|
||||
)
|
||||
fname = result["plugin"].__module__
|
||||
if 'File "<string>", line' in formatted_traceback:
|
||||
_, lineno, func, msg = err.traceback
|
||||
fname = os.path.abspath(fname)
|
||||
formatted_traceback = formatted_traceback.replace(
|
||||
'File "<string>", line',
|
||||
'File "{0}", line'.format(fname)
|
||||
)
|
||||
|
||||
err = result["error"]
|
||||
error_message += "\n"
|
||||
error_message += formatted_traceback
|
||||
|
||||
assert success, error_message
|
||||
print("Publish was successfull!")
|
||||
|
||||
|
||||
def test_load():
|
||||
"""Test loading with placeholders.
|
||||
TODO:
|
||||
- hero versions are not loaded
|
||||
- Look
|
||||
- Review
|
||||
- Arnold Scene Source
|
||||
- Assembly
|
||||
- Camera Rig
|
||||
- Layout
|
||||
- Matchmove
|
||||
- Maya USD
|
||||
- Multi-shot Layout
|
||||
- Multiverse Look
|
||||
- Multiverse USD Asset
|
||||
- Multiverse USD Composition
|
||||
- Multiverse USD Override
|
||||
- Pointcache
|
||||
- Proxy Alembic
|
||||
- Redshift Proxy
|
||||
- Set Dress
|
||||
- Unreal - Skeletal Mesh
|
||||
- Unreal - Static Mesh
|
||||
- Unreal - Yeti Cache
|
||||
- Vray Proxy
|
||||
- Vray Scene
|
||||
- Xgen
|
||||
- Yeti Cache
|
||||
- Yeti Rig
|
||||
"""
|
||||
builder = MayaTemplateBuilder(registered_host())
|
||||
builder.populate_scene_placeholders(keep_placeholders=True)
|
||||
print("Load was successfull!")
|
||||
|
|
@ -154,7 +154,7 @@ class MayaPlaceholderLoadPlugin(PlaceholderPlugin, PlaceholderLoadMixin):
|
|||
loader_args = json.loads(loader_args.replace('\'', '\"'))
|
||||
values = [v for v in loader_args.values()]
|
||||
for value in values:
|
||||
placeholder_name_parts.insert(pos, value)
|
||||
placeholder_name_parts.insert(pos, str(value))
|
||||
pos += 1
|
||||
|
||||
placeholder_name = "_".join(placeholder_name_parts)
|
||||
|
|
@ -263,6 +263,11 @@ class MayaPlaceholderLoadPlugin(PlaceholderPlugin, PlaceholderLoadMixin):
|
|||
# Hide placeholder and add them to placeholder set
|
||||
node = placeholder.scene_identifier
|
||||
|
||||
# If we just populate the placeholders from current scene, the
|
||||
# placeholder set will not be created so account for that.
|
||||
if not cmds.objExists(PLACEHOLDER_SET):
|
||||
cmds.sets(name=PLACEHOLDER_SET, empty=True)
|
||||
|
||||
cmds.sets(node, addElement=PLACEHOLDER_SET)
|
||||
cmds.hide(node)
|
||||
cmds.setAttr(node + ".hiddenInOutliner", True)
|
||||
|
|
@ -330,7 +335,8 @@ class MayaPlaceholderLoadPlugin(PlaceholderPlugin, PlaceholderLoadMixin):
|
|||
cmds.xform(node, matrix=placeholder_form, ws=True)
|
||||
if scene_parent:
|
||||
cmds.parent(node, scene_parent)
|
||||
else:
|
||||
# When parented to world, the parent returns None.
|
||||
elif cmds.listRelatives(node, parent=True) is not None:
|
||||
cmds.parent(node, world=True)
|
||||
|
||||
holding_sets = cmds.listSets(object=placeholder.scene_identifier)
|
||||
|
|
|
|||
|
|
@ -100,3 +100,5 @@ class CreateArnoldSceneSource(plugin.MayaCreator):
|
|||
content = cmds.sets(name=instance_node + "_content_SET", empty=True)
|
||||
proxy = cmds.sets(name=instance_node + "_proxy_SET", empty=True)
|
||||
cmds.sets([content, proxy], forceElement=instance_node)
|
||||
|
||||
return instance
|
||||
|
|
|
|||
|
|
@ -86,3 +86,8 @@ class CreatePointCache(plugin.MayaCreator):
|
|||
# For Arnold standin proxy
|
||||
proxy_set = cmds.sets(name=instance_node + "_proxy_SET", empty=True)
|
||||
cmds.sets(proxy_set, forceElement=instance_node)
|
||||
|
||||
for node, id in lib.generate_ids([proxy_set]):
|
||||
lib.set_id(node, id, overwrite=True)
|
||||
|
||||
return instance
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from maya import cmds
|
||||
|
||||
from ayon_core.hosts.maya.api import plugin
|
||||
from ayon_core.hosts.maya.api import plugin, lib
|
||||
|
||||
|
||||
class CreateRig(plugin.MayaCreator):
|
||||
|
|
@ -10,6 +10,12 @@ class CreateRig(plugin.MayaCreator):
|
|||
label = "Rig"
|
||||
product_type = "rig"
|
||||
icon = "wheelchair"
|
||||
set_suffixes = [
|
||||
"_controls_SET",
|
||||
"_out_SET",
|
||||
"_skeletonAnim_SET",
|
||||
"_skeletonMesh_SET"
|
||||
]
|
||||
|
||||
def create(self, product_name, instance_data, pre_create_data):
|
||||
|
||||
|
|
@ -20,13 +26,28 @@ class CreateRig(plugin.MayaCreator):
|
|||
instance_node = instance.get("instance_node")
|
||||
|
||||
self.log.info("Creating Rig instance set up ...")
|
||||
# TODO:change name (_controls_SET -> _rigs_SET)
|
||||
controls = cmds.sets(name=product_name + "_controls_SET", empty=True)
|
||||
# TODO:change name (_out_SET -> _geo_SET)
|
||||
pointcache = cmds.sets(name=product_name + "_out_SET", empty=True)
|
||||
skeleton = cmds.sets(
|
||||
name=product_name + "_skeletonAnim_SET", empty=True)
|
||||
skeleton_mesh = cmds.sets(
|
||||
name=product_name + "_skeletonMesh_SET", empty=True)
|
||||
cmds.sets([controls, pointcache,
|
||||
skeleton, skeleton_mesh], forceElement=instance_node)
|
||||
sets = []
|
||||
for suffix in self.set_suffixes:
|
||||
name = product_name + suffix
|
||||
cmds.sets(name=name, empty=True)
|
||||
sets.append(name)
|
||||
cmds.sets(sets, forceElement=instance_node)
|
||||
|
||||
for node, id in lib.generate_ids(sets):
|
||||
lib.set_id(node, id, overwrite=True)
|
||||
|
||||
return instance
|
||||
|
||||
def remove_instances(self, instances):
|
||||
for instance in instances:
|
||||
nodes = [instance.data.get("instance_node")]
|
||||
for suffix in self.set_suffixes:
|
||||
nodes.append(instance.data.get("instance_node") + suffix)
|
||||
|
||||
for node in nodes:
|
||||
if not cmds.objExists(node):
|
||||
continue
|
||||
|
||||
cmds.delete(node)
|
||||
|
||||
self._remove_instance_from_context(instance)
|
||||
|
|
|
|||
|
|
@ -290,7 +290,9 @@ class CollectMayaRender(pyblish.api.InstancePlugin):
|
|||
"colorspaceView": colorspace_data["view"],
|
||||
}
|
||||
|
||||
rr_settings = context.data["project_settings"]["royalrender"]
|
||||
rr_settings = context.data["project_settings"].get(
|
||||
"royalrender", {"enabled": False}
|
||||
)
|
||||
if rr_settings["enabled"]:
|
||||
data["rrPathName"] = instance.data.get("rrPathName")
|
||||
self.log.debug(data["rrPathName"])
|
||||
|
|
|
|||
|
|
@ -1468,7 +1468,7 @@ class PlaceholderLoadMixin(object):
|
|||
product_name_regex = None
|
||||
if product_name_regex_value:
|
||||
product_name_regex = re.compile(product_name_regex_value)
|
||||
product_type = placeholder.data["family"]
|
||||
product_type = placeholder.data["product_type"]
|
||||
|
||||
builder_type = placeholder.data["builder_type"]
|
||||
folder_ids = []
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ DEFAULT_RENDER_SETTINGS = {
|
|||
"reset_current_frame": False,
|
||||
"remove_aovs": False,
|
||||
"arnold_renderer": {
|
||||
"image_prefix": "<Scene>/<RenderLayer>/<RenderLayer>_<RenderPass>",
|
||||
"image_prefix": "<Scene>/<RenderLayer>/<RenderLayer>",
|
||||
"image_format": "exr",
|
||||
"multilayer_exr": True,
|
||||
"tiled": True,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue