OP-3277 - introduced Settings variable

Configured via Maya/Maya-dirmap to use in all Loaders
This commit is contained in:
Petr Kalis 2022-05-30 18:05:56 +02:00
parent 277024de81
commit 254455e786
3 changed files with 31 additions and 21 deletions

View file

@ -11,7 +11,7 @@ from openpype.pipeline import (
AVALON_CONTAINER_ID,
)
from openpype.api import Anatomy
from openpype.settings import get_project_settings
from .pipeline import containerise
from . import lib
@ -133,7 +133,6 @@ class ReferenceLoader(Loader):
" imported representation ?"
)
]
use_env_var_as_root = True
def load(
self,
@ -193,25 +192,6 @@ class ReferenceLoader(Loader):
"""To be implemented by subclass"""
raise NotImplementedError("Must be implemented by subclass")
def prepare_root_value(self, file_url, project_name):
"""Replace root value with env var placeholder.
Use ${OPENPYPE_ROOT_WORK} (or any other root) instead of proper root
value when storing referenced url into a workfile.
Useful for remote workflows with SiteSync.
Args:
file_url (str)
project_name (dict)
Returns:
(str)
"""
if self.use_env_var_as_root:
anatomy = Anatomy(project_name)
file_url = anatomy.replace_root_with_env_key(file_url, '${{{}}}')
return file_url
def update(self, container, representation):
from maya import cmds
from openpype.hosts.maya.api.lib import get_container_members
@ -344,6 +324,29 @@ class ReferenceLoader(Loader):
except RuntimeError:
pass
def prepare_root_value(self, file_url, project_name):
"""Replace root value with env var placeholder.
Use ${OPENPYPE_ROOT_WORK} (or any other root) instead of proper root
value when storing referenced url into a workfile.
Useful for remote workflows with SiteSync.
Args:
file_url (str)
project_name (dict)
Returns:
(str)
"""
settings = get_project_settings(project_name)
use_env_var_as_root = (settings["maya"]
["maya-dirmap"]
["use_env_var_as_root"])
if use_env_var_as_root:
anatomy = Anatomy(project_name)
file_url = anatomy.replace_root_with_env_key(file_url, '${{{}}}')
return file_url
@staticmethod
def _organize_containers(nodes, container):
# type: (list, str) -> None

View file

@ -8,6 +8,7 @@
"yetiRig": "ma"
},
"maya-dirmap": {
"use_env_var_as_root": true,
"enabled": false,
"paths": {
"source-path": [],

View file

@ -22,6 +22,12 @@
"label": "Maya Directory Mapping",
"is_group": true,
"children": [
{
"type": "boolean",
"key": "use_env_var_as_root",
"label": "Use env var placeholder in referenced url",
"docstring": "Use ${} placeholder instead of physical value of root when storing into workfile metadata."
},
{
"type": "boolean",
"key": "enabled",