mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Loader: Remove context argument from Loader.__init__() (#4602)
* Remove Loader `context` argument to __init__ * Add backwards compatibility for Loader.load by still setting `.fname` attr * Refactor/remove usage of `self.fname` in loaders * Fix some refactoring * Fix some refactoring * Hound * Revert invalid refactor * Fix refactor * Fix playblast panel collection * Refactor missing method * Fix typo * Use the correct `context` --------- Co-authored-by: Toke Stuart Jepsen <tokejepsen@gmail.com> Co-authored-by: Kayla Man <64118225+moonyuet@users.noreply.github.com> Co-authored-by: Jakub Trllo <jakub.trllo@gmail.com>
This commit is contained in:
parent
2fdb0ece6b
commit
f58994d59c
99 changed files with 237 additions and 175 deletions
|
|
@ -33,9 +33,10 @@ class BackgroundLoader(api.AfterEffectsLoader):
|
|||
existing_items,
|
||||
"{}_{}".format(context["asset"]["name"], name))
|
||||
|
||||
layers = get_background_layers(self.fname)
|
||||
path = self.filepath_from_context(context)
|
||||
layers = get_background_layers(path)
|
||||
if not layers:
|
||||
raise ValueError("No layers found in {}".format(self.fname))
|
||||
raise ValueError("No layers found in {}".format(path))
|
||||
|
||||
comp = stub.import_background(None, stub.LOADED_ICON + comp_name,
|
||||
layers)
|
||||
|
|
|
|||
|
|
@ -29,32 +29,32 @@ class FileLoader(api.AfterEffectsLoader):
|
|||
|
||||
import_options = {}
|
||||
|
||||
file = self.fname
|
||||
path = self.filepath_from_context(context)
|
||||
|
||||
repr_cont = context["representation"]["context"]
|
||||
if "#" not in file:
|
||||
if "#" not in path:
|
||||
frame = repr_cont.get("frame")
|
||||
if frame:
|
||||
padding = len(frame)
|
||||
file = file.replace(frame, "#" * padding)
|
||||
path = path.replace(frame, "#" * padding)
|
||||
import_options['sequence'] = True
|
||||
|
||||
if not file:
|
||||
if not path:
|
||||
repr_id = context["representation"]["_id"]
|
||||
self.log.warning(
|
||||
"Representation id `{}` is failing to load".format(repr_id))
|
||||
return
|
||||
|
||||
file = file.replace("\\", "/")
|
||||
if '.psd' in file:
|
||||
path = path.replace("\\", "/")
|
||||
if '.psd' in path:
|
||||
import_options['ImportAsType'] = 'ImportAsType.COMP'
|
||||
|
||||
comp = stub.import_file(self.fname, stub.LOADED_ICON + comp_name,
|
||||
comp = stub.import_file(path, stub.LOADED_ICON + comp_name,
|
||||
import_options)
|
||||
|
||||
if not comp:
|
||||
self.log.warning(
|
||||
"Representation id `{}` is failing to load".format(file))
|
||||
"Representation `{}` is failing to load".format(path))
|
||||
self.log.warning("Check host app for alert error.")
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -243,7 +243,8 @@ class AssetLoader(LoaderPlugin):
|
|||
"""
|
||||
# TODO (jasper): make it possible to add the asset several times by
|
||||
# just re-using the collection
|
||||
assert Path(self.fname).exists(), f"{self.fname} doesn't exist."
|
||||
filepath = self.filepath_from_context(context)
|
||||
assert Path(filepath).exists(), f"{filepath} doesn't exist."
|
||||
|
||||
asset = context["asset"]["name"]
|
||||
subset = context["subset"]["name"]
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@ class AppendBlendLoader(plugin.AssetLoader):
|
|||
color = "#775555"
|
||||
|
||||
def load(self, context, name=None, namespace=None, data=None):
|
||||
append_workfile(context, self.fname, False)
|
||||
path = self.filepath_from_context(context)
|
||||
append_workfile(context, path, False)
|
||||
|
||||
# We do not containerize imported content, it remains unmanaged
|
||||
return
|
||||
|
|
@ -76,7 +77,8 @@ class ImportBlendLoader(plugin.AssetLoader):
|
|||
color = "#775555"
|
||||
|
||||
def load(self, context, name=None, namespace=None, data=None):
|
||||
append_workfile(context, self.fname, True)
|
||||
path = self.filepath_from_context(context)
|
||||
append_workfile(context, path, True)
|
||||
|
||||
# We do not containerize imported content, it remains unmanaged
|
||||
return
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ class CacheModelLoader(plugin.AssetLoader):
|
|||
options: Additional settings dictionary
|
||||
"""
|
||||
|
||||
libpath = self.fname
|
||||
libpath = self.filepath_from_context(context)
|
||||
asset = context["asset"]["name"]
|
||||
subset = context["subset"]["name"]
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class BlendActionLoader(openpype.hosts.blender.api.plugin.AssetLoader):
|
|||
options: Additional settings dictionary
|
||||
"""
|
||||
|
||||
libpath = self.fname
|
||||
libpath = self.filepath_from_context(context)
|
||||
asset = context["asset"]["name"]
|
||||
subset = context["subset"]["name"]
|
||||
lib_container = openpype.hosts.blender.api.plugin.asset_name(asset, subset)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class BlendAnimationLoader(plugin.AssetLoader):
|
|||
context: Full parenthood of representation to load
|
||||
options: Additional settings dictionary
|
||||
"""
|
||||
libpath = self.fname
|
||||
libpath = self.filepath_from_context(context)
|
||||
|
||||
with bpy.data.libraries.load(
|
||||
libpath, link=True, relative=False
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class AudioLoader(plugin.AssetLoader):
|
|||
context: Full parenthood of representation to load
|
||||
options: Additional settings dictionary
|
||||
"""
|
||||
libpath = self.fname
|
||||
libpath = self.filepath_from_context(context)
|
||||
asset = context["asset"]["name"]
|
||||
subset = context["subset"]["name"]
|
||||
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ class BlendCameraLoader(plugin.AssetLoader):
|
|||
context: Full parenthood of representation to load
|
||||
options: Additional settings dictionary
|
||||
"""
|
||||
libpath = self.fname
|
||||
libpath = self.filepath_from_context(context)
|
||||
asset = context["asset"]["name"]
|
||||
subset = context["subset"]["name"]
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class FbxCameraLoader(plugin.AssetLoader):
|
|||
context: Full parenthood of representation to load
|
||||
options: Additional settings dictionary
|
||||
"""
|
||||
libpath = self.fname
|
||||
libpath = self.filepath_from_context(context)
|
||||
asset = context["asset"]["name"]
|
||||
subset = context["subset"]["name"]
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ class FbxModelLoader(plugin.AssetLoader):
|
|||
context: Full parenthood of representation to load
|
||||
options: Additional settings dictionary
|
||||
"""
|
||||
libpath = self.fname
|
||||
libpath = self.filepath_from_context(context)
|
||||
asset = context["asset"]["name"]
|
||||
subset = context["subset"]["name"]
|
||||
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ class BlendLayoutLoader(plugin.AssetLoader):
|
|||
context: Full parenthood of representation to load
|
||||
options: Additional settings dictionary
|
||||
"""
|
||||
libpath = self.fname
|
||||
libpath = self.filepath_from_context(context)
|
||||
asset = context["asset"]["name"]
|
||||
subset = context["subset"]["name"]
|
||||
representation = str(context["representation"]["_id"])
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ class JsonLayoutLoader(plugin.AssetLoader):
|
|||
context: Full parenthood of representation to load
|
||||
options: Additional settings dictionary
|
||||
"""
|
||||
libpath = self.fname
|
||||
libpath = self.filepath_from_context(context)
|
||||
asset = context["asset"]["name"]
|
||||
subset = context["subset"]["name"]
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class BlendLookLoader(plugin.AssetLoader):
|
|||
options: Additional settings dictionary
|
||||
"""
|
||||
|
||||
libpath = self.fname
|
||||
libpath = self.filepath_from_context(context)
|
||||
asset = context["asset"]["name"]
|
||||
subset = context["subset"]["name"]
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class BlendModelLoader(plugin.AssetLoader):
|
|||
context: Full parenthood of representation to load
|
||||
options: Additional settings dictionary
|
||||
"""
|
||||
libpath = self.fname
|
||||
libpath = self.filepath_from_context(context)
|
||||
asset = context["asset"]["name"]
|
||||
subset = context["subset"]["name"]
|
||||
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ class BlendRigLoader(plugin.AssetLoader):
|
|||
context: Full parenthood of representation to load
|
||||
options: Additional settings dictionary
|
||||
"""
|
||||
libpath = self.fname
|
||||
libpath = self.filepath_from_context(context)
|
||||
asset = context["asset"]["name"]
|
||||
subset = context["subset"]["name"]
|
||||
|
||||
|
|
|
|||
|
|
@ -82,8 +82,9 @@ class LoadClip(opfapi.ClipLoader):
|
|||
os.makedirs(openclip_dir)
|
||||
|
||||
# prepare clip data from context ad send it to openClipLoader
|
||||
path = self.filepath_from_context(context)
|
||||
loading_context = {
|
||||
"path": self.fname.replace("\\", "/"),
|
||||
"path": path.replace("\\", "/"),
|
||||
"colorspace": colorspace,
|
||||
"version": "v{:0>3}".format(version_name),
|
||||
"layer_rename_template": self.layer_rename_template,
|
||||
|
|
|
|||
|
|
@ -81,9 +81,10 @@ class LoadClipBatch(opfapi.ClipLoader):
|
|||
if not os.path.exists(openclip_dir):
|
||||
os.makedirs(openclip_dir)
|
||||
|
||||
# prepare clip data from context ad send it to openClipLoader
|
||||
# prepare clip data from context and send it to openClipLoader
|
||||
path = self.filepath_from_context(context)
|
||||
loading_context = {
|
||||
"path": self.fname.replace("\\", "/"),
|
||||
"path": path.replace("\\", "/"),
|
||||
"colorspace": colorspace,
|
||||
"version": "v{:0>3}".format(version_name),
|
||||
"layer_rename_template": self.layer_rename_template,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class FusionLoadAlembicMesh(load.LoaderPlugin):
|
|||
comp = get_current_comp()
|
||||
with comp_lock_and_undo_chunk(comp, "Create tool"):
|
||||
|
||||
path = self.fname
|
||||
path = self.filepath_from_context(context)
|
||||
|
||||
args = (-32768, -32768)
|
||||
tool = comp.AddTool(self.tool_type, *args)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class FusionLoadFBXMesh(load.LoaderPlugin):
|
|||
# Create the Loader with the filename path set
|
||||
comp = get_current_comp()
|
||||
with comp_lock_and_undo_chunk(comp, "Create tool"):
|
||||
path = self.fname
|
||||
path = self.filepath_from_context(context)
|
||||
|
||||
args = (-32768, -32768)
|
||||
tool = comp.AddTool(self.tool_type, *args)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
import contextlib
|
||||
|
||||
import openpype.pipeline.load as load
|
||||
from openpype.pipeline.load import (
|
||||
get_representation_context,
|
||||
get_representation_path_from_context,
|
||||
)
|
||||
from openpype.pipeline.load import get_representation_context
|
||||
from openpype.hosts.fusion.api import (
|
||||
imprint_container,
|
||||
get_current_comp,
|
||||
|
|
@ -157,7 +154,7 @@ class FusionLoadSequence(load.LoaderPlugin):
|
|||
namespace = context["asset"]["name"]
|
||||
|
||||
# Use the first file for now
|
||||
path = get_representation_path_from_context(context)
|
||||
path = self.filepath_from_context(context)
|
||||
|
||||
# Create the Loader with the filename path set
|
||||
comp = get_current_comp()
|
||||
|
|
@ -228,7 +225,7 @@ class FusionLoadSequence(load.LoaderPlugin):
|
|||
comp = tool.Comp()
|
||||
|
||||
context = get_representation_context(representation)
|
||||
path = get_representation_path_from_context(context)
|
||||
path = self.filepath_from_context(context)
|
||||
|
||||
# Get start frame from version data
|
||||
start = self._get_start(context["version"], tool)
|
||||
|
|
|
|||
|
|
@ -238,7 +238,8 @@ class BackgroundLoader(load.LoaderPlugin):
|
|||
|
||||
def load(self, context, name=None, namespace=None, data=None):
|
||||
|
||||
with open(self.fname) as json_file:
|
||||
path = self.filepath_from_context(context)
|
||||
with open(path) as json_file:
|
||||
data = json.load(json_file)
|
||||
|
||||
layers = list()
|
||||
|
|
@ -251,7 +252,7 @@ class BackgroundLoader(load.LoaderPlugin):
|
|||
if layer.get("filename"):
|
||||
layers.append(layer["filename"])
|
||||
|
||||
bg_folder = os.path.dirname(self.fname)
|
||||
bg_folder = os.path.dirname(path)
|
||||
|
||||
subset_name = context["subset"]["name"]
|
||||
# read_node_name += "_{}".format(uuid.uuid4())
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class ImageSequenceLoader(load.LoaderPlugin):
|
|||
data (dict, optional): Additional data passed into loader.
|
||||
|
||||
"""
|
||||
fname = Path(self.fname)
|
||||
fname = Path(self.filepath_from_context(context))
|
||||
self_name = self.__class__.__name__
|
||||
collections, remainder = clique.assemble(
|
||||
os.listdir(fname.parent.as_posix())
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ from openpype.settings import get_current_project_settings
|
|||
from openpype.lib import Logger
|
||||
from openpype.pipeline import LoaderPlugin, LegacyCreator
|
||||
from openpype.pipeline.context_tools import get_current_project_asset
|
||||
from openpype.pipeline.load import get_representation_path_from_context
|
||||
from . import lib
|
||||
|
||||
log = Logger.get_logger(__name__)
|
||||
|
|
@ -393,7 +394,7 @@ class ClipLoader:
|
|||
active_bin = None
|
||||
data = dict()
|
||||
|
||||
def __init__(self, cls, context, **options):
|
||||
def __init__(self, cls, context, path, **options):
|
||||
""" Initialize object
|
||||
|
||||
Arguments:
|
||||
|
|
@ -406,6 +407,7 @@ class ClipLoader:
|
|||
self.__dict__.update(cls.__dict__)
|
||||
self.context = context
|
||||
self.active_project = lib.get_current_project()
|
||||
self.fname = path
|
||||
|
||||
# try to get value from options or evaluate key value for `handles`
|
||||
self.with_handles = options.get("handles") or bool(
|
||||
|
|
@ -467,7 +469,7 @@ class ClipLoader:
|
|||
self.data["track_name"] = "_".join([subset, representation])
|
||||
self.data["versionData"] = self.context["version"]["data"]
|
||||
# gets file path
|
||||
file = self.fname
|
||||
file = get_representation_path_from_context(self.context)
|
||||
if not file:
|
||||
repr_id = repr["_id"]
|
||||
log.warning(
|
||||
|
|
|
|||
|
|
@ -87,7 +87,8 @@ class LoadClip(phiero.SequenceLoader):
|
|||
})
|
||||
|
||||
# load clip to timeline and get main variables
|
||||
track_item = phiero.ClipLoader(self, context, **options).load()
|
||||
path = self.filepath_from_context(context)
|
||||
track_item = phiero.ClipLoader(self, context, path, **options).load()
|
||||
namespace = namespace or track_item.name()
|
||||
version = context['version']
|
||||
version_data = version.get("data", {})
|
||||
|
|
|
|||
|
|
@ -59,7 +59,8 @@ class LoadEffects(load.LoaderPlugin):
|
|||
}
|
||||
|
||||
# getting file path
|
||||
file = self.fname.replace("\\", "/")
|
||||
file = self.filepath_from_context(context)
|
||||
file = file.replace("\\", "/")
|
||||
|
||||
if self._shared_loading(
|
||||
file,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ class AbcLoader(load.LoaderPlugin):
|
|||
import hou
|
||||
|
||||
# Format file name, Houdini only wants forward slashes
|
||||
file_path = os.path.normpath(self.fname)
|
||||
file_path = self.filepath_from_context(context)
|
||||
file_path = os.path.normpath(file_path)
|
||||
file_path = file_path.replace("\\", "/")
|
||||
|
||||
# Get the root node
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ class AbcArchiveLoader(load.LoaderPlugin):
|
|||
import hou
|
||||
|
||||
# Format file name, Houdini only wants forward slashes
|
||||
file_path = os.path.normpath(self.fname)
|
||||
file_path = self.filepath_from_context(context)
|
||||
file_path = os.path.normpath(file_path)
|
||||
file_path = file_path.replace("\\", "/")
|
||||
|
||||
# Get the root node
|
||||
|
|
|
|||
|
|
@ -43,9 +43,10 @@ class BgeoLoader(load.LoaderPlugin):
|
|||
file_node.destroy()
|
||||
|
||||
# Explicitly create a file node
|
||||
path = self.filepath_from_context(context)
|
||||
file_node = container.createNode("file", node_name=node_name)
|
||||
file_node.setParms(
|
||||
{"file": self.format_path(self.fname, context["representation"])})
|
||||
{"file": self.format_path(path, context["representation"])})
|
||||
|
||||
# Set display on last node
|
||||
file_node.setDisplayFlag(True)
|
||||
|
|
|
|||
|
|
@ -94,7 +94,8 @@ class CameraLoader(load.LoaderPlugin):
|
|||
import hou
|
||||
|
||||
# Format file name, Houdini only wants forward slashes
|
||||
file_path = os.path.normpath(self.fname)
|
||||
file_path = self.filepath_from_context(context)
|
||||
file_path = os.path.normpath(file_path)
|
||||
file_path = file_path.replace("\\", "/")
|
||||
|
||||
# Get the root node
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ class HdaLoader(load.LoaderPlugin):
|
|||
import hou
|
||||
|
||||
# Format file name, Houdini only wants forward slashes
|
||||
file_path = os.path.normpath(self.fname)
|
||||
file_path = self.filepath_from_context(context)
|
||||
file_path = os.path.normpath(file_path)
|
||||
file_path = file_path.replace("\\", "/")
|
||||
|
||||
# Get the root node
|
||||
|
|
|
|||
|
|
@ -55,7 +55,8 @@ class ImageLoader(load.LoaderPlugin):
|
|||
def load(self, context, name=None, namespace=None, data=None):
|
||||
|
||||
# Format file name, Houdini only wants forward slashes
|
||||
file_path = os.path.normpath(self.fname)
|
||||
file_path = self.filepath_from_context(context)
|
||||
file_path = os.path.normpath(file_path)
|
||||
file_path = file_path.replace("\\", "/")
|
||||
file_path = self._get_file_sequence(file_path)
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ class USDSublayerLoader(load.LoaderPlugin):
|
|||
import hou
|
||||
|
||||
# Format file name, Houdini only wants forward slashes
|
||||
file_path = os.path.normpath(self.fname)
|
||||
file_path = self.filepath_from_context(context)
|
||||
file_path = os.path.normpath(file_path)
|
||||
file_path = file_path.replace("\\", "/")
|
||||
|
||||
# Get the root node
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ class USDReferenceLoader(load.LoaderPlugin):
|
|||
import hou
|
||||
|
||||
# Format file name, Houdini only wants forward slashes
|
||||
file_path = os.path.normpath(self.fname)
|
||||
file_path = self.filepath_from_context(context)
|
||||
file_path = os.path.normpath(file_path)
|
||||
file_path = file_path.replace("\\", "/")
|
||||
|
||||
# Get the root node
|
||||
|
|
|
|||
|
|
@ -40,8 +40,9 @@ class VdbLoader(load.LoaderPlugin):
|
|||
|
||||
# Explicitly create a file node
|
||||
file_node = container.createNode("file", node_name=node_name)
|
||||
path = self.filepath_from_context(context)
|
||||
file_node.setParms(
|
||||
{"file": self.format_path(self.fname, context["representation"])})
|
||||
{"file": self.format_path(path, context["representation"])})
|
||||
|
||||
# Set display on last node
|
||||
file_node.setDisplayFlag(True)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ class ShowInUsdview(load.LoaderPlugin):
|
|||
|
||||
usdview = find_executable("usdview")
|
||||
|
||||
filepath = os.path.normpath(self.fname)
|
||||
filepath = self.filepath_from_context(context)
|
||||
filepath = os.path.normpath(filepath)
|
||||
filepath = filepath.replace("\\", "/")
|
||||
|
||||
if not os.path.exists(filepath):
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ class FbxLoader(load.LoaderPlugin):
|
|||
def load(self, context, name=None, namespace=None, data=None):
|
||||
from pymxs import runtime as rt
|
||||
|
||||
filepath = os.path.normpath(self.fname)
|
||||
filepath = self.filepath_from_context(context)
|
||||
filepath = os.path.normpath(filepath)
|
||||
rt.FBXImporterSetParam("Animation", True)
|
||||
rt.FBXImporterSetParam("Camera", True)
|
||||
rt.FBXImporterSetParam("AxisConversionMethod", True)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ class MaxSceneLoader(load.LoaderPlugin):
|
|||
|
||||
def load(self, context, name=None, namespace=None, data=None):
|
||||
from pymxs import runtime as rt
|
||||
path = os.path.normpath(self.fname)
|
||||
|
||||
path = self.filepath_from_context(context)
|
||||
path = os.path.normpath(path)
|
||||
# import the max scene by using "merge file"
|
||||
path = path.replace('\\', '/')
|
||||
rt.MergeMaxFile(path)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ class AbcLoader(load.LoaderPlugin):
|
|||
def load(self, context, name=None, namespace=None, data=None):
|
||||
from pymxs import runtime as rt
|
||||
|
||||
file_path = os.path.normpath(self.fname)
|
||||
file_path = self.filepath_from_context(context)
|
||||
file_path = os.path.normpath(file_path)
|
||||
|
||||
abc_before = {
|
||||
c
|
||||
|
|
|
|||
|
|
@ -485,7 +485,8 @@ class ReferenceLoader(Loader):
|
|||
namespace=None,
|
||||
options=None
|
||||
):
|
||||
assert os.path.exists(self.fname), "%s does not exist." % self.fname
|
||||
path = self.filepath_from_context(context)
|
||||
assert os.path.exists(path), "%s does not exist." % path
|
||||
|
||||
asset = context['asset']
|
||||
subset = context['subset']
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ class AbcLoader(openpype.hosts.maya.api.plugin.ReferenceLoader):
|
|||
|
||||
# hero_001 (abc)
|
||||
# asset_counter{optional}
|
||||
file_url = self.prepare_root_value(self.fname,
|
||||
path = self.filepath_from_context(context)
|
||||
file_url = self.prepare_root_value(path,
|
||||
context["project"]["name"])
|
||||
nodes = cmds.file(file_url,
|
||||
namespace=namespace,
|
||||
|
|
|
|||
|
|
@ -138,8 +138,9 @@ class ImportMayaLoader(load.LoaderPlugin):
|
|||
suffix="_",
|
||||
)
|
||||
|
||||
path = self.filepath_from_context(context)
|
||||
with maintained_selection():
|
||||
nodes = cmds.file(self.fname,
|
||||
nodes = cmds.file(path,
|
||||
i=True,
|
||||
preserveReferences=True,
|
||||
namespace=namespace,
|
||||
|
|
|
|||
|
|
@ -89,11 +89,12 @@ class ArnoldStandinLoader(load.LoaderPlugin):
|
|||
cmds.parent(standin, root)
|
||||
|
||||
# Set the standin filepath
|
||||
repre_path = self.filepath_from_context(context)
|
||||
path, operator = self._setup_proxy(
|
||||
standin_shape, self.fname, namespace
|
||||
standin_shape, repre_path, namespace
|
||||
)
|
||||
cmds.setAttr(standin_shape + ".dso", path, type="string")
|
||||
sequence = is_sequence(os.listdir(os.path.dirname(self.fname)))
|
||||
sequence = is_sequence(os.listdir(os.path.dirname(repre_path)))
|
||||
cmds.setAttr(standin_shape + ".useFrameExtension", sequence)
|
||||
|
||||
fps = float(version["data"].get("fps"))or get_current_session_fps()
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class AssemblyLoader(load.LoaderPlugin):
|
|||
)
|
||||
|
||||
containers = setdress.load_package(
|
||||
filepath=self.fname,
|
||||
filepath=self.filepath_from_context(context),
|
||||
name=name,
|
||||
namespace=namespace
|
||||
)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@ class GpuCacheLoader(load.LoaderPlugin):
|
|||
name="{0}Shape".format(transform_name))
|
||||
|
||||
# Set the cache filepath
|
||||
cmds.setAttr(cache + '.cacheFileName', self.fname, type="string")
|
||||
path = self.filepath_from_context(context)
|
||||
cmds.setAttr(cache + '.cacheFileName', path, type="string")
|
||||
cmds.setAttr(cache + '.cacheGeomPath', "|", type="string") # root
|
||||
|
||||
# Lock parenting of the transform and cache
|
||||
|
|
|
|||
|
|
@ -32,8 +32,10 @@ class LookLoader(openpype.hosts.maya.api.plugin.ReferenceLoader):
|
|||
from maya import cmds
|
||||
|
||||
with lib.maintained_selection():
|
||||
file_url = self.prepare_root_value(self.fname,
|
||||
context["project"]["name"])
|
||||
file_url = self.prepare_root_value(
|
||||
file_url=self.filepath_from_context(context),
|
||||
project_name=context["project"]["name"]
|
||||
)
|
||||
nodes = cmds.file(file_url,
|
||||
namespace=namespace,
|
||||
reference=True,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
from maya import mel
|
||||
from openpype.pipeline import load
|
||||
|
||||
|
||||
class MatchmoveLoader(load.LoaderPlugin):
|
||||
"""
|
||||
This will run matchmove script to create track in scene.
|
||||
|
|
@ -18,11 +17,12 @@ class MatchmoveLoader(load.LoaderPlugin):
|
|||
color = "orange"
|
||||
|
||||
def load(self, context, name, namespace, data):
|
||||
if self.fname.lower().endswith(".py"):
|
||||
exec(open(self.fname).read())
|
||||
path = self.filepath_from_context(context)
|
||||
if path.lower().endswith(".py"):
|
||||
exec(open(path).read())
|
||||
|
||||
elif self.fname.lower().endswith(".mel"):
|
||||
mel.eval('source "{}"'.format(self.fname))
|
||||
elif path.lower().endswith(".mel"):
|
||||
mel.eval('source "{}"'.format(path))
|
||||
|
||||
else:
|
||||
self.log.error("Unsupported script type")
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ class MultiverseUsdLoader(load.LoaderPlugin):
|
|||
suffix="_",
|
||||
)
|
||||
|
||||
path = self.filepath_from_context(context)
|
||||
|
||||
# Make sure we can load the plugin
|
||||
cmds.loadPlugin("MultiverseForMaya", quiet=True)
|
||||
import multiverse
|
||||
|
|
@ -46,7 +48,7 @@ class MultiverseUsdLoader(load.LoaderPlugin):
|
|||
with maintained_selection():
|
||||
cmds.namespace(addNamespace=namespace)
|
||||
with namespaced(namespace, new=False):
|
||||
shape = multiverse.CreateUsdCompound(self.fname)
|
||||
shape = multiverse.CreateUsdCompound(path)
|
||||
transform = cmds.listRelatives(
|
||||
shape, parent=True, fullPath=True)[0]
|
||||
|
||||
|
|
|
|||
|
|
@ -50,9 +50,10 @@ class MultiverseUsdOverLoader(load.LoaderPlugin):
|
|||
cmds.loadPlugin("MultiverseForMaya", quiet=True)
|
||||
import multiverse
|
||||
|
||||
path = self.filepath_from_context(context)
|
||||
nodes = current_usd
|
||||
with maintained_selection():
|
||||
multiverse.AddUsdCompoundAssetPath(current_usd[0], self.fname)
|
||||
multiverse.AddUsdCompoundAssetPath(current_usd[0], path)
|
||||
|
||||
namespace = current_usd[0].split("|")[1].split(":")[0]
|
||||
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ class RedshiftProxyLoader(load.LoaderPlugin):
|
|||
# Ensure Redshift for Maya is loaded.
|
||||
cmds.loadPlugin("redshift4maya", quiet=True)
|
||||
|
||||
path = self.filepath_from_context(context)
|
||||
with maintained_selection():
|
||||
cmds.namespace(addNamespace=namespace)
|
||||
with namespaced(namespace, new=False):
|
||||
nodes, group_node = self.create_rs_proxy(
|
||||
name, self.fname)
|
||||
nodes, group_node = self.create_rs_proxy(name, path)
|
||||
|
||||
self[:] = nodes
|
||||
if not nodes:
|
||||
|
|
|
|||
|
|
@ -122,9 +122,10 @@ class ReferenceLoader(openpype.hosts.maya.api.plugin.ReferenceLoader):
|
|||
attach_to_root = options.get("attach_to_root", True)
|
||||
group_name = options["group_name"]
|
||||
|
||||
path = self.filepath_from_context(context)
|
||||
with maintained_selection():
|
||||
cmds.loadPlugin("AbcImport.mll", quiet=True)
|
||||
file_url = self.prepare_root_value(self.fname,
|
||||
file_url = self.prepare_root_value(path,
|
||||
context["project"]["name"])
|
||||
|
||||
nodes = cmds.file(file_url,
|
||||
|
|
|
|||
|
|
@ -43,8 +43,9 @@ class RenderSetupLoader(load.LoaderPlugin):
|
|||
prefix="_" if asset[0].isdigit() else "",
|
||||
suffix="_",
|
||||
)
|
||||
self.log.info(">>> loading json [ {} ]".format(self.fname))
|
||||
with open(self.fname, "r") as file:
|
||||
path = self.filepath_from_context(context)
|
||||
self.log.info(">>> loading json [ {} ]".format(path))
|
||||
with open(path, "r") as file:
|
||||
renderSetup.instance().decode(
|
||||
json.load(file), renderSetup.DECODE_AND_OVERWRITE, None)
|
||||
|
||||
|
|
|
|||
|
|
@ -65,8 +65,9 @@ class LoadVDBtoArnold(load.LoaderPlugin):
|
|||
name="{}Shape".format(root),
|
||||
parent=root)
|
||||
|
||||
path = self.filepath_from_context(context)
|
||||
self._set_path(grid_node,
|
||||
path=self.fname,
|
||||
path=path,
|
||||
representation=context["representation"])
|
||||
|
||||
# Lock the shape node so the user can't delete the transform/shape
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class LoadVDBtoRedShift(load.LoaderPlugin):
|
|||
parent=root)
|
||||
|
||||
self._set_path(volume_node,
|
||||
path=self.fname,
|
||||
path=self.filepath_from_context(context),
|
||||
representation=context["representation"])
|
||||
|
||||
nodes = [root, volume_node]
|
||||
|
|
|
|||
|
|
@ -88,8 +88,9 @@ class LoadVDBtoVRay(load.LoaderPlugin):
|
|||
from openpype.hosts.maya.api.lib import unique_namespace
|
||||
from openpype.hosts.maya.api.pipeline import containerise
|
||||
|
||||
assert os.path.exists(self.fname), (
|
||||
"Path does not exist: %s" % self.fname
|
||||
path = self.filepath_from_context(context)
|
||||
assert os.path.exists(path), (
|
||||
"Path does not exist: %s" % path
|
||||
)
|
||||
|
||||
try:
|
||||
|
|
@ -146,7 +147,7 @@ class LoadVDBtoVRay(load.LoaderPlugin):
|
|||
cmds.connectAttr("time1.outTime", grid_node + ".currentTime")
|
||||
|
||||
# Set path
|
||||
self._set_path(grid_node, self.fname, show_preset_popup=True)
|
||||
self._set_path(grid_node, path, show_preset_popup=True)
|
||||
|
||||
# Lock the shape node so the user can't delete the transform/shape
|
||||
# as if it was referenced
|
||||
|
|
|
|||
|
|
@ -53,7 +53,9 @@ class VRayProxyLoader(load.LoaderPlugin):
|
|||
family = "vrayproxy"
|
||||
|
||||
# get all representations for this version
|
||||
self.fname = self._get_abc(context["version"]["_id"]) or self.fname
|
||||
filename = self._get_abc(context["version"]["_id"])
|
||||
if not filename:
|
||||
filename = self.filepath_from_context(context)
|
||||
|
||||
asset_name = context['asset']["name"]
|
||||
namespace = namespace or unique_namespace(
|
||||
|
|
@ -69,7 +71,7 @@ class VRayProxyLoader(load.LoaderPlugin):
|
|||
cmds.namespace(addNamespace=namespace)
|
||||
with namespaced(namespace, new=False):
|
||||
nodes, group_node = self.create_vray_proxy(
|
||||
name, filename=self.fname)
|
||||
name, filename=filename)
|
||||
|
||||
self[:] = nodes
|
||||
if not nodes:
|
||||
|
|
@ -190,7 +192,7 @@ class VRayProxyLoader(load.LoaderPlugin):
|
|||
if abc_rep:
|
||||
self.log.debug("Found, we'll link alembic to vray proxy.")
|
||||
file_name = get_representation_path(abc_rep)
|
||||
self.log.debug("File: {}".format(self.fname))
|
||||
self.log.debug("File: {}".format(file_name))
|
||||
return file_name
|
||||
|
||||
return ""
|
||||
|
|
|
|||
|
|
@ -46,8 +46,10 @@ class VRaySceneLoader(load.LoaderPlugin):
|
|||
with maintained_selection():
|
||||
cmds.namespace(addNamespace=namespace)
|
||||
with namespaced(namespace, new=False):
|
||||
nodes, root_node = self.create_vray_scene(name,
|
||||
filename=self.fname)
|
||||
nodes, root_node = self.create_vray_scene(
|
||||
name,
|
||||
filename=self.filepath_from_context(context)
|
||||
)
|
||||
|
||||
self[:] = nodes
|
||||
if not nodes:
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ class XgenLoader(openpype.hosts.maya.api.plugin.ReferenceLoader):
|
|||
return
|
||||
|
||||
maya_filepath = self.prepare_root_value(
|
||||
self.fname, context["project"]["name"]
|
||||
file_url=self.filepath_from_context(context),
|
||||
project_name=context["project"]["name"]
|
||||
)
|
||||
|
||||
# Reference xgen. Xgen does not like being referenced in under a group.
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@ class YetiCacheLoader(load.LoaderPlugin):
|
|||
cmds.loadPlugin("pgYetiMaya", quiet=True)
|
||||
|
||||
# Create Yeti cache nodes according to settings
|
||||
settings = self.read_settings(self.fname)
|
||||
path = self.filepath_from_context(context)
|
||||
settings = self.read_settings(path)
|
||||
nodes = []
|
||||
for node in settings["nodes"]:
|
||||
nodes.extend(self.create_node(namespace, node))
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@ class YetiRigLoader(openpype.hosts.maya.api.plugin.ReferenceLoader):
|
|||
self, context, name=None, namespace=None, options=None
|
||||
):
|
||||
group_name = options['group_name']
|
||||
path = self.filepath_from_context(context)
|
||||
with lib.maintained_selection():
|
||||
file_url = self.prepare_root_value(
|
||||
self.fname, context["project"]["name"]
|
||||
path, context["project"]["name"]
|
||||
)
|
||||
nodes = cmds.file(
|
||||
file_url,
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class LoadBackdropNodes(load.LoaderPlugin):
|
|||
data_imprint.update({k: version_data[k]})
|
||||
|
||||
# getting file path
|
||||
file = self.fname.replace("\\", "/")
|
||||
file = self.filepath_from_context(context).replace("\\", "/")
|
||||
|
||||
# adding nodes to node graph
|
||||
# just in case we are in group lets jump out of it
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class AlembicCameraLoader(load.LoaderPlugin):
|
|||
data_imprint.update({k: version_data[k]})
|
||||
|
||||
# getting file path
|
||||
file = self.fname.replace("\\", "/")
|
||||
file = self.filepath_from_context(context).replace("\\", "/")
|
||||
|
||||
with maintained_selection():
|
||||
camera_node = nuke.createNode(
|
||||
|
|
|
|||
|
|
@ -99,7 +99,8 @@ class LoadClip(plugin.NukeLoader):
|
|||
representation = self._representation_with_hash_in_frame(
|
||||
representation
|
||||
)
|
||||
filepath = get_representation_path(representation).replace("\\", "/")
|
||||
filepath = self.filepath_from_context(context)
|
||||
filepath = filepath.replace("\\", "/")
|
||||
self.log.debug("_ filepath: {}".format(filepath))
|
||||
|
||||
start_at_workfile = options.get(
|
||||
|
|
@ -154,7 +155,7 @@ class LoadClip(plugin.NukeLoader):
|
|||
read_node["file"].setValue(filepath)
|
||||
|
||||
used_colorspace = self._set_colorspace(
|
||||
read_node, version_data, representation["data"])
|
||||
read_node, version_data, representation["data"], filepath)
|
||||
|
||||
self._set_range_to_node(read_node, first, last, start_at_workfile)
|
||||
|
||||
|
|
@ -306,8 +307,7 @@ class LoadClip(plugin.NukeLoader):
|
|||
# we will switch off undo-ing
|
||||
with viewer_update_and_undo_stop():
|
||||
used_colorspace = self._set_colorspace(
|
||||
read_node, version_data, representation["data"],
|
||||
path=filepath)
|
||||
read_node, version_data, representation["data"], filepath)
|
||||
|
||||
self._set_range_to_node(read_node, first, last, start_at_workfile)
|
||||
|
||||
|
|
@ -454,9 +454,9 @@ class LoadClip(plugin.NukeLoader):
|
|||
|
||||
return self.node_name_template.format(**name_data)
|
||||
|
||||
def _set_colorspace(self, node, version_data, repre_data, path=None):
|
||||
def _set_colorspace(self, node, version_data, repre_data, path):
|
||||
output_color = None
|
||||
path = path or self.fname.replace("\\", "/")
|
||||
path = path.replace("\\", "/")
|
||||
# get colorspace
|
||||
colorspace = repre_data.get("colorspace")
|
||||
colorspace = colorspace or version_data.get("colorspace")
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class LoadEffects(load.LoaderPlugin):
|
|||
data_imprint.update({k: version_data[k]})
|
||||
|
||||
# getting file path
|
||||
file = self.fname.replace("\\", "/")
|
||||
file = self.filepath_from_context(context).replace("\\", "/")
|
||||
|
||||
# getting data from json file with unicode conversion
|
||||
with open(file, "r") as f:
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class LoadEffectsInputProcess(load.LoaderPlugin):
|
|||
data_imprint.update({k: version_data[k]})
|
||||
|
||||
# getting file path
|
||||
file = self.fname.replace("\\", "/")
|
||||
file = self.filepath_from_context(context).replace("\\", "/")
|
||||
|
||||
# getting data from json file with unicode conversion
|
||||
with open(file, "r") as f:
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class LoadGizmo(load.LoaderPlugin):
|
|||
data_imprint.update({k: version_data[k]})
|
||||
|
||||
# getting file path
|
||||
file = self.fname.replace("\\", "/")
|
||||
file = self.filepath_from_context(context).replace("\\", "/")
|
||||
|
||||
# adding nodes to node graph
|
||||
# just in case we are in group lets jump out of it
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class LoadGizmoInputProcess(load.LoaderPlugin):
|
|||
data_imprint.update({k: version_data[k]})
|
||||
|
||||
# getting file path
|
||||
file = self.fname.replace("\\", "/")
|
||||
file = self.filepath_from_context(context).replace("\\", "/")
|
||||
|
||||
# adding nodes to node graph
|
||||
# just in case we are in group lets jump out of it
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class LoadImage(load.LoaderPlugin):
|
|||
if namespace is None:
|
||||
namespace = context['asset']['name']
|
||||
|
||||
file = self.fname
|
||||
file = self.filepath_from_context(context)
|
||||
|
||||
if not file:
|
||||
repr_id = context["representation"]["_id"]
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@ class MatchmoveLoader(load.LoaderPlugin):
|
|||
color = "orange"
|
||||
|
||||
def load(self, context, name, namespace, data):
|
||||
if self.fname.lower().endswith(".py"):
|
||||
exec(open(self.fname).read())
|
||||
path = self.filepath_from_context(context)
|
||||
if path.lower().endswith(".py"):
|
||||
exec(open(path).read())
|
||||
|
||||
else:
|
||||
msg = "Unsupported script type"
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class AlembicModelLoader(load.LoaderPlugin):
|
|||
data_imprint.update({k: version_data[k]})
|
||||
|
||||
# getting file path
|
||||
file = self.fname.replace("\\", "/")
|
||||
file = self.filepath_from_context(context).replace("\\", "/")
|
||||
|
||||
with maintained_selection():
|
||||
model_node = nuke.createNode(
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ class LinkAsGroup(load.LoaderPlugin):
|
|||
if namespace is None:
|
||||
namespace = context['asset']['name']
|
||||
|
||||
file = self.fname.replace("\\", "/")
|
||||
self.log.info("file: {}\n".format(self.fname))
|
||||
file = self.filepath_from_context(context).replace("\\", "/")
|
||||
self.log.info("file: {}\n".format(file))
|
||||
|
||||
precomp_name = context["representation"]["context"]["subset"]
|
||||
|
||||
|
|
|
|||
|
|
@ -210,8 +210,9 @@ class ImageLoader(load.LoaderPlugin):
|
|||
representations = ["*"]
|
||||
|
||||
def load(self, context, name=None, namespace=None, data=None):
|
||||
path = self.filepath_from_context(context)
|
||||
with photoshop.maintained_selection():
|
||||
layer = stub.import_smart_object(self.fname)
|
||||
layer = stub.import_smart_object(path)
|
||||
|
||||
self[:] = [layer]
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ class ImageLoader(photoshop.PhotoshopLoader):
|
|||
name
|
||||
)
|
||||
with photoshop.maintained_selection():
|
||||
layer = self.import_layer(self.fname, layer_name, stub)
|
||||
path = self.filepath_from_context(context)
|
||||
layer = self.import_layer(path, layer_name, stub)
|
||||
|
||||
self[:] = [layer]
|
||||
namespace = namespace or layer_name
|
||||
|
|
|
|||
|
|
@ -29,11 +29,13 @@ class ImageFromSequenceLoader(photoshop.PhotoshopLoader):
|
|||
options = []
|
||||
|
||||
def load(self, context, name=None, namespace=None, data=None):
|
||||
|
||||
path = self.filepath_from_context(context)
|
||||
if data.get("frame"):
|
||||
self.fname = os.path.join(
|
||||
os.path.dirname(self.fname), data["frame"]
|
||||
path = os.path.join(
|
||||
os.path.dirname(path), data["frame"]
|
||||
)
|
||||
if not os.path.exists(self.fname):
|
||||
if not os.path.exists(path):
|
||||
return
|
||||
|
||||
stub = self.get_stub()
|
||||
|
|
@ -42,7 +44,7 @@ class ImageFromSequenceLoader(photoshop.PhotoshopLoader):
|
|||
)
|
||||
|
||||
with photoshop.maintained_selection():
|
||||
layer = stub.import_smart_object(self.fname, layer_name)
|
||||
layer = stub.import_smart_object(path, layer_name)
|
||||
|
||||
self[:] = [layer]
|
||||
namespace = namespace or layer_name
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ class ReferenceLoader(photoshop.PhotoshopLoader):
|
|||
stub.get_layers(), context["asset"]["name"], name
|
||||
)
|
||||
with photoshop.maintained_selection():
|
||||
layer = self.import_layer(self.fname, layer_name, stub)
|
||||
path = self.filepath_from_context(context)
|
||||
layer = self.import_layer(path, layer_name, stub)
|
||||
|
||||
self[:] = [layer]
|
||||
namespace = namespace or layer_name
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ class ClipLoader:
|
|||
active_bin = None
|
||||
data = dict()
|
||||
|
||||
def __init__(self, cls, context, **options):
|
||||
def __init__(self, cls, context, path, **options):
|
||||
""" Initialize object
|
||||
|
||||
Arguments:
|
||||
|
|
@ -304,6 +304,7 @@ class ClipLoader:
|
|||
self.__dict__.update(cls.__dict__)
|
||||
self.context = context
|
||||
self.active_project = lib.get_current_project()
|
||||
self.fname = path
|
||||
|
||||
# try to get value from options or evaluate key value for `handles`
|
||||
self.with_handles = options.get("handles") or bool(
|
||||
|
|
|
|||
|
|
@ -55,8 +55,9 @@ class LoadClip(plugin.TimelineItemLoader):
|
|||
})
|
||||
|
||||
# load clip to timeline and get main variables
|
||||
path = self.filepath_from_context(context)
|
||||
timeline_item = plugin.ClipLoader(
|
||||
self, context, **options).load()
|
||||
self, context, path, **options).load()
|
||||
namespace = namespace or timeline_item.GetName()
|
||||
version = context['version']
|
||||
version_data = version.get("data", {})
|
||||
|
|
@ -115,10 +116,10 @@ class LoadClip(plugin.TimelineItemLoader):
|
|||
version_name = version.get("name", None)
|
||||
colorspace = version_data.get("colorspace", None)
|
||||
object_name = "{}_{}".format(name, namespace)
|
||||
self.fname = get_representation_path(representation)
|
||||
path = get_representation_path(representation)
|
||||
context["version"] = {"data": version_data}
|
||||
|
||||
loader = plugin.ClipLoader(self, context)
|
||||
loader = plugin.ClipLoader(self, context, path)
|
||||
timeline_item = loader.update(timeline_item)
|
||||
|
||||
# add additional metadata from the version to imprint Avalon knob
|
||||
|
|
|
|||
|
|
@ -77,8 +77,9 @@ class ImportImage(plugin.Loader):
|
|||
)
|
||||
# Fill import script with filename and layer name
|
||||
# - filename mus not contain backwards slashes
|
||||
path = self.filepath_from_context(context).replace("\\", "/")
|
||||
george_script = self.import_script.format(
|
||||
self.fname.replace("\\", "/"),
|
||||
path,
|
||||
layer_name,
|
||||
load_options_str
|
||||
)
|
||||
|
|
|
|||
|
|
@ -86,10 +86,12 @@ class LoadImage(plugin.Loader):
|
|||
subset_name = context["subset"]["name"]
|
||||
layer_name = self.get_unique_layer_name(asset_name, subset_name)
|
||||
|
||||
path = self.filepath_from_context(context)
|
||||
|
||||
# Fill import script with filename and layer name
|
||||
# - filename mus not contain backwards slashes
|
||||
george_script = self.import_script.format(
|
||||
self.fname.replace("\\", "/"),
|
||||
path.replace("\\", "/"),
|
||||
layer_name,
|
||||
load_options_str
|
||||
)
|
||||
|
|
@ -271,9 +273,6 @@ class LoadImage(plugin.Loader):
|
|||
# Remove old layers
|
||||
self._remove_layers(layer_ids=layer_ids_to_remove)
|
||||
|
||||
# Change `fname` to new representation
|
||||
self.fname = self.filepath_from_context(context)
|
||||
|
||||
name = container["name"]
|
||||
namespace = container["namespace"]
|
||||
new_container = self.load(context, name, namespace, {})
|
||||
|
|
|
|||
|
|
@ -60,9 +60,10 @@ class ImportSound(plugin.Loader):
|
|||
output_filepath = output_file.name.replace("\\", "/")
|
||||
|
||||
# Prepare george script
|
||||
path = self.filepath_from_context(context).replace("\\", "/")
|
||||
import_script = "\n".join(self.import_script_lines)
|
||||
george_script = import_script.format(
|
||||
self.fname.replace("\\", "/"),
|
||||
path,
|
||||
output_filepath
|
||||
)
|
||||
self.log.info("*** George script:\n{}\n***".format(george_script))
|
||||
|
|
|
|||
|
|
@ -31,18 +31,18 @@ class LoadWorkfile(plugin.Loader):
|
|||
def load(self, context, name, namespace, options):
|
||||
# Load context of current workfile as first thing
|
||||
# - which context and extension has
|
||||
host = registered_host()
|
||||
current_file = host.get_current_workfile()
|
||||
|
||||
context = get_current_workfile_context()
|
||||
|
||||
filepath = self.fname.replace("\\", "/")
|
||||
filepath = self.filepath_from_context(context)
|
||||
filepath = filepath.replace("\\", "/")
|
||||
|
||||
if not os.path.exists(filepath):
|
||||
raise FileExistsError(
|
||||
"The loaded file does not exist. Try downloading it first."
|
||||
)
|
||||
|
||||
host = registered_host()
|
||||
current_file = host.get_current_workfile()
|
||||
work_context = get_current_workfile_context()
|
||||
|
||||
george_script = "tv_LoadProject '\"'\"{}\"'\"'".format(
|
||||
filepath
|
||||
)
|
||||
|
|
@ -50,10 +50,10 @@ class LoadWorkfile(plugin.Loader):
|
|||
|
||||
# Save workfile.
|
||||
host_name = "tvpaint"
|
||||
project_name = context.get("project")
|
||||
asset_name = context.get("asset")
|
||||
task_name = context.get("task")
|
||||
# Far cases when there is workfile without context
|
||||
project_name = work_context.get("project")
|
||||
asset_name = work_context.get("asset")
|
||||
task_name = work_context.get("task")
|
||||
# Far cases when there is workfile without work_context
|
||||
if not asset_name:
|
||||
project_name = legacy_io.active_project()
|
||||
asset_name = legacy_io.Session["AVALON_ASSET"]
|
||||
|
|
|
|||
|
|
@ -87,7 +87,8 @@ class AnimationAlembicLoader(plugin.Loader):
|
|||
if not unreal.EditorAssetLibrary.does_directory_exist(asset_dir):
|
||||
unreal.EditorAssetLibrary.make_directory(asset_dir)
|
||||
|
||||
task = self.get_task(self.fname, asset_dir, asset_name, False)
|
||||
path = self.filepath_from_context(context)
|
||||
task = self.get_task(path, asset_dir, asset_name, False)
|
||||
|
||||
asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
|
||||
asset_tools.import_asset_tasks([task])
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class AnimationFBXLoader(plugin.Loader):
|
|||
icon = "cube"
|
||||
color = "orange"
|
||||
|
||||
def _process(self, asset_dir, asset_name, instance_name):
|
||||
def _process(self, path, asset_dir, asset_name, instance_name):
|
||||
automated = False
|
||||
actor = None
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ class AnimationFBXLoader(plugin.Loader):
|
|||
|
||||
asset_doc = get_current_project_asset(fields=["data.fps"])
|
||||
|
||||
task.set_editor_property('filename', self.fname)
|
||||
task.set_editor_property('filename', path)
|
||||
task.set_editor_property('destination_path', asset_dir)
|
||||
task.set_editor_property('destination_name', asset_name)
|
||||
task.set_editor_property('replace_existing', False)
|
||||
|
|
@ -177,14 +177,15 @@ class AnimationFBXLoader(plugin.Loader):
|
|||
|
||||
EditorAssetLibrary.make_directory(asset_dir)
|
||||
|
||||
libpath = self.fname.replace("fbx", "json")
|
||||
path = self.filepath_from_context(context)
|
||||
libpath = path.replace(".fbx", ".json")
|
||||
|
||||
with open(libpath, "r") as fp:
|
||||
data = json.load(fp)
|
||||
|
||||
instance_name = data.get("instance_name")
|
||||
|
||||
animation = self._process(asset_dir, asset_name, instance_name)
|
||||
animation = self._process(path, asset_dir, asset_name, instance_name)
|
||||
|
||||
asset_content = EditorAssetLibrary.list_assets(
|
||||
hierarchy_dir, recursive=True, include_folder=False)
|
||||
|
|
|
|||
|
|
@ -200,12 +200,13 @@ class CameraLoader(plugin.Loader):
|
|||
settings.set_editor_property('reduce_keys', False)
|
||||
|
||||
if cam_seq:
|
||||
path = self.filepath_from_context(context)
|
||||
self._import_camera(
|
||||
EditorLevelLibrary.get_editor_world(),
|
||||
cam_seq,
|
||||
cam_seq.get_bindings(),
|
||||
settings,
|
||||
self.fname
|
||||
path
|
||||
)
|
||||
|
||||
# Set range of all sections
|
||||
|
|
|
|||
|
|
@ -111,8 +111,9 @@ class PointCacheAlembicLoader(plugin.Loader):
|
|||
if frame_start == frame_end:
|
||||
frame_end += 1
|
||||
|
||||
path = self.filepath_from_context(context)
|
||||
task = self.get_task(
|
||||
self.fname, asset_dir, asset_name, False, frame_start, frame_end)
|
||||
path, asset_dir, asset_name, False, frame_start, frame_end)
|
||||
|
||||
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task]) # noqa: E501
|
||||
|
||||
|
|
|
|||
|
|
@ -618,7 +618,8 @@ class LayoutLoader(plugin.Loader):
|
|||
|
||||
EditorLevelLibrary.load_level(level)
|
||||
|
||||
loaded_assets = self._process(self.fname, asset_dir, shot)
|
||||
path = self.filepath_from_context(context)
|
||||
loaded_assets = self._process(path, asset_dir, shot)
|
||||
|
||||
for s in sequences:
|
||||
EditorAssetLibrary.save_asset(s.get_path_name())
|
||||
|
|
|
|||
|
|
@ -380,7 +380,8 @@ class ExistingLayoutLoader(plugin.Loader):
|
|||
raise AssertionError("Current level not saved")
|
||||
|
||||
project_name = context["project"]["name"]
|
||||
containers = self._process(self.fname, project_name)
|
||||
path = self.filepath_from_context(context)
|
||||
containers = self._process(path, project_name)
|
||||
|
||||
curr_level_path = Path(
|
||||
curr_level.get_outer().get_path_name()).parent.as_posix()
|
||||
|
|
|
|||
|
|
@ -89,7 +89,8 @@ class SkeletalMeshAlembicLoader(plugin.Loader):
|
|||
if not unreal.EditorAssetLibrary.does_directory_exist(asset_dir):
|
||||
unreal.EditorAssetLibrary.make_directory(asset_dir)
|
||||
|
||||
task = self.get_task(self.fname, asset_dir, asset_name, False)
|
||||
path = self.filepath_from_context(context)
|
||||
task = self.get_task(path, asset_dir, asset_name, False)
|
||||
|
||||
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task]) # noqa: E501
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class SkeletalMeshFBXLoader(plugin.Loader):
|
|||
def load(self, context, name, namespace, options):
|
||||
"""Load and containerise representation into Content Browser.
|
||||
|
||||
This is two step process. First, import FBX to temporary path and
|
||||
This is a two step process. First, import FBX to temporary path and
|
||||
then call `containerise()` on it - this moves all content to new
|
||||
directory and then it will create AssetContainer there and imprint it
|
||||
with metadata. This will mark this path as container.
|
||||
|
|
@ -65,7 +65,8 @@ class SkeletalMeshFBXLoader(plugin.Loader):
|
|||
|
||||
task = unreal.AssetImportTask()
|
||||
|
||||
task.set_editor_property('filename', self.fname)
|
||||
path = self.filepath_from_context(context)
|
||||
task.set_editor_property('filename', path)
|
||||
task.set_editor_property('destination_path', asset_dir)
|
||||
task.set_editor_property('destination_name', asset_name)
|
||||
task.set_editor_property('replace_existing', False)
|
||||
|
|
|
|||
|
|
@ -98,8 +98,9 @@ class StaticMeshAlembicLoader(plugin.Loader):
|
|||
if not unreal.EditorAssetLibrary.does_directory_exist(asset_dir):
|
||||
unreal.EditorAssetLibrary.make_directory(asset_dir)
|
||||
|
||||
path = self.filepath_from_context(context)
|
||||
task = self.get_task(
|
||||
self.fname, asset_dir, asset_name, False, default_conversion)
|
||||
path, asset_dir, asset_name, False, default_conversion)
|
||||
|
||||
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task]) # noqa: E501
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,8 @@ class StaticMeshFBXLoader(plugin.Loader):
|
|||
|
||||
unreal.EditorAssetLibrary.make_directory(asset_dir)
|
||||
|
||||
task = self.get_task(self.fname, asset_dir, asset_name, False)
|
||||
path = self.filepath_from_context(context)
|
||||
task = self.get_task(path, asset_dir, asset_name, False)
|
||||
|
||||
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task]) # noqa: E501
|
||||
|
||||
|
|
|
|||
|
|
@ -64,8 +64,9 @@ class UAssetLoader(plugin.Loader):
|
|||
destination_path = asset_dir.replace(
|
||||
"/Game", Path(unreal.Paths.project_content_dir()).as_posix(), 1)
|
||||
|
||||
path = self.filepath_from_context(context)
|
||||
shutil.copy(
|
||||
self.fname,
|
||||
path,
|
||||
f"{destination_path}/{name}_{unique_number:02}.{self.extension}")
|
||||
|
||||
# Create Asset Container
|
||||
|
|
|
|||
|
|
@ -39,9 +39,6 @@ class LoaderPlugin(list):
|
|||
log = logging.getLogger("SubsetLoader")
|
||||
log.propagate = True
|
||||
|
||||
def __init__(self, context):
|
||||
self.fname = self.filepath_from_context(context)
|
||||
|
||||
@classmethod
|
||||
def apply_settings(cls, project_settings, system_settings):
|
||||
host_name = os.environ.get("AVALON_APP")
|
||||
|
|
@ -246,9 +243,6 @@ class SubsetLoaderPlugin(LoaderPlugin):
|
|||
namespace (str, optional): Use pre-defined namespace
|
||||
"""
|
||||
|
||||
def __init__(self, context):
|
||||
pass
|
||||
|
||||
|
||||
def discover_loader_plugins(project_name=None):
|
||||
from openpype.lib import Logger
|
||||
|
|
|
|||
|
|
@ -314,7 +314,12 @@ def load_with_repre_context(
|
|||
)
|
||||
)
|
||||
|
||||
loader = Loader(repre_context)
|
||||
loader = Loader()
|
||||
|
||||
# Backwards compatibility: Originally the loader's __init__ required the
|
||||
# representation context to set `fname` attribute to the filename to load
|
||||
loader.fname = get_representation_path_from_context(repre_context)
|
||||
|
||||
return loader.load(repre_context, name, namespace, options)
|
||||
|
||||
|
||||
|
|
@ -338,8 +343,7 @@ def load_with_subset_context(
|
|||
)
|
||||
)
|
||||
|
||||
loader = Loader(subset_context)
|
||||
return loader.load(subset_context, name, namespace, options)
|
||||
return Loader().load(subset_context, name, namespace, options)
|
||||
|
||||
|
||||
def load_with_subset_contexts(
|
||||
|
|
@ -364,8 +368,7 @@ def load_with_subset_contexts(
|
|||
"Running '{}' on '{}'".format(Loader.__name__, joined_subset_names)
|
||||
)
|
||||
|
||||
loader = Loader(subset_contexts)
|
||||
return loader.load(subset_contexts, name, namespace, options)
|
||||
return Loader().load(subset_contexts, name, namespace, options)
|
||||
|
||||
|
||||
def load_container(
|
||||
|
|
@ -447,8 +450,7 @@ def remove_container(container):
|
|||
.format(container.get("loader"))
|
||||
)
|
||||
|
||||
loader = Loader(get_representation_context(container["representation"]))
|
||||
return loader.remove(container)
|
||||
return Loader().remove(container)
|
||||
|
||||
|
||||
def update_container(container, version=-1):
|
||||
|
|
@ -498,8 +500,7 @@ def update_container(container, version=-1):
|
|||
.format(container.get("loader"))
|
||||
)
|
||||
|
||||
loader = Loader(get_representation_context(container["representation"]))
|
||||
return loader.update(container, new_representation)
|
||||
return Loader().update(container, new_representation)
|
||||
|
||||
|
||||
def switch_container(container, representation, loader_plugin=None):
|
||||
|
|
@ -635,7 +636,7 @@ def get_representation_path(representation, root=None, dbcon=None):
|
|||
|
||||
root = registered_root()
|
||||
|
||||
def path_from_represenation():
|
||||
def path_from_representation():
|
||||
try:
|
||||
template = representation["data"]["template"]
|
||||
except KeyError:
|
||||
|
|
@ -759,7 +760,7 @@ def get_representation_path(representation, root=None, dbcon=None):
|
|||
return os.path.normpath(path)
|
||||
|
||||
return (
|
||||
path_from_represenation() or
|
||||
path_from_representation() or
|
||||
path_from_config() or
|
||||
path_from_data()
|
||||
)
|
||||
|
|
|
|||
|
|
@ -14,8 +14,9 @@ class CopyFile(load.LoaderPlugin):
|
|||
color = get_default_entity_icon_color()
|
||||
|
||||
def load(self, context, name=None, namespace=None, data=None):
|
||||
self.log.info("Added copy to clipboard: {0}".format(self.fname))
|
||||
self.copy_file_to_clipboard(self.fname)
|
||||
path = self.filepath_from_context(context)
|
||||
self.log.info("Added copy to clipboard: {0}".format(path))
|
||||
self.copy_file_to_clipboard(path)
|
||||
|
||||
@staticmethod
|
||||
def copy_file_to_clipboard(path):
|
||||
|
|
|
|||
|
|
@ -14,8 +14,9 @@ class CopyFilePath(load.LoaderPlugin):
|
|||
color = "#999999"
|
||||
|
||||
def load(self, context, name=None, namespace=None, data=None):
|
||||
self.log.info("Added file path to clipboard: {0}".format(self.fname))
|
||||
self.copy_path_to_clipboard(self.fname)
|
||||
path = self.filepath_from_context(context)
|
||||
self.log.info("Added file path to clipboard: {0}".format(path))
|
||||
self.copy_path_to_clipboard(path)
|
||||
|
||||
@staticmethod
|
||||
def copy_path_to_clipboard(path):
|
||||
|
|
|
|||
|
|
@ -33,9 +33,11 @@ class OpenInDJV(load.LoaderPlugin):
|
|||
color = "orange"
|
||||
|
||||
def load(self, context, name, namespace, data):
|
||||
directory = os.path.dirname(self.fname)
|
||||
import clique
|
||||
|
||||
path = self.filepath_from_context(context)
|
||||
directory = os.path.dirname(path)
|
||||
|
||||
pattern = clique.PATTERNS["frames"]
|
||||
files = os.listdir(directory)
|
||||
collections, remainder = clique.assemble(
|
||||
|
|
@ -48,7 +50,7 @@ class OpenInDJV(load.LoaderPlugin):
|
|||
sequence = collections[0]
|
||||
first_image = list(sequence)[0]
|
||||
else:
|
||||
first_image = self.fname
|
||||
first_image = path
|
||||
filepath = os.path.normpath(os.path.join(directory, first_image))
|
||||
|
||||
self.log.info("Opening : {}".format(filepath))
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class OpenFile(load.LoaderPlugin):
|
|||
|
||||
def load(self, context, name, namespace, data):
|
||||
|
||||
path = self.fname
|
||||
path = self.filepath_from_context(context)
|
||||
if not os.path.exists(path):
|
||||
raise RuntimeError("File not found: {}".format(path))
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ from openpype.pipeline.colorspace import (
|
|||
|
||||
class YourLoader(api.Loader):
|
||||
def load(self, context, name=None, namespace=None, options=None):
|
||||
path = self.fname
|
||||
path = self.filepath_from_context(context)
|
||||
colorspace_data = context["representation"]["data"].get("colorspaceData", {})
|
||||
colorspace = (
|
||||
colorspace_data.get("colorspace")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue