mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Merge pull request #130 from ynput/enhancement/OP-8370_LoaderPlugin-update-expect-representation-context
Chore: Loader plugin expect representation context in methods
This commit is contained in:
commit
1457ec6111
106 changed files with 760 additions and 625 deletions
|
|
@ -56,16 +56,21 @@ class BackgroundLoader(api.AfterEffectsLoader):
|
|||
self.__class__.__name__
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
""" Switch asset or change version """
|
||||
stub = self.get_stub()
|
||||
context = representation.get("context", {})
|
||||
asset_doc = context["asset"]
|
||||
subset_doc = context["subset"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
folder_name = asset_doc["name"]
|
||||
product_name = subset_doc["name"]
|
||||
_ = container.pop("layer")
|
||||
|
||||
# without iterator number (_001, 002...)
|
||||
namespace_from_container = re.sub(r'_\d{3}$', '',
|
||||
container["namespace"])
|
||||
comp_name = "{}_{}".format(context["asset"], context["subset"])
|
||||
comp_name = "{}_{}".format(folder_name, product_name)
|
||||
|
||||
# switching assets
|
||||
if namespace_from_container != comp_name:
|
||||
|
|
@ -73,11 +78,11 @@ class BackgroundLoader(api.AfterEffectsLoader):
|
|||
existing_items = [layer.name for layer in items]
|
||||
comp_name = get_unique_layer_name(
|
||||
existing_items,
|
||||
"{}_{}".format(context["asset"], context["subset"]))
|
||||
"{}_{}".format(folder_name, product_name))
|
||||
else: # switching version - keep same name
|
||||
comp_name = container["namespace"]
|
||||
|
||||
path = get_representation_path(representation)
|
||||
path = get_representation_path(repre_doc)
|
||||
|
||||
layers = get_background_layers(path)
|
||||
comp = stub.reload_background(container["members"][1],
|
||||
|
|
@ -85,8 +90,8 @@ class BackgroundLoader(api.AfterEffectsLoader):
|
|||
layers)
|
||||
|
||||
# update container
|
||||
container["representation"] = str(representation["_id"])
|
||||
container["name"] = context["subset"]
|
||||
container["representation"] = str(repre_doc["_id"])
|
||||
container["name"] = product_name
|
||||
container["namespace"] = comp_name
|
||||
container["members"] = comp.members
|
||||
|
||||
|
|
@ -104,5 +109,5 @@ class BackgroundLoader(api.AfterEffectsLoader):
|
|||
stub.imprint(layer.id, {})
|
||||
stub.delete_item(layer.id)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
|
|
|||
|
|
@ -64,31 +64,36 @@ class FileLoader(api.AfterEffectsLoader):
|
|||
self.__class__.__name__
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
""" Switch asset or change version """
|
||||
stub = self.get_stub()
|
||||
layer = container.pop("layer")
|
||||
|
||||
context = representation.get("context", {})
|
||||
asset_doc = context["asset"]
|
||||
subset_doc = context["subset"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
folder_name = asset_doc["name"]
|
||||
product_name = subset_doc["name"]
|
||||
|
||||
namespace_from_container = re.sub(r'_\d{3}$', '',
|
||||
container["namespace"])
|
||||
layer_name = "{}_{}".format(context["asset"], context["subset"])
|
||||
layer_name = "{}_{}".format(folder_name, product_name)
|
||||
# switching assets
|
||||
if namespace_from_container != layer_name:
|
||||
layers = stub.get_items(comps=True)
|
||||
existing_layers = [layer.name for layer in layers]
|
||||
layer_name = get_unique_layer_name(
|
||||
existing_layers,
|
||||
"{}_{}".format(context["asset"], context["subset"]))
|
||||
"{}_{}".format(folder_name, product_name))
|
||||
else: # switching version - keep same name
|
||||
layer_name = container["namespace"]
|
||||
path = get_representation_path(representation)
|
||||
path = get_representation_path(repre_doc)
|
||||
# with aftereffects.maintained_selection(): # TODO
|
||||
stub.replace_item(layer.id, path, stub.LOADED_ICON + layer_name)
|
||||
stub.imprint(
|
||||
layer.id, {"representation": str(representation["_id"]),
|
||||
"name": context["subset"],
|
||||
layer.id, {"representation": str(repre_doc["_id"]),
|
||||
"name": product_name,
|
||||
"namespace": layer_name}
|
||||
)
|
||||
|
||||
|
|
@ -103,5 +108,5 @@ class FileLoader(api.AfterEffectsLoader):
|
|||
stub.imprint(layer.id, {})
|
||||
stub.delete_item(layer.id)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
|
|
|||
|
|
@ -506,13 +506,13 @@ class AssetLoader(LoaderPlugin):
|
|||
|
||||
# return self._get_instance_collection(instance_name, nodes)
|
||||
|
||||
def exec_update(self, container: Dict, representation: Dict):
|
||||
def exec_update(self, container: Dict, context: Dict):
|
||||
"""Must be implemented by a sub-class"""
|
||||
raise NotImplementedError("Must be implemented by a sub-class")
|
||||
|
||||
def update(self, container: Dict, representation: Dict):
|
||||
def update(self, container: Dict, context: Dict):
|
||||
""" Run the update on Blender main thread"""
|
||||
mti = MainThreadItem(self.exec_update, container, representation)
|
||||
mti = MainThreadItem(self.exec_update, container, context)
|
||||
execute_in_main_thread(mti)
|
||||
|
||||
def exec_remove(self, container: Dict) -> bool:
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ class CacheModelLoader(plugin.AssetLoader):
|
|||
self[:] = objects
|
||||
return objects
|
||||
|
||||
def exec_update(self, container: Dict, representation: Dict):
|
||||
def exec_update(self, container: Dict, context: Dict):
|
||||
"""Update the loaded asset.
|
||||
|
||||
This will remove all objects of the current collection, load the new
|
||||
|
|
@ -191,15 +191,16 @@ class CacheModelLoader(plugin.AssetLoader):
|
|||
Warning:
|
||||
No nested collections are supported at the moment!
|
||||
"""
|
||||
repre_doc = context["representation"]
|
||||
object_name = container["objectName"]
|
||||
asset_group = bpy.data.objects.get(object_name)
|
||||
libpath = Path(get_representation_path(representation))
|
||||
libpath = Path(get_representation_path(repre_doc))
|
||||
extension = libpath.suffix.lower()
|
||||
|
||||
self.log.info(
|
||||
"Container: %s\nRepresentation: %s",
|
||||
pformat(container, indent=2),
|
||||
pformat(representation, indent=2),
|
||||
pformat(repre_doc, indent=2),
|
||||
)
|
||||
|
||||
assert asset_group, (
|
||||
|
|
@ -244,7 +245,7 @@ class CacheModelLoader(plugin.AssetLoader):
|
|||
asset_group.matrix_basis = mat
|
||||
|
||||
metadata["libpath"] = str(libpath)
|
||||
metadata["representation"] = str(representation["_id"])
|
||||
metadata["representation"] = str(repre_doc["_id"])
|
||||
|
||||
def exec_remove(self, container: Dict) -> bool:
|
||||
"""Remove an existing container from a Blender scene.
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ class BlendActionLoader(plugin.AssetLoader):
|
|||
self[:] = nodes
|
||||
return nodes
|
||||
|
||||
def update(self, container: Dict, representation: Dict):
|
||||
def update(self, container: Dict, context: Dict):
|
||||
"""Update the loaded asset.
|
||||
|
||||
This will remove all objects of the current collection, load the new
|
||||
|
|
@ -126,18 +126,18 @@ class BlendActionLoader(plugin.AssetLoader):
|
|||
Warning:
|
||||
No nested collections are supported at the moment!
|
||||
"""
|
||||
|
||||
repre_doc = context["representation"]
|
||||
collection = bpy.data.collections.get(
|
||||
container["objectName"]
|
||||
)
|
||||
|
||||
libpath = Path(get_representation_path(representation))
|
||||
libpath = Path(get_representation_path(repre_doc))
|
||||
extension = libpath.suffix.lower()
|
||||
|
||||
logger.info(
|
||||
"Container: %s\nRepresentation: %s",
|
||||
pformat(container, indent=2),
|
||||
pformat(representation, indent=2),
|
||||
pformat(repre_doc, indent=2),
|
||||
)
|
||||
|
||||
assert collection, (
|
||||
|
|
@ -241,7 +241,7 @@ class BlendActionLoader(plugin.AssetLoader):
|
|||
# Save the list of objects in the metadata container
|
||||
collection_metadata["objects"] = objects_list
|
||||
collection_metadata["libpath"] = str(libpath)
|
||||
collection_metadata["representation"] = str(representation["_id"])
|
||||
collection_metadata["representation"] = str(repre_doc["_id"])
|
||||
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class AudioLoader(plugin.AssetLoader):
|
|||
self[:] = objects
|
||||
return [objects]
|
||||
|
||||
def exec_update(self, container: Dict, representation: Dict):
|
||||
def exec_update(self, container: Dict, context: Dict):
|
||||
"""Update an audio strip in the sequence editor.
|
||||
|
||||
Arguments:
|
||||
|
|
@ -105,14 +105,15 @@ class AudioLoader(plugin.AssetLoader):
|
|||
representation (openpype:representation-1.0): Representation to
|
||||
update, from `host.ls()`.
|
||||
"""
|
||||
repre_doc = context["representation"]
|
||||
object_name = container["objectName"]
|
||||
asset_group = bpy.data.objects.get(object_name)
|
||||
libpath = Path(get_representation_path(representation))
|
||||
libpath = Path(get_representation_path(repre_doc))
|
||||
|
||||
self.log.info(
|
||||
"Container: %s\nRepresentation: %s",
|
||||
pformat(container, indent=2),
|
||||
pformat(representation, indent=2),
|
||||
pformat(repre_doc, indent=2),
|
||||
)
|
||||
|
||||
assert asset_group, (
|
||||
|
|
@ -175,8 +176,8 @@ class AudioLoader(plugin.AssetLoader):
|
|||
window_manager.windows[-1].screen.areas[0].type = old_type
|
||||
|
||||
metadata["libpath"] = str(libpath)
|
||||
metadata["representation"] = str(representation["_id"])
|
||||
metadata["parent"] = str(representation["parent"])
|
||||
metadata["representation"] = str(repre_doc["_id"])
|
||||
metadata["parent"] = str(repre_doc["parent"])
|
||||
metadata["audio"] = new_audio
|
||||
|
||||
def exec_remove(self, container: Dict) -> bool:
|
||||
|
|
|
|||
|
|
@ -181,13 +181,14 @@ class BlendLoader(plugin.AssetLoader):
|
|||
self[:] = objects
|
||||
return objects
|
||||
|
||||
def exec_update(self, container: Dict, representation: Dict):
|
||||
def exec_update(self, container: Dict, context: Dict):
|
||||
"""
|
||||
Update the loaded asset.
|
||||
"""
|
||||
repre_doc = context["representation"]
|
||||
group_name = container["objectName"]
|
||||
asset_group = bpy.data.objects.get(group_name)
|
||||
libpath = Path(get_representation_path(representation)).as_posix()
|
||||
libpath = Path(get_representation_path(repre_doc)).as_posix()
|
||||
|
||||
assert asset_group, (
|
||||
f"The asset is not loaded: {container['objectName']}"
|
||||
|
|
@ -234,8 +235,8 @@ class BlendLoader(plugin.AssetLoader):
|
|||
|
||||
new_data = {
|
||||
"libpath": libpath,
|
||||
"representation": str(representation["_id"]),
|
||||
"parent": str(representation["parent"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"parent": str(repre_doc["parent"]),
|
||||
"members": members,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,13 +133,14 @@ class BlendSceneLoader(plugin.AssetLoader):
|
|||
self[:] = objects
|
||||
return objects
|
||||
|
||||
def exec_update(self, container: Dict, representation: Dict):
|
||||
def exec_update(self, container: Dict, context: Dict):
|
||||
"""
|
||||
Update the loaded asset.
|
||||
"""
|
||||
repre_doc = context["representation"]
|
||||
group_name = container["objectName"]
|
||||
asset_group = bpy.data.collections.get(group_name)
|
||||
libpath = Path(get_representation_path(representation)).as_posix()
|
||||
libpath = Path(get_representation_path(repre_doc)).as_posix()
|
||||
|
||||
assert asset_group, (
|
||||
f"The asset is not loaded: {container['objectName']}"
|
||||
|
|
@ -201,8 +202,8 @@ class BlendSceneLoader(plugin.AssetLoader):
|
|||
|
||||
new_data = {
|
||||
"libpath": libpath,
|
||||
"representation": str(representation["_id"]),
|
||||
"parent": str(representation["parent"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"parent": str(repre_doc["parent"]),
|
||||
"members": members,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ class AbcCameraLoader(plugin.AssetLoader):
|
|||
self[:] = objects
|
||||
return objects
|
||||
|
||||
def exec_update(self, container: Dict, representation: Dict):
|
||||
def exec_update(self, container: Dict, context: Dict):
|
||||
"""Update the loaded asset.
|
||||
|
||||
This will remove all objects of the current collection, load the new
|
||||
|
|
@ -142,15 +142,16 @@ class AbcCameraLoader(plugin.AssetLoader):
|
|||
Warning:
|
||||
No nested collections are supported at the moment!
|
||||
"""
|
||||
repre_doc = context["representation"]
|
||||
object_name = container["objectName"]
|
||||
asset_group = bpy.data.objects.get(object_name)
|
||||
libpath = Path(get_representation_path(representation))
|
||||
libpath = Path(get_representation_path(repre_doc))
|
||||
extension = libpath.suffix.lower()
|
||||
|
||||
self.log.info(
|
||||
"Container: %s\nRepresentation: %s",
|
||||
pformat(container, indent=2),
|
||||
pformat(representation, indent=2),
|
||||
pformat(repre_doc, indent=2),
|
||||
)
|
||||
|
||||
assert asset_group, (
|
||||
|
|
@ -185,7 +186,7 @@ class AbcCameraLoader(plugin.AssetLoader):
|
|||
asset_group.matrix_basis = mat
|
||||
|
||||
metadata["libpath"] = str(libpath)
|
||||
metadata["representation"] = str(representation["_id"])
|
||||
metadata["representation"] = str(repre_doc["_id"])
|
||||
|
||||
def exec_remove(self, container: Dict) -> bool:
|
||||
"""Remove an existing container from a Blender scene.
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ class FbxCameraLoader(plugin.AssetLoader):
|
|||
self[:] = objects
|
||||
return objects
|
||||
|
||||
def exec_update(self, container: Dict, representation: Dict):
|
||||
def exec_update(self, container: Dict, context: Dict):
|
||||
"""Update the loaded asset.
|
||||
|
||||
This will remove all objects of the current collection, load the new
|
||||
|
|
@ -145,15 +145,16 @@ class FbxCameraLoader(plugin.AssetLoader):
|
|||
Warning:
|
||||
No nested collections are supported at the moment!
|
||||
"""
|
||||
repre_doc = context["representation"]
|
||||
object_name = container["objectName"]
|
||||
asset_group = bpy.data.objects.get(object_name)
|
||||
libpath = Path(get_representation_path(representation))
|
||||
libpath = Path(get_representation_path(repre_doc))
|
||||
extension = libpath.suffix.lower()
|
||||
|
||||
self.log.info(
|
||||
"Container: %s\nRepresentation: %s",
|
||||
pformat(container, indent=2),
|
||||
pformat(representation, indent=2),
|
||||
pformat(repre_doc, indent=2),
|
||||
)
|
||||
|
||||
assert asset_group, (
|
||||
|
|
@ -195,7 +196,7 @@ class FbxCameraLoader(plugin.AssetLoader):
|
|||
asset_group.matrix_basis = mat
|
||||
|
||||
metadata["libpath"] = str(libpath)
|
||||
metadata["representation"] = str(representation["_id"])
|
||||
metadata["representation"] = str(repre_doc["_id"])
|
||||
|
||||
def exec_remove(self, container: Dict) -> bool:
|
||||
"""Remove an existing container from a Blender scene.
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ class FbxModelLoader(plugin.AssetLoader):
|
|||
self[:] = objects
|
||||
return objects
|
||||
|
||||
def exec_update(self, container: Dict, representation: Dict):
|
||||
def exec_update(self, container: Dict, context: Dict):
|
||||
"""Update the loaded asset.
|
||||
|
||||
This will remove all objects of the current collection, load the new
|
||||
|
|
@ -189,15 +189,16 @@ class FbxModelLoader(plugin.AssetLoader):
|
|||
Warning:
|
||||
No nested collections are supported at the moment!
|
||||
"""
|
||||
repre_doc = context["representation"]
|
||||
object_name = container["objectName"]
|
||||
asset_group = bpy.data.objects.get(object_name)
|
||||
libpath = Path(get_representation_path(representation))
|
||||
libpath = Path(get_representation_path(repre_doc))
|
||||
extension = libpath.suffix.lower()
|
||||
|
||||
self.log.info(
|
||||
"Container: %s\nRepresentation: %s",
|
||||
pformat(container, indent=2),
|
||||
pformat(representation, indent=2),
|
||||
pformat(repre_doc, indent=2),
|
||||
)
|
||||
|
||||
assert asset_group, (
|
||||
|
|
@ -250,7 +251,7 @@ class FbxModelLoader(plugin.AssetLoader):
|
|||
asset_group.matrix_basis = mat
|
||||
|
||||
metadata["libpath"] = str(libpath)
|
||||
metadata["representation"] = str(representation["_id"])
|
||||
metadata["representation"] = str(repre_doc["_id"])
|
||||
|
||||
def exec_remove(self, container: Dict) -> bool:
|
||||
"""Remove an existing container from a Blender scene.
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ class JsonLayoutLoader(plugin.AssetLoader):
|
|||
self[:] = asset_group.children
|
||||
return asset_group.children
|
||||
|
||||
def exec_update(self, container: Dict, representation: Dict):
|
||||
def exec_update(self, container: Dict, context: Dict):
|
||||
"""Update the loaded asset.
|
||||
|
||||
This will remove all objects of the current collection, load the new
|
||||
|
|
@ -197,15 +197,16 @@ class JsonLayoutLoader(plugin.AssetLoader):
|
|||
will not be removed, only unlinked. Normally this should not be the
|
||||
case though.
|
||||
"""
|
||||
repre_doc = context["representation"]
|
||||
object_name = container["objectName"]
|
||||
asset_group = bpy.data.objects.get(object_name)
|
||||
libpath = Path(get_representation_path(representation))
|
||||
libpath = Path(get_representation_path(repre_doc))
|
||||
extension = libpath.suffix.lower()
|
||||
|
||||
self.log.info(
|
||||
"Container: %s\nRepresentation: %s",
|
||||
pformat(container, indent=2),
|
||||
pformat(representation, indent=2),
|
||||
pformat(repre_doc, indent=2),
|
||||
)
|
||||
|
||||
assert asset_group, (
|
||||
|
|
@ -269,7 +270,7 @@ class JsonLayoutLoader(plugin.AssetLoader):
|
|||
asset_group.matrix_basis = mat
|
||||
|
||||
metadata["libpath"] = str(libpath)
|
||||
metadata["representation"] = str(representation["_id"])
|
||||
metadata["representation"] = str(repre_doc["_id"])
|
||||
|
||||
def exec_remove(self, container: Dict) -> bool:
|
||||
"""Remove an existing container from a Blender scene.
|
||||
|
|
|
|||
|
|
@ -138,15 +138,16 @@ class BlendLookLoader(plugin.AssetLoader):
|
|||
self[:] = nodes
|
||||
return nodes
|
||||
|
||||
def update(self, container: Dict, representation: Dict):
|
||||
def update(self, container: Dict, context: Dict):
|
||||
collection = bpy.data.collections.get(container["objectName"])
|
||||
libpath = Path(get_representation_path(representation))
|
||||
repre_doc = context["representation"]
|
||||
libpath = Path(get_representation_path(repre_doc))
|
||||
extension = libpath.suffix.lower()
|
||||
|
||||
self.log.info(
|
||||
"Container: %s\nRepresentation: %s",
|
||||
pformat(container, indent=2),
|
||||
pformat(representation, indent=2),
|
||||
pformat(repre_doc, indent=2),
|
||||
)
|
||||
|
||||
assert collection, (
|
||||
|
|
@ -201,7 +202,7 @@ class BlendLookLoader(plugin.AssetLoader):
|
|||
collection_metadata["objects"] = objects
|
||||
collection_metadata["materials"] = materials
|
||||
collection_metadata["libpath"] = str(libpath)
|
||||
collection_metadata["representation"] = str(representation["_id"])
|
||||
collection_metadata["representation"] = str(repre_doc["_id"])
|
||||
|
||||
def remove(self, container: Dict) -> bool:
|
||||
collection = bpy.data.collections.get(container["objectName"])
|
||||
|
|
|
|||
|
|
@ -180,27 +180,27 @@ class LoadClip(opfapi.ClipLoader):
|
|||
# unwrapping segment from input clip
|
||||
pass
|
||||
|
||||
# def switch(self, container, representation):
|
||||
# self.update(container, representation)
|
||||
# def switch(self, container, context):
|
||||
# self.update(container, context)
|
||||
|
||||
# def update(self, container, representation):
|
||||
# def update(self, container, context):
|
||||
# """ Updating previously loaded clips
|
||||
# """
|
||||
|
||||
# # load clip to timeline and get main variables
|
||||
# repre_doc = context['representation']
|
||||
# name = container['name']
|
||||
# namespace = container['namespace']
|
||||
# track_item = phiero.get_track_items(
|
||||
# track_item_name=namespace)
|
||||
# version = io.find_one({
|
||||
# "type": "version",
|
||||
# "_id": representation["parent"]
|
||||
# "_id": repre_doc["parent"]
|
||||
# })
|
||||
# version_data = version.get("data", {})
|
||||
# version_name = version.get("name", None)
|
||||
# colorspace = version_data.get("colorspace", None)
|
||||
# object_name = "{}_{}".format(name, namespace)
|
||||
# file = get_representation_path(representation).replace("\\", "/")
|
||||
# file = get_representation_path(repre_doc).replace("\\", "/")
|
||||
# clip = track_item.source()
|
||||
|
||||
# # reconnect media to new path
|
||||
|
|
@ -225,7 +225,7 @@ class LoadClip(opfapi.ClipLoader):
|
|||
|
||||
# # add variables related to version context
|
||||
# data_imprint.update({
|
||||
# "representation": str(representation["_id"]),
|
||||
# "representation": str(repre_doc["_id"]),
|
||||
# "version": version_name,
|
||||
# "colorspace": colorspace,
|
||||
# "objectName": object_name
|
||||
|
|
|
|||
|
|
@ -44,23 +44,24 @@ class FusionLoadAlembicMesh(load.LoaderPlugin):
|
|||
context=context,
|
||||
loader=self.__class__.__name__)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update Alembic path"""
|
||||
|
||||
tool = container["_tool"]
|
||||
assert tool.ID == self.tool_type, f"Must be {self.tool_type}"
|
||||
comp = tool.Comp()
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
|
||||
with comp_lock_and_undo_chunk(comp, "Update tool"):
|
||||
tool["Filename"] = path
|
||||
|
||||
# Update the imprinted representation
|
||||
tool.SetData("avalon.representation", str(representation["_id"]))
|
||||
tool.SetData("avalon.representation", str(repre_doc["_id"]))
|
||||
|
||||
def remove(self, container):
|
||||
tool = container["_tool"]
|
||||
|
|
|
|||
|
|
@ -59,23 +59,24 @@ class FusionLoadFBXMesh(load.LoaderPlugin):
|
|||
loader=self.__class__.__name__,
|
||||
)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update path"""
|
||||
|
||||
tool = container["_tool"]
|
||||
assert tool.ID == self.tool_type, f"Must be {self.tool_type}"
|
||||
comp = tool.Comp()
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
|
||||
with comp_lock_and_undo_chunk(comp, "Update tool"):
|
||||
tool["ImportFile"] = path
|
||||
|
||||
# Update the imprinted representation
|
||||
tool.SetData("avalon.representation", str(representation["_id"]))
|
||||
tool.SetData("avalon.representation", str(repre_doc["_id"]))
|
||||
|
||||
def remove(self, container):
|
||||
tool = container["_tool"]
|
||||
|
|
|
|||
|
|
@ -175,10 +175,10 @@ class FusionLoadSequence(load.LoaderPlugin):
|
|||
loader=self.__class__.__name__,
|
||||
)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update the Loader's path
|
||||
|
||||
Fusion automatically tries to reset some variables when changing
|
||||
|
|
@ -224,7 +224,8 @@ class FusionLoadSequence(load.LoaderPlugin):
|
|||
assert tool.ID == "Loader", "Must be Loader"
|
||||
comp = tool.Comp()
|
||||
|
||||
context = get_representation_context(representation)
|
||||
repre_doc = context["representation"]
|
||||
context = get_representation_context(repre_doc)
|
||||
path = self.filepath_from_context(context)
|
||||
|
||||
# Get start frame from version data
|
||||
|
|
@ -255,7 +256,7 @@ class FusionLoadSequence(load.LoaderPlugin):
|
|||
)
|
||||
|
||||
# Update the imprinted representation
|
||||
tool.SetData("avalon.representation", str(representation["_id"]))
|
||||
tool.SetData("avalon.representation", str(repre_doc["_id"]))
|
||||
|
||||
def remove(self, container):
|
||||
tool = container["_tool"]
|
||||
|
|
|
|||
|
|
@ -60,22 +60,23 @@ class FusionLoadUSD(load.LoaderPlugin):
|
|||
context=context,
|
||||
loader=self.__class__.__name__)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
|
||||
tool = container["_tool"]
|
||||
assert tool.ID == self.tool_type, f"Must be {self.tool_type}"
|
||||
comp = tool.Comp()
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
|
||||
with comp_lock_and_undo_chunk(comp, "Update tool"):
|
||||
tool["Filename"] = path
|
||||
|
||||
# Update the imprinted representation
|
||||
tool.SetData("avalon.representation", str(representation["_id"]))
|
||||
tool.SetData("avalon.representation", str(repre_doc["_id"]))
|
||||
|
||||
def remove(self, container):
|
||||
tool = container["_tool"]
|
||||
|
|
|
|||
|
|
@ -611,11 +611,12 @@ class ImageSequenceLoader(load.LoaderPlugin):
|
|||
self.__class__.__name__
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
node = container.pop("node")
|
||||
|
||||
repre_doc = context["representation"]
|
||||
project_name = get_current_project_name()
|
||||
version = get_version_by_id(project_name, representation["parent"])
|
||||
version = get_version_by_id(project_name, repre_doc["parent"])
|
||||
files = []
|
||||
for f in version["data"]["files"]:
|
||||
files.append(
|
||||
|
|
@ -632,7 +633,7 @@ class ImageSequenceLoader(load.LoaderPlugin):
|
|||
)
|
||||
|
||||
harmony.imprint(
|
||||
node, {"representation": str(representation["_id"])}
|
||||
node, {"representation": str(repre_doc["_id"])}
|
||||
)
|
||||
|
||||
def remove(self, container):
|
||||
|
|
@ -648,8 +649,8 @@ class ImageSequenceLoader(load.LoaderPlugin):
|
|||
{"function": func, "args": [node]}
|
||||
)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
```
|
||||
|
||||
## Resources
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class ImportAudioLoader(load.LoaderPlugin):
|
|||
self.__class__.__name__
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
pass
|
||||
|
||||
def remove(self, container):
|
||||
|
|
|
|||
|
|
@ -280,8 +280,9 @@ class BackgroundLoader(load.LoaderPlugin):
|
|||
nodes=container_nodes
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
path = get_representation_path(representation)
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
with open(path) as json_file:
|
||||
data = json.load(json_file)
|
||||
|
||||
|
|
@ -301,7 +302,7 @@ class BackgroundLoader(load.LoaderPlugin):
|
|||
|
||||
print(container)
|
||||
|
||||
is_latest = is_representation_from_latest(representation)
|
||||
is_latest = is_representation_from_latest(repre_doc)
|
||||
for layer in sorted(layers):
|
||||
file_to_import = [
|
||||
os.path.join(bg_folder, layer).replace("\\", "/")
|
||||
|
|
@ -351,8 +352,11 @@ class BackgroundLoader(load.LoaderPlugin):
|
|||
harmony.send({"function": func, "args": [node, "red"]})
|
||||
|
||||
harmony.imprint(
|
||||
container['name'], {"representation": str(representation["_id"]),
|
||||
"nodes": container['nodes']}
|
||||
container['name'],
|
||||
{
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"nodes": container["nodes"]
|
||||
}
|
||||
)
|
||||
|
||||
def remove(self, container):
|
||||
|
|
@ -369,5 +373,5 @@ class BackgroundLoader(load.LoaderPlugin):
|
|||
)
|
||||
harmony.imprint(container['name'], {}, remove=True)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
|
|
|||
|
|
@ -72,18 +72,19 @@ class ImageSequenceLoader(load.LoaderPlugin):
|
|||
nodes=[read_node]
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update loaded containers.
|
||||
|
||||
Args:
|
||||
container (dict): Container data.
|
||||
representation (dict): Representation data.
|
||||
context (dict): Representation context data.
|
||||
|
||||
"""
|
||||
self_name = self.__class__.__name__
|
||||
node = container.get("nodes").pop()
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
collections, remainder = clique.assemble(
|
||||
os.listdir(os.path.dirname(path))
|
||||
)
|
||||
|
|
@ -110,7 +111,7 @@ class ImageSequenceLoader(load.LoaderPlugin):
|
|||
)
|
||||
|
||||
# Colour node.
|
||||
if is_representation_from_latest(representation):
|
||||
if is_representation_from_latest(repre_doc):
|
||||
harmony.send(
|
||||
{
|
||||
"function": "PypeHarmony.setColor",
|
||||
|
|
@ -124,7 +125,7 @@ class ImageSequenceLoader(load.LoaderPlugin):
|
|||
})
|
||||
|
||||
harmony.imprint(
|
||||
node, {"representation": str(representation["_id"])}
|
||||
node, {"representation": str(repre_doc["_id"])}
|
||||
)
|
||||
|
||||
def remove(self, container):
|
||||
|
|
@ -140,6 +141,6 @@ class ImageSequenceLoader(load.LoaderPlugin):
|
|||
)
|
||||
harmony.imprint(node, {}, remove=True)
|
||||
|
||||
def switch(self, container, representation):
|
||||
def switch(self, container, context):
|
||||
"""Switch loaded representations."""
|
||||
self.update(container, representation)
|
||||
self.update(container, context)
|
||||
|
|
|
|||
|
|
@ -26,15 +26,17 @@ class ImportPaletteLoader(load.LoaderPlugin):
|
|||
self.__class__.__name__
|
||||
)
|
||||
|
||||
def load_palette(self, representation):
|
||||
product_name = representation["context"]["subset"]
|
||||
def load_palette(self, context):
|
||||
subset_doc = context["subset"]
|
||||
repre_doc = context["representation"]
|
||||
product_name = subset_doc["name"]
|
||||
name = product_name.replace("palette", "")
|
||||
|
||||
# Overwrite palette on disk.
|
||||
scene_path = harmony.send(
|
||||
{"function": "scene.currentProjectPath"}
|
||||
)["result"]
|
||||
src = get_representation_path(representation)
|
||||
src = get_representation_path(repre_doc)
|
||||
dst = os.path.join(
|
||||
scene_path,
|
||||
"palette-library",
|
||||
|
|
@ -59,13 +61,14 @@ class ImportPaletteLoader(load.LoaderPlugin):
|
|||
def remove(self, container):
|
||||
harmony.remove(container["name"])
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
self.remove(container)
|
||||
name = self.load_palette(representation)
|
||||
name = self.load_palette(context)
|
||||
|
||||
container["representation"] = str(representation["_id"])
|
||||
repre_doc = context["representation"]
|
||||
container["representation"] = str(repre_doc["_id"])
|
||||
container["name"] = name
|
||||
harmony.imprint(name, container)
|
||||
|
|
|
|||
|
|
@ -70,19 +70,20 @@ class TemplateLoader(load.LoaderPlugin):
|
|||
self_name
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update loaded containers.
|
||||
|
||||
Args:
|
||||
container (dict): Container data.
|
||||
representation (dict): Representation data.
|
||||
context (dict): Representation context data.
|
||||
|
||||
"""
|
||||
node_name = container["name"]
|
||||
node = harmony.find_node_by_name(node_name, "GROUP")
|
||||
self_name = self.__class__.__name__
|
||||
|
||||
if is_representation_from_latest(representation):
|
||||
repre_doc = context["representation"]
|
||||
if is_representation_from_latest(repre_doc):
|
||||
self._set_green(node)
|
||||
else:
|
||||
self._set_red(node)
|
||||
|
|
@ -110,7 +111,7 @@ class TemplateLoader(load.LoaderPlugin):
|
|||
None, container["data"])
|
||||
|
||||
harmony.imprint(
|
||||
node, {"representation": str(representation["_id"])}
|
||||
node, {"representation": str(repre_doc["_id"])}
|
||||
)
|
||||
|
||||
def remove(self, container):
|
||||
|
|
@ -125,9 +126,9 @@ class TemplateLoader(load.LoaderPlugin):
|
|||
{"function": "PypeHarmony.deleteNode", "args": [node]}
|
||||
)
|
||||
|
||||
def switch(self, container, representation):
|
||||
def switch(self, container, context):
|
||||
"""Switch representation containers."""
|
||||
self.update(container, representation)
|
||||
self.update(container, context)
|
||||
|
||||
def _set_green(self, node):
|
||||
"""Set node color to green `rgba(0, 255, 0, 255)`."""
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class ImportTemplateLoader(load.LoaderPlugin):
|
|||
self.__class__.__name__
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
pass
|
||||
|
||||
def remove(self, container):
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@ class SequenceLoader(LoaderPlugin):
|
|||
):
|
||||
pass
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update an existing `container`
|
||||
"""
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -146,27 +146,25 @@ class LoadClip(phiero.SequenceLoader):
|
|||
self.__class__.__name__,
|
||||
data_imprint)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
""" Updating previously loaded clips
|
||||
"""
|
||||
|
||||
version_doc = context["version"]
|
||||
repre_doc = context["representation"]
|
||||
# load clip to timeline and get main variables
|
||||
name = container['name']
|
||||
namespace = container['namespace']
|
||||
track_item = phiero.get_track_items(
|
||||
track_item_name=namespace).pop()
|
||||
|
||||
project_name = get_current_project_name()
|
||||
version_doc = get_version_by_id(project_name, representation["parent"])
|
||||
|
||||
version_data = version_doc.get("data", {})
|
||||
version_name = version_doc.get("name", None)
|
||||
colorspace = version_data.get("colorspace", None)
|
||||
object_name = "{}_{}".format(name, namespace)
|
||||
file = get_representation_path(representation).replace("\\", "/")
|
||||
file = get_representation_path(repre_doc).replace("\\", "/")
|
||||
clip = track_item.source()
|
||||
|
||||
# reconnect media to new path
|
||||
|
|
@ -191,7 +189,7 @@ class LoadClip(phiero.SequenceLoader):
|
|||
|
||||
# add variables related to version context
|
||||
data_imprint.update({
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"version": version_name,
|
||||
"colorspace": colorspace,
|
||||
"objectName": object_name
|
||||
|
|
|
|||
|
|
@ -157,19 +157,19 @@ class LoadEffects(load.LoaderPlugin):
|
|||
|
||||
return loaded
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
""" Updating previously loaded effects
|
||||
"""
|
||||
version_doc = context["version"]
|
||||
repre_doc = context["representation"]
|
||||
active_track = container["_item"]
|
||||
file = get_representation_path(representation).replace("\\", "/")
|
||||
file = get_representation_path(repre_doc).replace("\\", "/")
|
||||
|
||||
# get main variables
|
||||
name = container['name']
|
||||
namespace = container['namespace']
|
||||
|
||||
# get timeline in out data
|
||||
project_name = get_current_project_name()
|
||||
version_doc = get_version_by_id(project_name, representation["parent"])
|
||||
version_data = version_doc["data"]
|
||||
clip_in = version_data["clipIn"]
|
||||
clip_out = version_data["clipOut"]
|
||||
|
|
@ -197,7 +197,7 @@ class LoadEffects(load.LoaderPlugin):
|
|||
data_imprint = {
|
||||
"objectName": object_name,
|
||||
"name": name,
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"children_names": []
|
||||
}
|
||||
|
||||
|
|
@ -256,8 +256,8 @@ class LoadEffects(load.LoaderPlugin):
|
|||
else:
|
||||
return input
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ class AbcLoader(load.LoaderPlugin):
|
|||
suffix="",
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
node = container["node"]
|
||||
try:
|
||||
alembic_node = next(
|
||||
|
|
@ -93,18 +93,18 @@ class AbcLoader(load.LoaderPlugin):
|
|||
return
|
||||
|
||||
# Update the file path
|
||||
file_path = get_representation_path(representation)
|
||||
file_path = get_representation_path(repre_doc)
|
||||
file_path = file_path.replace("\\", "/")
|
||||
|
||||
alembic_node.setParms({"fileName": file_path})
|
||||
|
||||
# Update attribute
|
||||
node.setParms({"representation": str(representation["_id"])})
|
||||
node.setParms({"representation": str(repre_doc["_id"])})
|
||||
|
||||
def remove(self, container):
|
||||
|
||||
node = container["node"]
|
||||
node.destroy()
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
|
|
|||
|
|
@ -55,17 +55,17 @@ class AbcArchiveLoader(load.LoaderPlugin):
|
|||
self.__class__.__name__,
|
||||
suffix="")
|
||||
|
||||
def update(self, container, representation):
|
||||
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
node = container["node"]
|
||||
|
||||
# Update the file path
|
||||
file_path = get_representation_path(representation)
|
||||
file_path = get_representation_path(repre_doc)
|
||||
file_path = file_path.replace("\\", "/")
|
||||
|
||||
# Update attributes
|
||||
node.setParms({"fileName": file_path,
|
||||
"representation": str(representation["_id"])})
|
||||
"representation": str(repre_doc["_id"])})
|
||||
|
||||
# Rebuild
|
||||
node.parm("buildHierarchy").pressButton()
|
||||
|
|
@ -75,5 +75,5 @@ class AbcArchiveLoader(load.LoaderPlugin):
|
|||
node = container["node"]
|
||||
node.destroy()
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
|
|
|||
|
|
@ -48,13 +48,14 @@ class AssLoader(load.LoaderPlugin):
|
|||
suffix="",
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
# Update the file path
|
||||
repre_doc = context["representation"]
|
||||
procedural = container["node"]
|
||||
procedural.setParms({"ar_filename": self.format_path(representation)})
|
||||
procedural.setParms({"ar_filename": self.format_path(repre_doc)})
|
||||
|
||||
# Update attribute
|
||||
procedural.setParms({"representation": str(representation["_id"])})
|
||||
procedural.setParms({"representation": str(repre_doc["_id"])})
|
||||
|
||||
def remove(self, container):
|
||||
node = container["node"]
|
||||
|
|
@ -86,5 +87,5 @@ class AssLoader(load.LoaderPlugin):
|
|||
|
||||
return os.path.normpath(path).replace("\\", "/")
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ class BgeoLoader(load.LoaderPlugin):
|
|||
|
||||
return filename
|
||||
|
||||
def update(self, container, representation):
|
||||
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
node = container["node"]
|
||||
try:
|
||||
file_node = next(
|
||||
|
|
@ -94,18 +94,18 @@ class BgeoLoader(load.LoaderPlugin):
|
|||
return
|
||||
|
||||
# Update the file path
|
||||
file_path = get_representation_path(representation)
|
||||
file_path = self.format_path(file_path, representation)
|
||||
file_path = get_representation_path(repre_doc)
|
||||
file_path = self.format_path(file_path, repre_doc)
|
||||
|
||||
file_node.setParms({"file": file_path})
|
||||
|
||||
# Update attribute
|
||||
node.setParms({"representation": str(representation["_id"])})
|
||||
node.setParms({"representation": str(repre_doc["_id"])})
|
||||
|
||||
def remove(self, container):
|
||||
|
||||
node = container["node"]
|
||||
node.destroy()
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
|
|
|||
|
|
@ -132,17 +132,17 @@ class CameraLoader(load.LoaderPlugin):
|
|||
self.__class__.__name__,
|
||||
suffix="")
|
||||
|
||||
def update(self, container, representation):
|
||||
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
node = container["node"]
|
||||
|
||||
# Update the file path
|
||||
file_path = get_representation_path(representation)
|
||||
file_path = get_representation_path(repre_doc)
|
||||
file_path = file_path.replace("\\", "/")
|
||||
|
||||
# Update attributes
|
||||
node.setParms({"fileName": file_path,
|
||||
"representation": str(representation["_id"])})
|
||||
"representation": str(repre_doc["_id"])})
|
||||
|
||||
# Store the cam temporarily next to the Alembic Archive
|
||||
# so that we can preserve parm values the user set on it
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ class FbxLoader(load.LoaderPlugin):
|
|||
|
||||
return containerised_nodes
|
||||
|
||||
def update(self, container, representation):
|
||||
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
node = container["node"]
|
||||
try:
|
||||
file_node = next(
|
||||
|
|
@ -59,21 +59,21 @@ class FbxLoader(load.LoaderPlugin):
|
|||
return
|
||||
|
||||
# Update the file path from representation
|
||||
file_path = get_representation_path(representation)
|
||||
file_path = get_representation_path(repre_doc)
|
||||
file_path = file_path.replace("\\", "/")
|
||||
|
||||
file_node.setParms({"file": file_path})
|
||||
|
||||
# Update attribute
|
||||
node.setParms({"representation": str(representation["_id"])})
|
||||
node.setParms({"representation": str(repre_doc["_id"])})
|
||||
|
||||
def remove(self, container):
|
||||
|
||||
node = container["node"]
|
||||
node.destroy()
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def get_node_name(self, context, name=None, namespace=None):
|
||||
"""Define node name."""
|
||||
|
|
|
|||
|
|
@ -48,11 +48,12 @@ class HdaLoader(load.LoaderPlugin):
|
|||
suffix="",
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
import hou
|
||||
|
||||
repre_doc = context["representation"]
|
||||
hda_node = container["node"]
|
||||
file_path = get_representation_path(representation)
|
||||
file_path = get_representation_path(repre_doc)
|
||||
file_path = file_path.replace("\\", "/")
|
||||
hou.hda.installFile(file_path)
|
||||
defs = hda_node.type().allInstalledDefinitions()
|
||||
|
|
@ -60,7 +61,7 @@ class HdaLoader(load.LoaderPlugin):
|
|||
new = def_paths.index(file_path)
|
||||
defs[new].setIsPreferred(True)
|
||||
hda_node.setParms({
|
||||
"representation": str(representation["_id"])
|
||||
"representation": str(repre_doc["_id"])
|
||||
})
|
||||
|
||||
def remove(self, container):
|
||||
|
|
|
|||
|
|
@ -87,12 +87,12 @@ class ImageLoader(load.LoaderPlugin):
|
|||
|
||||
return node
|
||||
|
||||
def update(self, container, representation):
|
||||
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
node = container["node"]
|
||||
|
||||
# Update the file path
|
||||
file_path = get_representation_path(representation)
|
||||
file_path = get_representation_path(repre_doc)
|
||||
file_path = file_path.replace("\\", "/")
|
||||
file_path = self._get_file_sequence(file_path)
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ class ImageLoader(load.LoaderPlugin):
|
|||
node.setParms(
|
||||
{
|
||||
"filename1": file_path,
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -128,5 +128,5 @@ class ImageLoader(load.LoaderPlugin):
|
|||
fname = ".".join([prefix, "$F{}".format(len(padding)), suffix])
|
||||
return os.path.join(root, fname).replace("\\", "/")
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
|
|
|||
|
|
@ -72,19 +72,19 @@ class RedshiftProxyLoader(load.LoaderPlugin):
|
|||
suffix="",
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
# Update the file path
|
||||
file_path = get_representation_path(representation)
|
||||
file_path = get_representation_path(repre_doc)
|
||||
|
||||
node = container["node"]
|
||||
node.setParms({
|
||||
"RS_objprop_proxy_file": self.format_path(
|
||||
file_path, representation)
|
||||
file_path, repre_doc)
|
||||
})
|
||||
|
||||
# Update attribute
|
||||
node.setParms({"representation": str(representation["_id"])})
|
||||
node.setParms({"representation": str(repre_doc["_id"])})
|
||||
|
||||
def remove(self, container):
|
||||
|
||||
|
|
|
|||
|
|
@ -57,19 +57,19 @@ class USDSublayerLoader(load.LoaderPlugin):
|
|||
|
||||
return container
|
||||
|
||||
def update(self, container, representation):
|
||||
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
node = container["node"]
|
||||
|
||||
# Update the file path
|
||||
file_path = get_representation_path(representation)
|
||||
file_path = get_representation_path(repre_doc)
|
||||
file_path = file_path.replace("\\", "/")
|
||||
|
||||
# Update attributes
|
||||
node.setParms(
|
||||
{
|
||||
"filepath1": file_path,
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -81,5 +81,5 @@ class USDSublayerLoader(load.LoaderPlugin):
|
|||
node = container["node"]
|
||||
node.destroy()
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
|
|
|||
|
|
@ -57,19 +57,19 @@ class USDReferenceLoader(load.LoaderPlugin):
|
|||
|
||||
return container
|
||||
|
||||
def update(self, container, representation):
|
||||
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
node = container["node"]
|
||||
|
||||
# Update the file path
|
||||
file_path = get_representation_path(representation)
|
||||
file_path = get_representation_path(repre_doc)
|
||||
file_path = file_path.replace("\\", "/")
|
||||
|
||||
# Update attributes
|
||||
node.setParms(
|
||||
{
|
||||
"filepath1": file_path,
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -81,5 +81,5 @@ class USDReferenceLoader(load.LoaderPlugin):
|
|||
node = container["node"]
|
||||
node.destroy()
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ class VdbLoader(load.LoaderPlugin):
|
|||
|
||||
return filename
|
||||
|
||||
def update(self, container, representation):
|
||||
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
node = container["node"]
|
||||
try:
|
||||
file_node = next(
|
||||
|
|
@ -91,18 +91,18 @@ class VdbLoader(load.LoaderPlugin):
|
|||
return
|
||||
|
||||
# Update the file path
|
||||
file_path = get_representation_path(representation)
|
||||
file_path = self.format_path(file_path, representation)
|
||||
file_path = get_representation_path(repre_doc)
|
||||
file_path = self.format_path(file_path, repre_doc)
|
||||
|
||||
file_node.setParms({"file": file_path})
|
||||
|
||||
# Update attribute
|
||||
node.setParms({"representation": str(representation["_id"])})
|
||||
node.setParms({"representation": str(repre_doc["_id"])})
|
||||
|
||||
def remove(self, container):
|
||||
|
||||
node = container["node"]
|
||||
node.destroy()
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
|
|
|||
|
|
@ -51,10 +51,11 @@ class FbxLoader(load.LoaderPlugin):
|
|||
name, selections, context,
|
||||
namespace, loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
from pymxs import runtime as rt
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
node_name = container["instance_node"]
|
||||
node = rt.getNodeByName(node_name)
|
||||
namespace, _ = get_namespace(node_name)
|
||||
|
|
@ -87,11 +88,11 @@ class FbxLoader(load.LoaderPlugin):
|
|||
|
||||
update_custom_attribute_data(node, fbx_objects)
|
||||
lib.imprint(container["instance_node"], {
|
||||
"representation": str(representation["_id"])
|
||||
"representation": str(repre_doc["_id"])
|
||||
})
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
from pymxs import runtime as rt
|
||||
|
|
|
|||
|
|
@ -48,10 +48,11 @@ class MaxSceneLoader(load.LoaderPlugin):
|
|||
name, max_container, context,
|
||||
namespace, loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
from pymxs import runtime as rt
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
node_name = container["instance_node"]
|
||||
node = rt.getNodeByName(node_name)
|
||||
namespace, _ = get_namespace(node_name)
|
||||
|
|
@ -86,11 +87,11 @@ class MaxSceneLoader(load.LoaderPlugin):
|
|||
|
||||
update_custom_attribute_data(node, max_objects)
|
||||
lib.imprint(container["instance_node"], {
|
||||
"representation": str(representation["_id"])
|
||||
"representation": str(repre_doc["_id"])
|
||||
})
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
from pymxs import runtime as rt
|
||||
|
|
|
|||
|
|
@ -70,10 +70,11 @@ class ModelAbcLoader(load.LoaderPlugin):
|
|||
namespace, loader=self.__class__.__name__
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
from pymxs import runtime as rt
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
node = rt.GetNodeByName(container["instance_node"])
|
||||
node_list = [n for n in get_previous_loaded_object(node)
|
||||
if rt.ClassOf(n) == rt.AlembicContainer]
|
||||
|
|
@ -90,11 +91,11 @@ class ModelAbcLoader(load.LoaderPlugin):
|
|||
abc_obj.source = path
|
||||
lib.imprint(
|
||||
container["instance_node"],
|
||||
{"representation": str(representation["_id"])},
|
||||
{"representation": str(repre_doc["_id"])},
|
||||
)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
from pymxs import runtime as rt
|
||||
|
|
|
|||
|
|
@ -47,10 +47,11 @@ class FbxModelLoader(load.LoaderPlugin):
|
|||
name, selections, context,
|
||||
namespace, loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
from pymxs import runtime as rt
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
node_name = container["instance_node"]
|
||||
node = rt.getNodeByName(node_name)
|
||||
if not node:
|
||||
|
|
@ -85,11 +86,11 @@ class FbxModelLoader(load.LoaderPlugin):
|
|||
rt.Select(node)
|
||||
update_custom_attribute_data(node, fbx_objects)
|
||||
lib.imprint(container["instance_node"], {
|
||||
"representation": str(representation["_id"])
|
||||
"representation": str(repre_doc["_id"])
|
||||
})
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
from pymxs import runtime as rt
|
||||
|
|
|
|||
|
|
@ -47,10 +47,11 @@ class ObjLoader(load.LoaderPlugin):
|
|||
name, selections, context,
|
||||
namespace, loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
from pymxs import runtime as rt
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
node_name = container["instance_node"]
|
||||
node = rt.getNodeByName(node_name)
|
||||
namespace, _ = get_namespace(node_name)
|
||||
|
|
@ -77,11 +78,11 @@ class ObjLoader(load.LoaderPlugin):
|
|||
rt.Select(node)
|
||||
|
||||
lib.imprint(node_name, {
|
||||
"representation": str(representation["_id"])
|
||||
"representation": str(repre_doc["_id"])
|
||||
})
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
from pymxs import runtime as rt
|
||||
|
|
|
|||
|
|
@ -65,8 +65,9 @@ class ModelUSDLoader(load.LoaderPlugin):
|
|||
name, usd_objects, context,
|
||||
namespace, loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
path = get_representation_path(representation)
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
node_name = container["instance_node"]
|
||||
node = rt.GetNodeByName(node_name)
|
||||
namespace, name = get_namespace(node_name)
|
||||
|
|
@ -107,11 +108,11 @@ class ModelUSDLoader(load.LoaderPlugin):
|
|||
rt.Select(node)
|
||||
|
||||
lib.imprint(node_name, {
|
||||
"representation": str(representation["_id"])
|
||||
"representation": str(repre_doc["_id"])
|
||||
})
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
from pymxs import runtime as rt
|
||||
|
|
|
|||
|
|
@ -76,10 +76,11 @@ class AbcLoader(load.LoaderPlugin):
|
|||
namespace, loader=self.__class__.__name__
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
from pymxs import runtime as rt
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
node = rt.GetNodeByName(container["instance_node"])
|
||||
abc_container = [n for n in get_previous_loaded_object(node)
|
||||
if rt.ClassOf(n) == rt.AlembicContainer]
|
||||
|
|
@ -96,11 +97,11 @@ class AbcLoader(load.LoaderPlugin):
|
|||
abc_obj.source = path
|
||||
lib.imprint(
|
||||
container["instance_node"],
|
||||
{"representation": str(representation["_id"])},
|
||||
{"representation": str(repre_doc["_id"])},
|
||||
)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
from pymxs import runtime as rt
|
||||
|
|
|
|||
|
|
@ -62,8 +62,9 @@ class OxAbcLoader(load.LoaderPlugin):
|
|||
namespace, loader=self.__class__.__name__
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
path = get_representation_path(representation)
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
node_name = container["instance_node"]
|
||||
namespace, name = get_namespace(node_name)
|
||||
node = rt.getNodeByName(node_name)
|
||||
|
|
@ -98,11 +99,11 @@ class OxAbcLoader(load.LoaderPlugin):
|
|||
update_custom_attribute_data(node, ox_abc_objects)
|
||||
lib.imprint(
|
||||
container["instance_node"],
|
||||
{"representation": str(representation["_id"])},
|
||||
{"representation": str(repre_doc["_id"])},
|
||||
)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
from pymxs import runtime as rt
|
||||
|
|
|
|||
|
|
@ -41,11 +41,12 @@ class PointCloudLoader(load.LoaderPlugin):
|
|||
name, [obj], context,
|
||||
namespace, loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""update the container"""
|
||||
from pymxs import runtime as rt
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
node = rt.GetNodeByName(container["instance_node"])
|
||||
node_list = get_previous_loaded_object(node)
|
||||
update_custom_attribute_data(
|
||||
|
|
@ -55,11 +56,11 @@ class PointCloudLoader(load.LoaderPlugin):
|
|||
for prt in rt.Selection:
|
||||
prt.filename = path
|
||||
lib.imprint(container["instance_node"], {
|
||||
"representation": str(representation["_id"])
|
||||
"representation": str(repre_doc["_id"])
|
||||
})
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
"""remove the container"""
|
||||
|
|
|
|||
|
|
@ -52,10 +52,11 @@ class RedshiftProxyLoader(load.LoaderPlugin):
|
|||
name, [rs_proxy], context,
|
||||
namespace, loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
from pymxs import runtime as rt
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
node = rt.getNodeByName(container["instance_node"])
|
||||
node_list = get_previous_loaded_object(node)
|
||||
rt.Select(node_list)
|
||||
|
|
@ -65,11 +66,11 @@ class RedshiftProxyLoader(load.LoaderPlugin):
|
|||
proxy.file = path
|
||||
|
||||
lib.imprint(container["instance_node"], {
|
||||
"representation": str(representation["_id"])
|
||||
"representation": str(repre_doc["_id"])
|
||||
})
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
from pymxs import runtime as rt
|
||||
|
|
|
|||
|
|
@ -39,11 +39,12 @@ class TyCacheLoader(load.LoaderPlugin):
|
|||
name, [obj], context,
|
||||
namespace, loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""update the container"""
|
||||
from pymxs import runtime as rt
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
node = rt.GetNodeByName(container["instance_node"])
|
||||
node_list = get_previous_loaded_object(node)
|
||||
update_custom_attribute_data(node, node_list)
|
||||
|
|
@ -51,11 +52,11 @@ class TyCacheLoader(load.LoaderPlugin):
|
|||
for tyc in node_list:
|
||||
tyc.filename = path
|
||||
lib.imprint(container["instance_node"], {
|
||||
"representation": str(representation["_id"])
|
||||
"representation": str(repre_doc["_id"])
|
||||
})
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
"""remove the container"""
|
||||
|
|
|
|||
|
|
@ -793,14 +793,17 @@ class ReferenceLoader(Loader):
|
|||
"""To be implemented by subclass"""
|
||||
raise NotImplementedError("Must be implemented by subclass")
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
from maya import cmds
|
||||
|
||||
from ayon_core.hosts.maya.api.lib import get_container_members
|
||||
|
||||
node = container["objectName"]
|
||||
|
||||
path = get_representation_path(representation)
|
||||
project_name = context["project"]["name"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
path = get_representation_path(repre_doc)
|
||||
|
||||
# Get reference node from container members
|
||||
members = get_container_members(node)
|
||||
|
|
@ -813,9 +816,9 @@ class ReferenceLoader(Loader):
|
|||
"abc": "Alembic",
|
||||
"fbx": "FBX",
|
||||
"usd": "USD Import"
|
||||
}.get(representation["name"])
|
||||
}.get(repre_doc["name"])
|
||||
|
||||
assert file_type, "Unsupported representation: %s" % representation
|
||||
assert file_type, "Unsupported representation: %s" % repre_doc
|
||||
|
||||
assert os.path.exists(path), "%s does not exist." % path
|
||||
|
||||
|
|
@ -823,7 +826,7 @@ class ReferenceLoader(Loader):
|
|||
# them to incoming data.
|
||||
alembic_attrs = ["speed", "offset", "cycleType", "time"]
|
||||
alembic_data = {}
|
||||
if representation["name"] == "abc":
|
||||
if repre_doc["name"] == "abc":
|
||||
alembic_nodes = cmds.ls(
|
||||
"{}:*".format(namespace), type="AlembicNode"
|
||||
)
|
||||
|
|
@ -840,10 +843,7 @@ class ReferenceLoader(Loader):
|
|||
self.log.debug("No alembic nodes found in {}".format(members))
|
||||
|
||||
try:
|
||||
path = self.prepare_root_value(path,
|
||||
representation["context"]
|
||||
["project"]
|
||||
["name"])
|
||||
path = self.prepare_root_value(path, project_name)
|
||||
content = cmds.file(path,
|
||||
loadReference=reference_node,
|
||||
type=file_type,
|
||||
|
|
@ -867,7 +867,7 @@ class ReferenceLoader(Loader):
|
|||
self._organize_containers(content, container["objectName"])
|
||||
|
||||
# Reapply alembic settings.
|
||||
if representation["name"] == "abc" and alembic_data:
|
||||
if repre_doc["name"] == "abc" and alembic_data:
|
||||
alembic_nodes = cmds.ls(
|
||||
"{}:*".format(namespace), type="AlembicNode"
|
||||
)
|
||||
|
|
@ -901,7 +901,7 @@ class ReferenceLoader(Loader):
|
|||
|
||||
# Update metadata
|
||||
cmds.setAttr("{}.representation".format(node),
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string")
|
||||
|
||||
# When an animation or pointcache gets connected to an Xgen container,
|
||||
|
|
|
|||
|
|
@ -315,16 +315,27 @@ def update_package_version(container, version):
|
|||
new_representation = get_representation_by_name(
|
||||
project_name, current_representation["name"], new_version["_id"]
|
||||
)
|
||||
|
||||
update_package(container, new_representation)
|
||||
# TODO there is 'get_representation_context' to get the context which
|
||||
# could be possible to use here
|
||||
new_context = {
|
||||
"project": {
|
||||
"name": project_doc["name"],
|
||||
"code": project_doc["data"].get("code", "")
|
||||
},
|
||||
"asset": asset_doc,
|
||||
"subset": subset_doc,
|
||||
"version": version_doc,
|
||||
"representation": new_representation,
|
||||
}
|
||||
update_package(container, new_context)
|
||||
|
||||
|
||||
def update_package(set_container, representation):
|
||||
def update_package(set_container, context):
|
||||
"""Update any matrix changes in the scene based on the new data
|
||||
|
||||
Args:
|
||||
set_container (dict): container data from `ls()`
|
||||
representation (dict): the representation document from the database
|
||||
context (dict): the representation document from the database
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
|
@ -332,7 +343,8 @@ def update_package(set_container, representation):
|
|||
"""
|
||||
|
||||
# Load the original package data
|
||||
project_name = get_current_project_name()
|
||||
project_name = context["project"]["name"]
|
||||
repre_doc = context["representation"]
|
||||
current_representation = get_representation_by_id(
|
||||
project_name, set_container["representation"]
|
||||
)
|
||||
|
|
@ -343,7 +355,7 @@ def update_package(set_container, representation):
|
|||
current_data = json.load(fp)
|
||||
|
||||
# Load the new package data
|
||||
new_file = get_representation_path(representation)
|
||||
new_file = get_representation_path(repre_doc)
|
||||
assert new_file.endswith(".json")
|
||||
with open(new_file, "r") as fp:
|
||||
new_data = json.load(fp)
|
||||
|
|
@ -354,7 +366,7 @@ def update_package(set_container, representation):
|
|||
|
||||
# TODO: This should be handled by the pipeline itself
|
||||
cmds.setAttr(set_container['objectName'] + ".representation",
|
||||
str(representation['_id']), type="string")
|
||||
str(repre_doc['_id']), type="string")
|
||||
|
||||
|
||||
def update_scene(set_container, containers, current_data, new_data, new_file):
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ class ArnoldStandinLoader(load.LoaderPlugin):
|
|||
|
||||
return proxy_path, string_replace_operator
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
# Update the standin
|
||||
members = cmds.sets(container['objectName'], query=True)
|
||||
for member in members:
|
||||
|
|
@ -190,7 +190,8 @@ class ArnoldStandinLoader(load.LoaderPlugin):
|
|||
if cmds.nodeType(shapes[0]) == "aiStandIn":
|
||||
standin = shapes[0]
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
proxy_basename, proxy_path = self._get_proxy_path(path)
|
||||
|
||||
# Whether there is proxy or so, we still update the string operator.
|
||||
|
|
@ -216,12 +217,12 @@ class ArnoldStandinLoader(load.LoaderPlugin):
|
|||
|
||||
cmds.setAttr(
|
||||
container["objectName"] + ".representation",
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string"
|
||||
)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
members = cmds.sets(container['objectName'], query=True)
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ class AssemblyLoader(load.LoaderPlugin):
|
|||
context=context,
|
||||
loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
|
||||
return setdress.update_package(container, representation)
|
||||
return setdress.update_package(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
"""Remove all sub containers"""
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ class AudioLoader(load.LoaderPlugin):
|
|||
loader=self.__class__.__name__
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
|
||||
members = get_container_members(container)
|
||||
audio_nodes = cmds.ls(members, type="audio")
|
||||
|
|
@ -60,7 +61,7 @@ class AudioLoader(load.LoaderPlugin):
|
|||
)
|
||||
activate_sound = current_sound == audio_node
|
||||
|
||||
path = get_representation_path(representation)
|
||||
path = get_representation_path(repre_doc)
|
||||
|
||||
cmds.sound(
|
||||
audio_node,
|
||||
|
|
@ -93,12 +94,12 @@ class AudioLoader(load.LoaderPlugin):
|
|||
|
||||
cmds.setAttr(
|
||||
container["objectName"] + ".representation",
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string"
|
||||
)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
members = cmds.sets(container['objectName'], query=True)
|
||||
|
|
|
|||
|
|
@ -74,8 +74,9 @@ class GpuCacheLoader(load.LoaderPlugin):
|
|||
context=context,
|
||||
loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
path = get_representation_path(representation)
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
|
||||
# Update the cache
|
||||
members = cmds.sets(container['objectName'], query=True)
|
||||
|
|
@ -87,11 +88,11 @@ class GpuCacheLoader(load.LoaderPlugin):
|
|||
cmds.setAttr(cache + ".cacheFileName", path, type="string")
|
||||
|
||||
cmds.setAttr(container["objectName"] + ".representation",
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string")
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
members = cmds.sets(container['objectName'], query=True)
|
||||
|
|
|
|||
|
|
@ -146,23 +146,23 @@ class FileNodeLoader(load.LoaderPlugin):
|
|||
loader=self.__class__.__name__
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
|
||||
members = cmds.sets(container['objectName'], query=True)
|
||||
file_node = cmds.ls(members, type="file")[0]
|
||||
|
||||
context = get_representation_context(representation)
|
||||
self._apply_representation_context(context, file_node)
|
||||
|
||||
# Update representation
|
||||
cmds.setAttr(
|
||||
container["objectName"] + ".representation",
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string"
|
||||
)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
members = cmds.sets(container['objectName'], query=True)
|
||||
|
|
|
|||
|
|
@ -205,32 +205,24 @@ class ImagePlaneLoader(load.LoaderPlugin):
|
|||
loader=self.__class__.__name__
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
asset_doc = context["asset"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
members = get_container_members(container)
|
||||
image_planes = cmds.ls(members, type="imagePlane")
|
||||
assert image_planes, "Image plane not found."
|
||||
image_plane_shape = image_planes[0]
|
||||
|
||||
path = get_representation_path(representation)
|
||||
path = get_representation_path(repre_doc)
|
||||
cmds.setAttr("{}.imageName".format(image_plane_shape),
|
||||
path,
|
||||
type="string")
|
||||
cmds.setAttr("{}.representation".format(container["objectName"]),
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string")
|
||||
|
||||
# Set frame range.
|
||||
project_name = get_current_project_name()
|
||||
version = get_version_by_id(
|
||||
project_name, representation["parent"], fields=["parent"]
|
||||
)
|
||||
subset_doc = get_subset_by_id(
|
||||
project_name, version["parent"], fields=["parent"]
|
||||
)
|
||||
asset_doc = get_asset_by_id(
|
||||
project_name, subset_doc["parent"], fields=["parent"]
|
||||
)
|
||||
start_frame = asset_doc["data"]["frameStart"]
|
||||
end_frame = asset_doc["data"]["frameEnd"]
|
||||
|
||||
|
|
@ -243,8 +235,8 @@ class ImagePlaneLoader(load.LoaderPlugin):
|
|||
plug = "{}.{}".format(image_plane_shape, attr)
|
||||
cmds.setAttr(plug, value)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
members = cmds.sets(container['objectName'], query=True)
|
||||
|
|
|
|||
|
|
@ -43,10 +43,10 @@ class LookLoader(ayon_core.hosts.maya.api.plugin.ReferenceLoader):
|
|||
|
||||
self[:] = nodes
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""
|
||||
Called by Scene Inventory when look should be updated to current
|
||||
version.
|
||||
|
|
@ -56,7 +56,7 @@ class LookLoader(ayon_core.hosts.maya.api.plugin.ReferenceLoader):
|
|||
|
||||
Args:
|
||||
container: object that has look to be updated
|
||||
representation: (dict): relationship data to get proper
|
||||
context: (dict): relationship data to get proper
|
||||
representation from DB and persisted
|
||||
data in .json
|
||||
Returns:
|
||||
|
|
@ -72,15 +72,16 @@ class LookLoader(ayon_core.hosts.maya.api.plugin.ReferenceLoader):
|
|||
orig_nodes = set(self._get_nodes_with_shader(shader_nodes))
|
||||
|
||||
# Trigger the regular reference update on the ReferenceLoader
|
||||
super(LookLoader, self).update(container, representation)
|
||||
super(LookLoader, self).update(container, context)
|
||||
|
||||
# get new applied shaders and nodes from new version
|
||||
shader_nodes = cmds.ls(members, type='shadingEngine')
|
||||
nodes = set(self._get_nodes_with_shader(shader_nodes))
|
||||
|
||||
version_doc = context["version"]
|
||||
project_name = get_current_project_name()
|
||||
json_representation = get_representation_by_name(
|
||||
project_name, "json", representation["parent"]
|
||||
project_name, "json", version_doc["_id"]
|
||||
)
|
||||
|
||||
# Load relationships
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class MayaUsdLoader(load.LoaderPlugin):
|
|||
context=context,
|
||||
loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
# type: (dict, dict) -> None
|
||||
"""Update container with specified representation."""
|
||||
node = container['objectName']
|
||||
|
|
@ -78,16 +78,17 @@ class MayaUsdLoader(load.LoaderPlugin):
|
|||
members = cmds.sets(node, query=True) or []
|
||||
shapes = cmds.ls(members, type="mayaUsdProxyShape")
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
for shape in shapes:
|
||||
cmds.setAttr("{}.filePath".format(shape), path, type="string")
|
||||
|
||||
cmds.setAttr("{}.representation".format(node),
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string")
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
# type: (dict) -> None
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class MultiverseUsdLoader(load.LoaderPlugin):
|
|||
context=context,
|
||||
loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
# type: (dict, dict) -> None
|
||||
"""Update container with specified representation."""
|
||||
node = container['objectName']
|
||||
|
|
@ -70,7 +70,9 @@ class MultiverseUsdLoader(load.LoaderPlugin):
|
|||
shapes = cmds.ls(members, type="mvUsdCompoundShape")
|
||||
assert shapes, "Cannot find mvUsdCompoundShape in container"
|
||||
|
||||
project_name = representation["context"]["project"]["name"]
|
||||
project_name = context["project"]["name"]
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
prev_representation_id = cmds.getAttr("{}.representation".format(node))
|
||||
prev_representation = get_representation_by_id(project_name,
|
||||
prev_representation_id)
|
||||
|
|
@ -89,18 +91,17 @@ class MultiverseUsdLoader(load.LoaderPlugin):
|
|||
"Couldn't find matching path (or too many)"
|
||||
prev_path_idx = asset_paths.index(prev_path)
|
||||
|
||||
path = get_representation_path(representation)
|
||||
asset_paths[prev_path_idx] = path
|
||||
|
||||
multiverse.SetUsdCompoundAssetPaths(shape, asset_paths)
|
||||
|
||||
cmds.setAttr("{}.representation".format(node),
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string")
|
||||
mel.eval('refreshEditorTemplates;')
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
# type: (dict) -> None
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class MultiverseUsdOverLoader(load.LoaderPlugin):
|
|||
|
||||
return container
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
# type: (dict, dict) -> None
|
||||
"""Update container with specified representation."""
|
||||
|
||||
|
|
@ -88,13 +88,14 @@ class MultiverseUsdOverLoader(load.LoaderPlugin):
|
|||
mvShape = container['mvUsdCompoundShape']
|
||||
assert mvShape, "Missing mv source"
|
||||
|
||||
project_name = representation["context"]["project"]["name"]
|
||||
project_name = context["project"]["name"]
|
||||
repre_doc = context["representation"]
|
||||
prev_representation_id = cmds.getAttr("{}.representation".format(node))
|
||||
prev_representation = get_representation_by_id(project_name,
|
||||
prev_representation_id)
|
||||
prev_path = os.path.normpath(prev_representation["data"]["path"])
|
||||
|
||||
path = get_representation_path(representation)
|
||||
path = get_representation_path(repre_doc)
|
||||
|
||||
for shape in shapes:
|
||||
asset_paths = multiverse.GetUsdCompoundAssetPaths(shape)
|
||||
|
|
@ -107,12 +108,12 @@ class MultiverseUsdOverLoader(load.LoaderPlugin):
|
|||
multiverse.SetUsdCompoundAssetPaths(shape, asset_paths)
|
||||
|
||||
cmds.setAttr("{}.representation".format(node),
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string")
|
||||
mel.eval('refreshEditorTemplates;')
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
# type: (dict) -> None
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class RedshiftProxyLoader(load.LoaderPlugin):
|
|||
context=context,
|
||||
loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
|
||||
node = container['objectName']
|
||||
assert cmds.objExists(node), "Missing container"
|
||||
|
|
@ -83,8 +83,8 @@ class RedshiftProxyLoader(load.LoaderPlugin):
|
|||
members = cmds.sets(node, query=True) or []
|
||||
rs_meshes = cmds.ls(members, type="RedshiftProxyMesh")
|
||||
assert rs_meshes, "Cannot find RedshiftProxyMesh in container"
|
||||
|
||||
filename = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
filename = get_representation_path(repre_doc)
|
||||
|
||||
for rs_mesh in rs_meshes:
|
||||
cmds.setAttr("{}.fileName".format(rs_mesh),
|
||||
|
|
@ -93,7 +93,7 @@ class RedshiftProxyLoader(load.LoaderPlugin):
|
|||
|
||||
# Update metadata
|
||||
cmds.setAttr("{}.representation".format(node),
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string")
|
||||
|
||||
def remove(self, container):
|
||||
|
|
@ -113,8 +113,8 @@ class RedshiftProxyLoader(load.LoaderPlugin):
|
|||
self.log.warning("Namespace not deleted because it "
|
||||
"still has members: %s", namespace)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def create_rs_proxy(self, name, path):
|
||||
"""Creates Redshift Proxies showing a proxy object.
|
||||
|
|
|
|||
|
|
@ -231,12 +231,12 @@ class ReferenceLoader(plugin.ReferenceLoader):
|
|||
*options["translate"])
|
||||
return new_nodes
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
with preserve_modelpanel_cameras(container, log=self.log):
|
||||
super(ReferenceLoader, self).update(container, representation)
|
||||
super(ReferenceLoader, self).update(container, context)
|
||||
|
||||
# We also want to lock camera transforms on any new cameras in the
|
||||
# reference or for a camera which might have changed names.
|
||||
|
|
|
|||
|
|
@ -84,14 +84,15 @@ class RenderSetupLoader(load.LoaderPlugin):
|
|||
# Already implicitly deleted by Maya upon removing reference
|
||||
pass
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update RenderSetup setting by overwriting existing settings."""
|
||||
lib.show_message(
|
||||
"Render setup update",
|
||||
"Render setup setting will be overwritten by new version. All "
|
||||
"setting specified by user not included in loaded version "
|
||||
"will be lost.")
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
with open(path, "r") as file:
|
||||
try:
|
||||
renderSetup.instance().decode(
|
||||
|
|
@ -103,10 +104,10 @@ class RenderSetupLoader(load.LoaderPlugin):
|
|||
# Update metadata
|
||||
node = container["objectName"]
|
||||
cmds.setAttr("{}.representation".format(node),
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string")
|
||||
self.log.info("... updated")
|
||||
|
||||
def switch(self, container, representation):
|
||||
def switch(self, container, context):
|
||||
"""Switch representations."""
|
||||
self.update(container, representation)
|
||||
self.update(container, context)
|
||||
|
|
|
|||
|
|
@ -81,11 +81,13 @@ class LoadVDBtoArnold(load.LoaderPlugin):
|
|||
context=context,
|
||||
loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
|
||||
from maya import cmds
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
|
||||
path = get_representation_path(repre_doc)
|
||||
|
||||
# Find VRayVolumeGrid
|
||||
members = cmds.sets(container['objectName'], query=True)
|
||||
|
|
@ -93,15 +95,15 @@ class LoadVDBtoArnold(load.LoaderPlugin):
|
|||
assert len(grid_nodes) == 1, "This is a bug"
|
||||
|
||||
# Update the VRayVolumeGrid
|
||||
self._set_path(grid_nodes[0], path=path, representation=representation)
|
||||
self._set_path(grid_nodes[0], path=path, representation=repre_doc)
|
||||
|
||||
# Update container representation
|
||||
cmds.setAttr(container["objectName"] + ".representation",
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string")
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
|
||||
|
|
|
|||
|
|
@ -95,10 +95,11 @@ class LoadVDBtoRedShift(load.LoaderPlugin):
|
|||
context=context,
|
||||
loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
from maya import cmds
|
||||
|
||||
path = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
path = get_representation_path(repre_doc)
|
||||
|
||||
# Find VRayVolumeGrid
|
||||
members = cmds.sets(container['objectName'], query=True)
|
||||
|
|
@ -106,11 +107,11 @@ class LoadVDBtoRedShift(load.LoaderPlugin):
|
|||
assert len(grid_nodes) == 1, "This is a bug"
|
||||
|
||||
# Update the VRayVolumeGrid
|
||||
self._set_path(grid_nodes[0], path=path, representation=representation)
|
||||
self._set_path(grid_nodes[0], path=path, representation=repre_doc)
|
||||
|
||||
# Update container representation
|
||||
cmds.setAttr(container["objectName"] + ".representation",
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string")
|
||||
|
||||
def remove(self, container):
|
||||
|
|
@ -129,8 +130,8 @@ class LoadVDBtoRedShift(load.LoaderPlugin):
|
|||
except RuntimeError:
|
||||
pass
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
@staticmethod
|
||||
def _set_path(grid_node,
|
||||
|
|
|
|||
|
|
@ -254,9 +254,10 @@ class LoadVDBtoVRay(load.LoaderPlugin):
|
|||
restored_mapping,
|
||||
type="string")
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
|
||||
path = get_representation_path(representation)
|
||||
path = get_representation_path(repre_doc)
|
||||
|
||||
# Find VRayVolumeGrid
|
||||
members = cmds.sets(container['objectName'], query=True)
|
||||
|
|
@ -269,11 +270,11 @@ class LoadVDBtoVRay(load.LoaderPlugin):
|
|||
|
||||
# Update container representation
|
||||
cmds.setAttr(container["objectName"] + ".representation",
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string")
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class VRayProxyLoader(load.LoaderPlugin):
|
|||
context=context,
|
||||
loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
# type: (dict, dict) -> None
|
||||
"""Update container with specified representation."""
|
||||
node = container['objectName']
|
||||
|
|
@ -107,9 +107,10 @@ class VRayProxyLoader(load.LoaderPlugin):
|
|||
assert vraymeshes, "Cannot find VRayMesh in container"
|
||||
|
||||
# get all representations for this version
|
||||
repre_doc = context["representation"]
|
||||
filename = (
|
||||
self._get_abc(representation["parent"])
|
||||
or get_representation_path(representation)
|
||||
self._get_abc(repre_doc["parent"])
|
||||
or get_representation_path(repre_doc)
|
||||
)
|
||||
|
||||
for vray_mesh in vraymeshes:
|
||||
|
|
@ -119,7 +120,7 @@ class VRayProxyLoader(load.LoaderPlugin):
|
|||
|
||||
# Update metadata
|
||||
cmds.setAttr("{}.representation".format(node),
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string")
|
||||
|
||||
def remove(self, container):
|
||||
|
|
@ -140,10 +141,10 @@ class VRayProxyLoader(load.LoaderPlugin):
|
|||
self.log.warning("Namespace not deleted because it "
|
||||
"still has members: %s", namespace)
|
||||
|
||||
def switch(self, container, representation):
|
||||
def switch(self, container, context):
|
||||
# type: (dict, dict) -> None
|
||||
"""Switch loaded representation."""
|
||||
self.update(container, representation)
|
||||
self.update(container, context)
|
||||
|
||||
def create_vray_proxy(self, name, filename):
|
||||
# type: (str, str) -> (list, str)
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class VRaySceneLoader(load.LoaderPlugin):
|
|||
context=context,
|
||||
loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
|
||||
node = container['objectName']
|
||||
assert cmds.objExists(node), "Missing container"
|
||||
|
|
@ -80,7 +80,8 @@ class VRaySceneLoader(load.LoaderPlugin):
|
|||
vraymeshes = cmds.ls(members, type="VRayScene")
|
||||
assert vraymeshes, "Cannot find VRayScene in container"
|
||||
|
||||
filename = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
filename = get_representation_path(repre_doc)
|
||||
|
||||
for vray_mesh in vraymeshes:
|
||||
cmds.setAttr("{}.FilePath".format(vray_mesh),
|
||||
|
|
@ -89,7 +90,7 @@ class VRaySceneLoader(load.LoaderPlugin):
|
|||
|
||||
# Update metadata
|
||||
cmds.setAttr("{}.representation".format(node),
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
type="string")
|
||||
|
||||
def remove(self, container):
|
||||
|
|
@ -109,8 +110,8 @@ class VRaySceneLoader(load.LoaderPlugin):
|
|||
self.log.warning("Namespace not deleted because it "
|
||||
"still has members: %s", namespace)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def create_vray_scene(self, name, filename):
|
||||
"""Re-create the structure created by VRay to support vrscenes
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class XgenLoader(ayon_core.hosts.maya.api.plugin.ReferenceLoader):
|
|||
)
|
||||
cmds.setAttr("{}.xgExportAsDelta".format(xgen_palette), True)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Workflow for updating Xgen.
|
||||
|
||||
- Export changes to delta file.
|
||||
|
|
@ -147,7 +147,8 @@ class XgenLoader(ayon_core.hosts.maya.api.plugin.ReferenceLoader):
|
|||
|
||||
self.set_palette_attributes(xgen_palette, xgen_file, xgd_file)
|
||||
|
||||
maya_file = get_representation_path(representation)
|
||||
repre_doc = context["representation"]
|
||||
maya_file = get_representation_path(repre_doc)
|
||||
_, extension = os.path.splitext(maya_file)
|
||||
new_xgen_file = maya_file.replace(extension, ".xgen")
|
||||
data_path = ""
|
||||
|
|
@ -173,7 +174,7 @@ class XgenLoader(ayon_core.hosts.maya.api.plugin.ReferenceLoader):
|
|||
"{}.xgExportAsDelta".format(xgen_palette): False
|
||||
}
|
||||
with attribute_values(attribute_data):
|
||||
super().update(container, representation)
|
||||
super().update(container, context)
|
||||
|
||||
xgenm.applyDelta(xgen_palette.replace("|", ""), xgd_file)
|
||||
|
||||
|
|
|
|||
|
|
@ -122,12 +122,12 @@ class YetiCacheLoader(load.LoaderPlugin):
|
|||
|
||||
cmds.namespace(removeNamespace=namespace, deleteNamespaceContent=True)
|
||||
|
||||
def update(self, container, representation):
|
||||
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
namespace = container["namespace"]
|
||||
container_node = container["objectName"]
|
||||
|
||||
path = get_representation_path(representation)
|
||||
path = get_representation_path(repre_doc)
|
||||
settings = self.read_settings(path)
|
||||
|
||||
# Collect scene information of asset
|
||||
|
|
@ -216,11 +216,11 @@ class YetiCacheLoader(load.LoaderPlugin):
|
|||
set_attribute(attr, value, yeti_node)
|
||||
|
||||
cmds.setAttr("{}.representation".format(container_node),
|
||||
str(representation["_id"]),
|
||||
str(repre_doc["_id"]),
|
||||
typ="string")
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
# helper functions
|
||||
def create_namespace(self, asset):
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ class LoadBackdropNodes(load.LoaderPlugin):
|
|||
loader=self.__class__.__name__,
|
||||
data=data_imprint)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update the Loader's path
|
||||
|
||||
Nuke automatically tries to reset some variables when changing
|
||||
|
|
@ -189,13 +189,14 @@ class LoadBackdropNodes(load.LoaderPlugin):
|
|||
|
||||
# get main variables
|
||||
# Get version from io
|
||||
project_name = get_current_project_name()
|
||||
version_doc = get_version_by_id(project_name, representation["parent"])
|
||||
project_name = context["project"]["name"]
|
||||
version_doc = context["version"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
# get corresponding node
|
||||
GN = container["node"]
|
||||
|
||||
file = get_representation_path(representation).replace("\\", "/")
|
||||
file = get_representation_path(repre_doc).replace("\\", "/")
|
||||
|
||||
name = container['name']
|
||||
version_data = version_doc.get("data", {})
|
||||
|
|
@ -207,7 +208,7 @@ class LoadBackdropNodes(load.LoaderPlugin):
|
|||
add_keys = ["source", "author", "fps"]
|
||||
|
||||
data_imprint = {
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"version": vname,
|
||||
"colorspaceInput": colorspace,
|
||||
}
|
||||
|
|
@ -248,8 +249,8 @@ class LoadBackdropNodes(load.LoaderPlugin):
|
|||
|
||||
return update_container(GN, data_imprint)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
node = container["node"]
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class AlembicCameraLoader(load.LoaderPlugin):
|
|||
loader=self.__class__.__name__,
|
||||
data=data_imprint)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""
|
||||
Called by Scene Inventory when look should be updated to current
|
||||
version.
|
||||
|
|
@ -109,8 +109,8 @@ class AlembicCameraLoader(load.LoaderPlugin):
|
|||
None
|
||||
"""
|
||||
# Get version from io
|
||||
project_name = get_current_project_name()
|
||||
version_doc = get_version_by_id(project_name, representation["parent"])
|
||||
version_doc = context["version"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
# get main variables
|
||||
version_data = version_doc.get("data", {})
|
||||
|
|
@ -124,7 +124,7 @@ class AlembicCameraLoader(load.LoaderPlugin):
|
|||
add_keys = ["source", "author", "fps"]
|
||||
|
||||
data_imprint = {
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"frameStart": first,
|
||||
"frameEnd": last,
|
||||
"version": vname
|
||||
|
|
@ -134,7 +134,7 @@ class AlembicCameraLoader(load.LoaderPlugin):
|
|||
data_imprint.update({k: version_data[k]})
|
||||
|
||||
# getting file path
|
||||
file = get_representation_path(representation).replace("\\", "/")
|
||||
file = get_representation_path(repre_doc).replace("\\", "/")
|
||||
|
||||
with maintained_selection():
|
||||
camera_node = container["node"]
|
||||
|
|
@ -191,8 +191,8 @@ class AlembicCameraLoader(load.LoaderPlugin):
|
|||
color_value = "0xd88467ff"
|
||||
node["tile_color"].setValue(int(color_value, 16))
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
node = container["node"]
|
||||
|
|
|
|||
|
|
@ -209,8 +209,8 @@ class LoadClip(plugin.NukeLoader):
|
|||
|
||||
return container
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def _representation_with_hash_in_frame(self, representation):
|
||||
"""Convert frame key value to padded hash
|
||||
|
|
@ -241,7 +241,7 @@ class LoadClip(plugin.NukeLoader):
|
|||
representation["context"]["frame"] = hashed_frame
|
||||
return representation
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update the Loader's path
|
||||
|
||||
Nuke automatically tries to reset some variables when changing
|
||||
|
|
@ -250,16 +250,18 @@ class LoadClip(plugin.NukeLoader):
|
|||
|
||||
"""
|
||||
|
||||
is_sequence = len(representation["files"]) > 1
|
||||
repre_doc = context["representation"]
|
||||
|
||||
is_sequence = len(repre_doc["files"]) > 1
|
||||
|
||||
read_node = container["node"]
|
||||
|
||||
if is_sequence:
|
||||
representation = self._representation_with_hash_in_frame(
|
||||
representation
|
||||
repre_doc = self._representation_with_hash_in_frame(
|
||||
repre_doc
|
||||
)
|
||||
|
||||
filepath = get_representation_path(representation).replace("\\", "/")
|
||||
filepath = get_representation_path(repre_doc).replace("\\", "/")
|
||||
self.log.debug("_ filepath: {}".format(filepath))
|
||||
|
||||
start_at_workfile = "start at" in read_node['frame_mode'].value()
|
||||
|
|
@ -270,13 +272,13 @@ class LoadClip(plugin.NukeLoader):
|
|||
]
|
||||
|
||||
project_name = get_current_project_name()
|
||||
version_doc = get_version_by_id(project_name, representation["parent"])
|
||||
version_doc = get_version_by_id(project_name, repre_doc["parent"])
|
||||
|
||||
version_data = version_doc.get("data", {})
|
||||
repre_id = representation["_id"]
|
||||
repre_id = repre_doc["_id"]
|
||||
|
||||
# colorspace profile
|
||||
colorspace = representation["data"].get("colorspace")
|
||||
colorspace = repre_doc["data"].get("colorspace")
|
||||
colorspace = colorspace or version_data.get("colorspace")
|
||||
|
||||
self.handle_start = version_data.get("handleStart", 0)
|
||||
|
|
@ -303,12 +305,12 @@ 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"], filepath)
|
||||
read_node, version_data, repre_doc["data"], filepath)
|
||||
|
||||
self._set_range_to_node(read_node, first, last, start_at_workfile)
|
||||
|
||||
updated_dict = {
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"frameStart": str(first),
|
||||
"frameEnd": str(last),
|
||||
"version": str(version_doc.get("name")),
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ class LoadEffects(load.LoaderPlugin):
|
|||
loader=self.__class__.__name__,
|
||||
data=data_imprint)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update the Loader's path
|
||||
|
||||
Nuke automatically tries to reset some variables when changing
|
||||
|
|
@ -156,13 +156,14 @@ class LoadEffects(load.LoaderPlugin):
|
|||
"""
|
||||
# get main variables
|
||||
# Get version from io
|
||||
project_name = get_current_project_name()
|
||||
version_doc = get_version_by_id(project_name, representation["parent"])
|
||||
project_name = context["project"]["name"]
|
||||
version_doc = context["version"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
# get corresponding node
|
||||
GN = container["node"]
|
||||
|
||||
file = get_representation_path(representation).replace("\\", "/")
|
||||
file = get_representation_path(repre_doc).replace("\\", "/")
|
||||
name = container['name']
|
||||
version_data = version_doc.get("data", {})
|
||||
vname = version_doc.get("name", None)
|
||||
|
|
@ -177,7 +178,7 @@ class LoadEffects(load.LoaderPlugin):
|
|||
"source", "author", "fps"]
|
||||
|
||||
data_imprint = {
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"frameStart": first,
|
||||
"frameEnd": last,
|
||||
"version": vname,
|
||||
|
|
@ -344,8 +345,8 @@ class LoadEffects(load.LoaderPlugin):
|
|||
else:
|
||||
return input
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
node = container["node"]
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ class LoadEffectsInputProcess(load.LoaderPlugin):
|
|||
loader=self.__class__.__name__,
|
||||
data=data_imprint)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update the Loader's path
|
||||
|
||||
Nuke automatically tries to reset some variables when changing
|
||||
|
|
@ -161,13 +161,14 @@ class LoadEffectsInputProcess(load.LoaderPlugin):
|
|||
|
||||
# get main variables
|
||||
# Get version from io
|
||||
project_name = get_current_project_name()
|
||||
version_doc = get_version_by_id(project_name, representation["parent"])
|
||||
project_name = context["project"]["name"]
|
||||
version_doc = context["version"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
# get corresponding node
|
||||
GN = container["node"]
|
||||
|
||||
file = get_representation_path(representation).replace("\\", "/")
|
||||
file = get_representation_path(repre_doc).replace("\\", "/")
|
||||
version_data = version_doc.get("data", {})
|
||||
vname = version_doc.get("name", None)
|
||||
first = version_data.get("frameStart", None)
|
||||
|
|
@ -179,7 +180,7 @@ class LoadEffectsInputProcess(load.LoaderPlugin):
|
|||
"source", "author", "fps"]
|
||||
|
||||
data_imprint = {
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"frameStart": first,
|
||||
"frameEnd": last,
|
||||
"version": vname,
|
||||
|
|
@ -355,8 +356,8 @@ class LoadEffectsInputProcess(load.LoaderPlugin):
|
|||
else:
|
||||
return input
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
node = container["node"]
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ class LoadGizmo(load.LoaderPlugin):
|
|||
loader=self.__class__.__name__,
|
||||
data=data_imprint)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update the Loader's path
|
||||
|
||||
Nuke automatically tries to reset some variables when changing
|
||||
|
|
@ -108,13 +108,14 @@ class LoadGizmo(load.LoaderPlugin):
|
|||
|
||||
# get main variables
|
||||
# Get version from io
|
||||
project_name = get_current_project_name()
|
||||
version_doc = get_version_by_id(project_name, representation["parent"])
|
||||
project_name = context["project"]["name"]
|
||||
version_doc = context["version"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
# get corresponding node
|
||||
group_node = container["node"]
|
||||
|
||||
file = get_representation_path(representation).replace("\\", "/")
|
||||
file = get_representation_path(repre_doc).replace("\\", "/")
|
||||
name = container['name']
|
||||
version_data = version_doc.get("data", {})
|
||||
vname = version_doc.get("name", None)
|
||||
|
|
@ -128,7 +129,7 @@ class LoadGizmo(load.LoaderPlugin):
|
|||
"source", "author", "fps"]
|
||||
|
||||
data_imprint = {
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"frameStart": first,
|
||||
"frameEnd": last,
|
||||
"version": vname,
|
||||
|
|
@ -173,8 +174,8 @@ class LoadGizmo(load.LoaderPlugin):
|
|||
|
||||
return update_container(new_group_node, data_imprint)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
node = container["node"]
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ class LoadGizmoInputProcess(load.LoaderPlugin):
|
|||
loader=self.__class__.__name__,
|
||||
data=data_imprint)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update the Loader's path
|
||||
|
||||
Nuke automatically tries to reset some variables when changing
|
||||
|
|
@ -115,13 +115,14 @@ class LoadGizmoInputProcess(load.LoaderPlugin):
|
|||
|
||||
# get main variables
|
||||
# Get version from io
|
||||
project_name = get_current_project_name()
|
||||
version_doc = get_version_by_id(project_name, representation["parent"])
|
||||
project_name = context["project"]["name"]
|
||||
version_doc = context["version"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
# get corresponding node
|
||||
group_node = container["node"]
|
||||
|
||||
file = get_representation_path(representation).replace("\\", "/")
|
||||
file = get_representation_path(repre_doc).replace("\\", "/")
|
||||
name = container['name']
|
||||
version_data = version_doc.get("data", {})
|
||||
vname = version_doc.get("name", None)
|
||||
|
|
@ -135,7 +136,7 @@ class LoadGizmoInputProcess(load.LoaderPlugin):
|
|||
"source", "author", "fps"]
|
||||
|
||||
data_imprint = {
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"frameStart": first,
|
||||
"frameEnd": last,
|
||||
"version": vname,
|
||||
|
|
@ -254,8 +255,8 @@ class LoadGizmoInputProcess(load.LoaderPlugin):
|
|||
else:
|
||||
return input
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
node = container["node"]
|
||||
|
|
|
|||
|
|
@ -155,10 +155,10 @@ class LoadImage(load.LoaderPlugin):
|
|||
loader=self.__class__.__name__,
|
||||
data=data_imprint)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update the Loader's path
|
||||
|
||||
Nuke automatically tries to reset some variables when changing
|
||||
|
|
@ -171,12 +171,16 @@ class LoadImage(load.LoaderPlugin):
|
|||
|
||||
assert node.Class() == "Read", "Must be Read"
|
||||
|
||||
repr_cont = representation["context"]
|
||||
project_name = context["project"]["name"]
|
||||
version_doc = context["version"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
file = get_representation_path(representation)
|
||||
repr_cont = repre_doc["context"]
|
||||
|
||||
file = get_representation_path(repre_doc)
|
||||
|
||||
if not file:
|
||||
repr_id = representation["_id"]
|
||||
repr_id = repre_doc["_id"]
|
||||
self.log.warning(
|
||||
"Representation id `{}` is failing to load".format(repr_id))
|
||||
return
|
||||
|
|
@ -191,8 +195,6 @@ class LoadImage(load.LoaderPlugin):
|
|||
format(frame_number, "0{}".format(padding)))
|
||||
|
||||
# Get start frame from version data
|
||||
project_name = get_current_project_name()
|
||||
version_doc = get_version_by_id(project_name, representation["parent"])
|
||||
last_version_doc = get_last_version_by_subset_id(
|
||||
project_name, version_doc["parent"], fields=["_id"]
|
||||
)
|
||||
|
|
@ -210,7 +212,7 @@ class LoadImage(load.LoaderPlugin):
|
|||
|
||||
updated_dict = {}
|
||||
updated_dict.update({
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"frameStart": str(first),
|
||||
"frameEnd": str(last),
|
||||
"version": str(version_doc.get("name")),
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class AlembicModelLoader(load.LoaderPlugin):
|
|||
loader=self.__class__.__name__,
|
||||
data=data_imprint)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""
|
||||
Called by Scene Inventory when look should be updated to current
|
||||
version.
|
||||
|
|
@ -106,15 +106,15 @@ class AlembicModelLoader(load.LoaderPlugin):
|
|||
|
||||
Args:
|
||||
container: object that has look to be updated
|
||||
representation: (dict): relationship data to get proper
|
||||
context: (dict): relationship data to get proper
|
||||
representation from DB and persisted
|
||||
data in .json
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
# Get version from io
|
||||
project_name = get_current_project_name()
|
||||
version_doc = get_version_by_id(project_name, representation["parent"])
|
||||
version_doc = context["version"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
# get corresponding node
|
||||
model_node = container["node"]
|
||||
|
|
@ -131,7 +131,7 @@ class AlembicModelLoader(load.LoaderPlugin):
|
|||
add_keys = ["source", "author", "fps"]
|
||||
|
||||
data_imprint = {
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"frameStart": first,
|
||||
"frameEnd": last,
|
||||
"version": vname
|
||||
|
|
@ -141,7 +141,7 @@ class AlembicModelLoader(load.LoaderPlugin):
|
|||
data_imprint.update({k: version_data[k]})
|
||||
|
||||
# getting file path
|
||||
file = get_representation_path(representation).replace("\\", "/")
|
||||
file = get_representation_path(repre_doc).replace("\\", "/")
|
||||
|
||||
with maintained_selection():
|
||||
model_node['selected'].setValue(True)
|
||||
|
|
@ -202,8 +202,8 @@ class AlembicModelLoader(load.LoaderPlugin):
|
|||
color_value = "0xd88467ff"
|
||||
node["tile_color"].setValue(int(color_value, 16))
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
node = nuke.toNode(container['objectName'])
|
||||
|
|
|
|||
|
|
@ -219,14 +219,13 @@ class LoadOcioLookNodes(load.LoaderPlugin):
|
|||
|
||||
return group_node
|
||||
|
||||
def update(self, container, representation):
|
||||
|
||||
project_name = get_current_project_name()
|
||||
version_doc = get_version_by_id(project_name, representation["parent"])
|
||||
def update(self, container, context):
|
||||
version_doc = context["version"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
group_node = container["node"]
|
||||
|
||||
filepath = get_representation_path(representation)
|
||||
filepath = get_representation_path(repre_doc)
|
||||
|
||||
json_f = self._load_json_data(filepath)
|
||||
|
||||
|
|
@ -242,7 +241,7 @@ class LoadOcioLookNodes(load.LoaderPlugin):
|
|||
group_node["name"].value()))
|
||||
|
||||
return update_container(
|
||||
group_node, {"representation": str(representation["_id"])})
|
||||
group_node, {"representation": str(repre_doc["_id"])})
|
||||
|
||||
def _load_json_data(self, filepath):
|
||||
# getting data from json file with unicode conversion
|
||||
|
|
@ -280,8 +279,8 @@ class LoadOcioLookNodes(load.LoaderPlugin):
|
|||
else:
|
||||
return input
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def remove(self, container):
|
||||
node = nuke.toNode(container['objectName'])
|
||||
|
|
|
|||
|
|
@ -104,10 +104,10 @@ class LinkAsGroup(load.LoaderPlugin):
|
|||
loader=self.__class__.__name__,
|
||||
data=data_imprint)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update the Loader's path
|
||||
|
||||
Nuke automatically tries to reset some variables when changing
|
||||
|
|
@ -117,11 +117,13 @@ class LinkAsGroup(load.LoaderPlugin):
|
|||
"""
|
||||
node = container["node"]
|
||||
|
||||
root = get_representation_path(representation).replace("\\", "/")
|
||||
project_name = context["project"]["name"]
|
||||
version_doc = context["version"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
root = get_representation_path(repre_doc).replace("\\", "/")
|
||||
|
||||
# Get start frame from version data
|
||||
project_name = get_current_project_name()
|
||||
version_doc = get_version_by_id(project_name, representation["parent"])
|
||||
last_version_doc = get_last_version_by_subset_id(
|
||||
project_name, version_doc["parent"], fields=["_id"]
|
||||
)
|
||||
|
|
@ -129,7 +131,7 @@ class LinkAsGroup(load.LoaderPlugin):
|
|||
updated_dict = {}
|
||||
version_data = version_doc["data"]
|
||||
updated_dict.update({
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"frameEnd": version_data.get("frameEnd"),
|
||||
"version": version_doc.get("name"),
|
||||
"colorspace": version_data.get("colorspace"),
|
||||
|
|
|
|||
|
|
@ -224,23 +224,23 @@ class ImageLoader(load.LoaderPlugin):
|
|||
self.__class__.__name__
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
layer = container.pop("layer")
|
||||
|
||||
repre_doc = context["representation"]
|
||||
with photoshop.maintained_selection():
|
||||
stub.replace_smart_object(
|
||||
layer, get_representation_path(representation)
|
||||
layer, get_representation_path(repre_doc)
|
||||
)
|
||||
|
||||
stub.imprint(
|
||||
layer, {"representation": str(representation["_id"])}
|
||||
layer, {"representation": str(repre_doc["_id"])}
|
||||
)
|
||||
|
||||
def remove(self, container):
|
||||
container["layer"].Delete()
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
```
|
||||
For easier debugging of Javascript:
|
||||
https://community.adobe.com/t5/download-install/adobe-extension-debuger-problem/td-p/10911704?page=1
|
||||
|
|
|
|||
|
|
@ -36,13 +36,13 @@ class ImageLoader(photoshop.PhotoshopLoader):
|
|||
self.__class__.__name__
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
""" Switch asset or change version """
|
||||
stub = self.get_stub()
|
||||
|
||||
layer = container.pop("layer")
|
||||
|
||||
context = representation.get("context", {})
|
||||
repre_doc = context["representation"]
|
||||
|
||||
namespace_from_container = re.sub(r'_\d{3}$', '',
|
||||
container["namespace"])
|
||||
|
|
@ -55,14 +55,14 @@ class ImageLoader(photoshop.PhotoshopLoader):
|
|||
else: # switching version - keep same name
|
||||
layer_name = container["namespace"]
|
||||
|
||||
path = get_representation_path(representation)
|
||||
path = get_representation_path(repre_doc)
|
||||
with photoshop.maintained_selection():
|
||||
stub.replace_smart_object(
|
||||
layer, path, layer_name
|
||||
)
|
||||
|
||||
stub.imprint(
|
||||
layer.id, {"representation": str(representation["_id"])}
|
||||
layer.id, {"representation": str(repre_doc["_id"])}
|
||||
)
|
||||
|
||||
def remove(self, container):
|
||||
|
|
@ -77,8 +77,8 @@ class ImageLoader(photoshop.PhotoshopLoader):
|
|||
stub.imprint(layer.id, {})
|
||||
stub.delete_layer(layer.id)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def import_layer(self, file_name, layer_name, stub):
|
||||
return stub.import_smart_object(file_name, layer_name)
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class ImageFromSequenceLoader(photoshop.PhotoshopLoader):
|
|||
)
|
||||
]
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""No update possible, not containerized."""
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -37,32 +37,37 @@ class ReferenceLoader(photoshop.PhotoshopLoader):
|
|||
self.__class__.__name__
|
||||
)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
""" Switch asset or change version """
|
||||
stub = self.get_stub()
|
||||
layer = container.pop("layer")
|
||||
|
||||
context = representation.get("context", {})
|
||||
asset_doc = context["asset"]
|
||||
subset_doc = context["subset"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
folder_name = asset_doc["name"]
|
||||
product_name = subset_doc["name"]
|
||||
|
||||
namespace_from_container = re.sub(r'_\d{3}$', '',
|
||||
container["namespace"])
|
||||
layer_name = "{}_{}".format(context["asset"], context["subset"])
|
||||
layer_name = "{}_{}".format(folder_name, product_name)
|
||||
# switching assets
|
||||
if namespace_from_container != layer_name:
|
||||
layer_name = get_unique_layer_name(
|
||||
stub.get_layers(), context["asset"], context["subset"]
|
||||
stub.get_layers(), folder_name, product_name
|
||||
)
|
||||
else: # switching version - keep same name
|
||||
layer_name = container["namespace"]
|
||||
|
||||
path = get_representation_path(representation)
|
||||
path = get_representation_path(repre_doc)
|
||||
with photoshop.maintained_selection():
|
||||
stub.replace_smart_object(
|
||||
layer, path, layer_name
|
||||
)
|
||||
|
||||
stub.imprint(
|
||||
layer.id, {"representation": str(representation["_id"])}
|
||||
layer.id, {"representation": str(repre_doc["_id"])}
|
||||
)
|
||||
|
||||
def remove(self, container):
|
||||
|
|
@ -76,8 +81,8 @@ class ReferenceLoader(photoshop.PhotoshopLoader):
|
|||
stub.imprint(layer.id, {})
|
||||
stub.delete_layer(layer.id)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def import_layer(self, file_name, layer_name, stub):
|
||||
return stub.import_smart_object(
|
||||
|
|
|
|||
|
|
@ -538,7 +538,7 @@ class TimelineItemLoader(LoaderPlugin):
|
|||
):
|
||||
pass
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Update an existing `container`
|
||||
"""
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -59,21 +59,21 @@ class LoadClip(plugin.TimelineItemLoader):
|
|||
self.__class__.__name__,
|
||||
data_imprint)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
""" Updating previously loaded clips
|
||||
"""
|
||||
|
||||
context = get_representation_context(representation)
|
||||
repre_doc = context["representation"]
|
||||
name = container['name']
|
||||
namespace = container['namespace']
|
||||
timeline_item = container["_timeline_item"]
|
||||
|
||||
media_pool_item = timeline_item.GetMediaPoolItem()
|
||||
|
||||
files = plugin.get_representation_files(representation)
|
||||
files = plugin.get_representation_files(repre_doc)
|
||||
|
||||
loader = plugin.ClipLoader(self, context)
|
||||
timeline_item = loader.update(timeline_item, files)
|
||||
|
|
@ -92,10 +92,10 @@ class LoadClip(plugin.TimelineItemLoader):
|
|||
def get_tag_data(self, context, name, namespace):
|
||||
"""Return data to be imprinted on the timeline item marker"""
|
||||
|
||||
representation = context["representation"]
|
||||
version = context['version']
|
||||
version_data = version.get("data", {})
|
||||
version_name = version.get("name", None)
|
||||
repre_doc = context["representation"]
|
||||
version_doc = context["version"]
|
||||
version_data = version_doc.get("data", {})
|
||||
version_name = version_doc.get("name", None)
|
||||
colorspace = version_data.get("colorspace", None)
|
||||
object_name = "{}_{}".format(name, namespace)
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ class LoadClip(plugin.TimelineItemLoader):
|
|||
|
||||
# add variables related to version context
|
||||
data.update({
|
||||
"representation": str(representation["_id"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"version": version_name,
|
||||
"colorspace": colorspace,
|
||||
"objectName": object_name
|
||||
|
|
|
|||
|
|
@ -97,12 +97,13 @@ class SubstanceLoadProjectMesh(load.LoaderPlugin):
|
|||
|
||||
set_container_metadata(project_mesh_object_name, container)
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
def switch(self, container, context):
|
||||
self.update(container, context)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
|
||||
path = get_representation_path(representation)
|
||||
path = get_representation_path(repre_doc)
|
||||
|
||||
# Reload the mesh
|
||||
container_options = container.get("options", {})
|
||||
|
|
@ -121,7 +122,7 @@ class SubstanceLoadProjectMesh(load.LoaderPlugin):
|
|||
|
||||
# Update container representation
|
||||
object_name = container["objectName"]
|
||||
update_data = {"representation": str(representation["_id"])}
|
||||
update_data = {"representation": str(repre_doc["_id"])}
|
||||
set_container_metadata(object_name, update_data, update=True)
|
||||
|
||||
def remove(self, container):
|
||||
|
|
|
|||
|
|
@ -210,15 +210,17 @@ class LoadImage(plugin.Loader):
|
|||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
"""Replace container with different version.
|
||||
|
||||
New layers are loaded as first step. Then is tried to change data in
|
||||
new layers with data from old layers. When that is done old layers are
|
||||
removed.
|
||||
"""
|
||||
|
||||
repre_doc = context["representation"]
|
||||
# Create new containers first
|
||||
context = get_representation_context(representation)
|
||||
context = get_representation_context(repre_doc)
|
||||
|
||||
# Get layer ids from previous container
|
||||
old_layer_names = self.get_members_from_container(container)
|
||||
|
|
|
|||
|
|
@ -126,12 +126,15 @@ class AnimationAlembicLoader(plugin.Loader):
|
|||
|
||||
return asset_content
|
||||
|
||||
def update(self, container, representation):
|
||||
name = container["asset_name"]
|
||||
source_path = get_representation_path(representation)
|
||||
def update(self, container, context):
|
||||
folder_name = container["asset_name"]
|
||||
repre_doc = context["representation"]
|
||||
source_path = get_representation_path(repre_doc)
|
||||
destination_path = container["namespace"]
|
||||
|
||||
task = self.get_task(source_path, destination_path, name, True)
|
||||
task = self.get_task(
|
||||
source_path, destination_path, folder_name, True
|
||||
)
|
||||
|
||||
# do import fbx and replace existing data
|
||||
asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
|
||||
|
|
@ -143,8 +146,8 @@ class AnimationAlembicLoader(plugin.Loader):
|
|||
unreal_pipeline.imprint(
|
||||
container_path,
|
||||
{
|
||||
"representation": str(representation["_id"]),
|
||||
"parent": str(representation["parent"])
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"parent": str(repre_doc["parent"])
|
||||
})
|
||||
|
||||
asset_content = unreal.EditorAssetLibrary.list_assets(
|
||||
|
|
|
|||
|
|
@ -246,9 +246,10 @@ class AnimationFBXLoader(plugin.Loader):
|
|||
unreal.EditorLevelLibrary.save_current_level()
|
||||
unreal.EditorLevelLibrary.load_level(master_level)
|
||||
|
||||
def update(self, container, representation):
|
||||
name = container["asset_name"]
|
||||
source_path = get_representation_path(representation)
|
||||
def update(self, container, context):
|
||||
repre_doc = context["representation"]
|
||||
folder_name = container["asset_name"]
|
||||
source_path = get_representation_path(repre_doc)
|
||||
asset_doc = get_current_project_asset(fields=["data.fps"])
|
||||
destination_path = container["namespace"]
|
||||
|
||||
|
|
@ -258,7 +259,7 @@ class AnimationFBXLoader(plugin.Loader):
|
|||
task.set_editor_property('filename', source_path)
|
||||
task.set_editor_property('destination_path', destination_path)
|
||||
# strip suffix
|
||||
task.set_editor_property('destination_name', name)
|
||||
task.set_editor_property('destination_name', folder_name)
|
||||
task.set_editor_property('replace_existing', True)
|
||||
task.set_editor_property('automated', True)
|
||||
task.set_editor_property('save', True)
|
||||
|
|
@ -305,8 +306,8 @@ class AnimationFBXLoader(plugin.Loader):
|
|||
unreal_pipeline.imprint(
|
||||
container_path,
|
||||
{
|
||||
"representation": str(representation["_id"]),
|
||||
"parent": str(representation["parent"])
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"parent": str(repre_doc["parent"])
|
||||
})
|
||||
|
||||
asset_content = EditorAssetLibrary.list_assets(
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ class CameraLoader(plugin.Loader):
|
|||
|
||||
return asset_content
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
ar = unreal.AssetRegistryHelpers.get_asset_registry()
|
||||
|
||||
curr_level_sequence = LevelSequenceLib.get_current_level_sequence()
|
||||
|
|
@ -379,12 +379,13 @@ class CameraLoader(plugin.Loader):
|
|||
|
||||
sub_scene.set_sequence(new_sequence)
|
||||
|
||||
repre_doc = context["representation"]
|
||||
self._import_camera(
|
||||
EditorLevelLibrary.get_editor_world(),
|
||||
new_sequence,
|
||||
new_sequence.get_bindings(),
|
||||
settings,
|
||||
str(representation["data"]["path"])
|
||||
str(repre_doc["data"]["path"])
|
||||
)
|
||||
|
||||
# Set range of all sections
|
||||
|
|
@ -412,8 +413,8 @@ class CameraLoader(plugin.Loader):
|
|||
key.set_time(unreal.FrameNumber(value=new_time))
|
||||
|
||||
data = {
|
||||
"representation": str(representation["_id"]),
|
||||
"parent": str(representation["parent"])
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"parent": str(repre_doc["parent"])
|
||||
}
|
||||
imprint(f"{asset_dir}/{container.get('container_name')}", data)
|
||||
|
||||
|
|
|
|||
|
|
@ -163,25 +163,30 @@ class PointCacheAlembicLoader(plugin.Loader):
|
|||
|
||||
return asset_content
|
||||
|
||||
def update(self, container, representation):
|
||||
context = representation.get("context", {})
|
||||
|
||||
unreal.log_warning(context)
|
||||
|
||||
if not context:
|
||||
raise RuntimeError("No context found in representation")
|
||||
def update(self, container, context):
|
||||
asset_doc = context["asset"]
|
||||
subset_doc = context["subset"]
|
||||
version_doc = context["version"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
# Create directory for asset and Ayon container
|
||||
asset = context.get('asset')
|
||||
name = context.get('subset')
|
||||
folder_name = asset_doc["name"]
|
||||
product_name = subset_doc["name"]
|
||||
|
||||
suffix = "_CON"
|
||||
asset_name = f"{asset}_{name}" if asset else f"{name}"
|
||||
version = context.get('version')
|
||||
asset_name = product_name
|
||||
if folder_name:
|
||||
asset_name = f"{folder_name}_{product_name}"
|
||||
|
||||
# Check if version is hero version and use different name
|
||||
name_version = f"{name}_v{version:03d}" if version else f"{name}_hero"
|
||||
version = version_doc.get("name", -1)
|
||||
if version < 0:
|
||||
name_version = f"{product_name}_hero"
|
||||
else:
|
||||
name_version = f"{product_name}_v{version:03d}"
|
||||
tools = unreal.AssetToolsHelpers().get_asset_tools()
|
||||
asset_dir, container_name = tools.create_unique_asset_name(
|
||||
f"{self.root}/{asset}/{name_version}", suffix="")
|
||||
f"{self.root}/{folder_name}/{name_version}", suffix="")
|
||||
|
||||
container_name += suffix
|
||||
|
||||
|
|
@ -189,14 +194,14 @@ class PointCacheAlembicLoader(plugin.Loader):
|
|||
frame_end = int(container.get("frame_end"))
|
||||
|
||||
if not unreal.EditorAssetLibrary.does_directory_exist(asset_dir):
|
||||
path = get_representation_path(representation)
|
||||
path = get_representation_path(repre_doc)
|
||||
|
||||
self.import_and_containerize(
|
||||
path, asset_dir, asset_name, container_name,
|
||||
frame_start, frame_end)
|
||||
|
||||
self.imprint(
|
||||
asset, asset_dir, container_name, asset_name, representation,
|
||||
folder_name, asset_dir, container_name, asset_name, repre_doc,
|
||||
frame_start, frame_end)
|
||||
|
||||
asset_content = unreal.EditorAssetLibrary.list_assets(
|
||||
|
|
|
|||
|
|
@ -661,7 +661,7 @@ class LayoutLoader(plugin.Loader):
|
|||
|
||||
return asset_content
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
data = get_current_project_settings()
|
||||
create_sequences = data["unreal"]["level_sequences_for_layouts"]
|
||||
|
||||
|
|
@ -677,9 +677,11 @@ class LayoutLoader(plugin.Loader):
|
|||
root = "/Game/Ayon"
|
||||
|
||||
asset_dir = container.get('namespace')
|
||||
context = representation.get("context")
|
||||
|
||||
hierarchy = context.get('hierarchy').split("/")
|
||||
asset_doc = context["asset"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
hierarchy = list(asset_doc["data"]["parents"])
|
||||
|
||||
sequence = None
|
||||
master_level = None
|
||||
|
|
@ -728,13 +730,13 @@ class LayoutLoader(plugin.Loader):
|
|||
|
||||
EditorAssetLibrary.delete_directory(f"{asset_dir}/animations/")
|
||||
|
||||
source_path = get_representation_path(representation)
|
||||
source_path = get_representation_path(repre_doc)
|
||||
|
||||
loaded_assets = self._process(source_path, asset_dir, sequence)
|
||||
|
||||
data = {
|
||||
"representation": str(representation["_id"]),
|
||||
"parent": str(representation["parent"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"parent": str(repre_doc["parent"]),
|
||||
"loaded_assets": loaded_assets
|
||||
}
|
||||
imprint(
|
||||
|
|
|
|||
|
|
@ -407,16 +407,18 @@ class ExistingLayoutLoader(plugin.Loader):
|
|||
}
|
||||
upipeline.imprint(f"{curr_level_path}/{container_name}", data)
|
||||
|
||||
def update(self, container, representation):
|
||||
def update(self, container, context):
|
||||
asset_dir = container.get('namespace')
|
||||
|
||||
source_path = get_representation_path(representation)
|
||||
project_name = get_current_project_name()
|
||||
project_name = context["project"]["name"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
source_path = get_representation_path(repre_doc)
|
||||
containers = self._process(source_path, project_name)
|
||||
|
||||
data = {
|
||||
"representation": str(representation["_id"]),
|
||||
"parent": str(representation["parent"]),
|
||||
"representation": str(repre_doc["_id"]),
|
||||
"parent": str(repre_doc["parent"]),
|
||||
"loaded_assets": containers
|
||||
}
|
||||
upipeline.imprint(
|
||||
|
|
|
|||
|
|
@ -144,34 +144,40 @@ class SkeletalMeshAlembicLoader(plugin.Loader):
|
|||
|
||||
return asset_content
|
||||
|
||||
def update(self, container, representation):
|
||||
context = representation.get("context", {})
|
||||
def update(self, container, context):
|
||||
asset_doc = context["asset"]
|
||||
subset_doc = context["subset"]
|
||||
version_doc = context["version"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
if not context:
|
||||
raise RuntimeError("No context found in representation")
|
||||
folder_name = asset_doc["name"]
|
||||
product_name = subset_doc["name"]
|
||||
|
||||
# Create directory for asset and Ayon container
|
||||
asset = context.get('asset')
|
||||
name = context.get('subset')
|
||||
# Create directory for folder and Ayon container
|
||||
suffix = "_CON"
|
||||
asset_name = f"{asset}_{name}" if asset else f"{name}"
|
||||
version = context.get('version')
|
||||
asset_name = product_name
|
||||
if folder_name:
|
||||
asset_name = f"{folder_name}_{product_name}"
|
||||
# Check if version is hero version and use different name
|
||||
name_version = f"{name}_v{version:03d}" if version else f"{name}_hero"
|
||||
version = version_doc.get("name", -1)
|
||||
if version < 0:
|
||||
name_version = f"{product_name}_hero"
|
||||
else:
|
||||
name_version = f"{product_name}_v{version:03d}"
|
||||
tools = unreal.AssetToolsHelpers().get_asset_tools()
|
||||
asset_dir, container_name = tools.create_unique_asset_name(
|
||||
f"{self.root}/{asset}/{name_version}", suffix="")
|
||||
f"{self.root}/{folder_name}/{name_version}", suffix="")
|
||||
|
||||
container_name += suffix
|
||||
|
||||
if not unreal.EditorAssetLibrary.does_directory_exist(asset_dir):
|
||||
path = get_representation_path(representation)
|
||||
path = get_representation_path(repre_doc)
|
||||
|
||||
self.import_and_containerize(path, asset_dir, asset_name,
|
||||
container_name)
|
||||
|
||||
self.imprint(
|
||||
asset, asset_dir, container_name, asset_name, representation)
|
||||
folder_name, asset_dir, container_name, asset_name, repre_doc)
|
||||
|
||||
asset_content = unreal.EditorAssetLibrary.list_assets(
|
||||
asset_dir, recursive=True, include_folder=False
|
||||
|
|
|
|||
|
|
@ -146,34 +146,40 @@ class SkeletalMeshFBXLoader(plugin.Loader):
|
|||
|
||||
return asset_content
|
||||
|
||||
def update(self, container, representation):
|
||||
context = representation.get("context", {})
|
||||
def update(self, container, context):
|
||||
asset_doc = context["asse"]
|
||||
subset_doc = context["subset"]
|
||||
version_doc = context["version"]
|
||||
repre_doc = context["representation"]
|
||||
|
||||
if not context:
|
||||
raise RuntimeError("No context found in representation")
|
||||
folder_name = asset_doc["name"]
|
||||
product_name = subset_doc["name"]
|
||||
|
||||
# Create directory for asset and Ayon container
|
||||
asset = context.get('asset')
|
||||
name = context.get('subset')
|
||||
suffix = "_CON"
|
||||
asset_name = f"{asset}_{name}" if asset else f"{name}"
|
||||
version = context.get('version')
|
||||
asset_name = product_name
|
||||
if folder_name:
|
||||
asset_name = f"{folder_name}_{product_name}"
|
||||
# Check if version is hero version and use different name
|
||||
name_version = f"{name}_v{version:03d}" if version else f"{name}_hero"
|
||||
version = version_doc.get("name", -1)
|
||||
if version < 0:
|
||||
name_version = f"{product_name}_hero"
|
||||
else:
|
||||
name_version = f"{product_name}_v{version:03d}"
|
||||
tools = unreal.AssetToolsHelpers().get_asset_tools()
|
||||
asset_dir, container_name = tools.create_unique_asset_name(
|
||||
f"{self.root}/{asset}/{name_version}", suffix="")
|
||||
f"{self.root}/{folder_name}/{name_version}", suffix="")
|
||||
|
||||
container_name += suffix
|
||||
|
||||
if not unreal.EditorAssetLibrary.does_directory_exist(asset_dir):
|
||||
path = get_representation_path(representation)
|
||||
path = get_representation_path(repre_doc)
|
||||
|
||||
self.import_and_containerize(
|
||||
path, asset_dir, asset_name, container_name)
|
||||
|
||||
self.imprint(
|
||||
asset, asset_dir, container_name, asset_name, representation)
|
||||
folder_name, asset_dir, container_name, asset_name, repre_doc)
|
||||
|
||||
asset_content = unreal.EditorAssetLibrary.list_assets(
|
||||
asset_dir, recursive=True, include_folder=False
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue