Skip to content

Commit

Permalink
Merge branch 'develop' into enhancement/remove-multijson-publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
antirotor committed Mar 4, 2024
2 parents 25573ce + d3d3596 commit 742bbb3
Show file tree
Hide file tree
Showing 118 changed files with 984 additions and 823 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Bug Report
description: File a bug report
title: 'Bug: '
title: ''
labels:
- 'type: bug'
body:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/enhancement_request.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Enhancement Request
description: Create a report to help us enhance a particular feature
title: "Enhancement: "
title: ""
labels:
- "type: enhancement"
body:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,37 +56,42 @@ def load(self, context, name=None, namespace=None, data=None):
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:
items = stub.get_items(comps=True)
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],
stub.LOADED_ICON + comp_name,
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

Expand All @@ -104,5 +109,5 @@ def remove(self, container):
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)
23 changes: 14 additions & 9 deletions client/ayon_core/hosts/aftereffects/plugins/load/load_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,36 @@ def load(self, context, name=None, namespace=None, data=None):
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}
)

Expand All @@ -103,5 +108,5 @@ def remove(self, container):
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)
6 changes: 3 additions & 3 deletions client/ayon_core/hosts/blender/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,13 @@ def _load(self,

# 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:
Expand Down
9 changes: 5 additions & 4 deletions client/ayon_core/hosts/blender/plugins/load/load_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def process_asset(
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
Expand All @@ -191,15 +191,16 @@ def exec_update(self, container: Dict, representation: Dict):
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, (
Expand Down Expand Up @@ -244,7 +245,7 @@ def exec_update(self, container: Dict, representation: Dict):
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.
Expand Down
10 changes: 5 additions & 5 deletions client/ayon_core/hosts/blender/plugins/load/load_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def process_asset(
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
Expand All @@ -126,18 +126,18 @@ def update(self, container: Dict, representation: Dict):
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, (
Expand Down Expand Up @@ -241,7 +241,7 @@ def update(self, container: Dict, representation: Dict):
# 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')

Expand Down
11 changes: 6 additions & 5 deletions client/ayon_core/hosts/blender/plugins/load/load_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def process_asset(
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:
Expand All @@ -105,14 +105,15 @@ def exec_update(self, container: Dict, representation: Dict):
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, (
Expand Down Expand Up @@ -175,8 +176,8 @@ def exec_update(self, container: Dict, representation: Dict):
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:
Expand Down
9 changes: 5 additions & 4 deletions client/ayon_core/hosts/blender/plugins/load/load_blend.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,14 @@ def process_asset(
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']}"
Expand Down Expand Up @@ -234,8 +235,8 @@ def exec_update(self, container: Dict, representation: Dict):

new_data = {
"libpath": libpath,
"representation": str(representation["_id"]),
"parent": str(representation["parent"]),
"representation": str(repre_doc["_id"]),
"parent": str(repre_doc["parent"]),
"members": members,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,14 @@ def process_asset(
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']}"
Expand Down Expand Up @@ -201,8 +202,8 @@ def exec_update(self, container: Dict, representation: Dict):

new_data = {
"libpath": libpath,
"representation": str(representation["_id"]),
"parent": str(representation["parent"]),
"representation": str(repre_doc["_id"]),
"parent": str(repre_doc["parent"]),
"members": members,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def process_asset(
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
Expand All @@ -142,15 +142,16 @@ def exec_update(self, container: Dict, representation: Dict):
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, (
Expand Down Expand Up @@ -185,7 +186,7 @@ def exec_update(self, container: Dict, representation: Dict):
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def process_asset(
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
Expand All @@ -145,15 +145,16 @@ def exec_update(self, container: Dict, representation: Dict):
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, (
Expand Down Expand Up @@ -195,7 +196,7 @@ def exec_update(self, container: Dict, representation: Dict):
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.
Expand Down
Loading

0 comments on commit 742bbb3

Please sign in to comment.