mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Order instances for processing
This commit is contained in:
parent
12a0db85bb
commit
7eea0cab97
4 changed files with 36 additions and 5 deletions
|
|
@ -2,7 +2,7 @@ import nuke
|
|||
|
||||
import os
|
||||
import importlib
|
||||
from collections import OrderedDict
|
||||
from collections import OrderedDict, defaultdict
|
||||
|
||||
import pyblish.api
|
||||
|
||||
|
|
@ -537,7 +537,8 @@ def list_instances(creator_id=None):
|
|||
Returns:
|
||||
(list) of dictionaries matching instances format
|
||||
"""
|
||||
listed_instances = []
|
||||
instances_by_order = defaultdict(list)
|
||||
subset_instances = []
|
||||
for node in nuke.allNodes(recurseGroups=True):
|
||||
|
||||
if node.Class() in ["Viewer", "Dot"]:
|
||||
|
|
@ -563,9 +564,29 @@ def list_instances(creator_id=None):
|
|||
if creator_id and instance_data["creator_identifier"] != creator_id:
|
||||
continue
|
||||
|
||||
listed_instances.append((node, instance_data))
|
||||
if "render_order" not in node.knobs():
|
||||
subset_instances.append((node, instance_data))
|
||||
continue
|
||||
|
||||
return listed_instances
|
||||
order = int(node["render_order"].value())
|
||||
instances_by_order[order].append((node, instance_data))
|
||||
|
||||
# Sort instances based on order attribute or subset name.
|
||||
ordered_instances = []
|
||||
for key in sorted(instances_by_order.keys()):
|
||||
instances_by_subset = {}
|
||||
for node, data in instances_by_order[key]:
|
||||
instances_by_subset[data["subset"]] = (node, data)
|
||||
for subkey in sorted(instances_by_subset.keys()):
|
||||
ordered_instances.append(instances_by_subset[subkey])
|
||||
|
||||
instances_by_subset = {}
|
||||
for node, data in subset_instances:
|
||||
instances_by_subset[data["subset"]] = (node, data)
|
||||
for key in sorted(instances_by_subset.keys()):
|
||||
ordered_instances.append(instances_by_subset[key])
|
||||
|
||||
return ordered_instances
|
||||
|
||||
|
||||
def remove_instance(instance):
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ class CreateWritePrerender(napi.NukeWriteCreator):
|
|||
temp_rendering_path_template = (
|
||||
"{work}/renders/nuke/{subset}/{subset}.{frame}.{ext}")
|
||||
|
||||
# Before write node render.
|
||||
order = 90
|
||||
|
||||
def get_pre_create_attr_defs(self):
|
||||
attr_defs = [
|
||||
BoolDef(
|
||||
|
|
@ -46,6 +49,8 @@ class CreateWritePrerender(napi.NukeWriteCreator):
|
|||
if "use_range_limit" in self.instance_attributes:
|
||||
linked_knobs_ = ["channels", "___", "first", "last", "use_limit"]
|
||||
|
||||
linked_knobs_.append("render_order")
|
||||
|
||||
# add fpath_template
|
||||
write_data = {
|
||||
"creator": self.__class__.__name__,
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@ class CreateWriteRender(napi.NukeWriteCreator):
|
|||
return attr_defs
|
||||
|
||||
def create_instance_node(self, subset_name, instance_data):
|
||||
linked_knobs_ = [
|
||||
"channels", "___", "first", "last", "use_limit", "render_order"
|
||||
]
|
||||
|
||||
# add fpath_template
|
||||
write_data = {
|
||||
"creator": self.__class__.__name__,
|
||||
|
|
@ -61,6 +65,7 @@ class CreateWriteRender(napi.NukeWriteCreator):
|
|||
write_data,
|
||||
input=self.selected_node,
|
||||
prenodes=self.prenodes,
|
||||
linked_knobs=linked_knobs_,
|
||||
**{
|
||||
"width": width,
|
||||
"height": height
|
||||
|
|
|
|||
|
|
@ -2121,7 +2121,7 @@ class CreateContext:
|
|||
|
||||
def reset_instances(self):
|
||||
"""Reload instances"""
|
||||
self._instances_by_id = {}
|
||||
self._instances_by_id = collections.OrderedDict()
|
||||
|
||||
# Collect instances
|
||||
error_message = "Collection of instances for creator {} failed. {}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue