mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Publish backdrops with templates.
- other nodes within the bounding box of the backdrops are published as well, cause non-connected notes can be used to communicate to the end user. - not publishing templates to ftrack.
This commit is contained in:
parent
579d9e0162
commit
9d9ef80f1c
3 changed files with 79 additions and 10 deletions
|
|
@ -14,6 +14,19 @@ class ImportTemplateLoader(api.Loader):
|
|||
label = "Import Template"
|
||||
|
||||
def load(self, context, name=None, namespace=None, data=None):
|
||||
# Make backdrops from metadata.
|
||||
backdrops = context["representation"]["data"].get("backdrops", [])
|
||||
|
||||
func = """function func(args)
|
||||
{
|
||||
Backdrop.addBackdrop("Top", args[0]);
|
||||
}
|
||||
func
|
||||
"""
|
||||
for backdrop in backdrops:
|
||||
harmony.send({"function": func, "args": [backdrop]})
|
||||
|
||||
# Import template.
|
||||
temp_dir = tempfile.mkdtemp()
|
||||
zip_file = api.get_representation_path(context["representation"])
|
||||
template_path = os.path.join(temp_dir, "temp.tpl")
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class CollectInstances(pyblish.api.ContextPlugin):
|
|||
order = pyblish.api.CollectorOrder
|
||||
hosts = ["harmony"]
|
||||
families_mapping = {
|
||||
"render": ["imagesequence", "review"],
|
||||
"render": ["imagesequence", "review", "ftrack"],
|
||||
"harmony.template": []
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +45,6 @@ class CollectInstances(pyblish.api.ContextPlugin):
|
|||
{"function": "node.getEnable", "args": [node]}
|
||||
)["result"]
|
||||
instance.data["families"] = self.families_mapping[data["family"]]
|
||||
instance.data["families"].append("ftrack")
|
||||
|
||||
# Produce diagnostic message for any graphical
|
||||
# user interface interested in visualising it.
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from avalon import harmony
|
|||
|
||||
class ExtractTemplate(pype.api.Extractor):
|
||||
"""Extract the connected nodes to the composite instance."""
|
||||
|
||||
label = "Extract Template"
|
||||
hosts = ["harmony"]
|
||||
families = ["harmony.template"]
|
||||
|
|
@ -14,10 +15,32 @@ class ExtractTemplate(pype.api.Extractor):
|
|||
def process(self, instance):
|
||||
staging_dir = self.staging_dir(instance)
|
||||
|
||||
self.log.info("Outputting template to %s" % staging_dir)
|
||||
self.log.info("Outputting template to {}".format(staging_dir))
|
||||
|
||||
self.dependencies = []
|
||||
self.get_dependencies(instance[0])
|
||||
dependencies = []
|
||||
self.get_dependencies(instance[0], dependencies)
|
||||
|
||||
# Get backdrops.
|
||||
backdrops = {}
|
||||
for dependency in dependencies:
|
||||
for backdrop in self.get_backdrops(dependency):
|
||||
backdrops[backdrop["title"]["text"]] = backdrop
|
||||
unique_backdrops = [backdrops[x] for x in set(backdrops.keys())]
|
||||
|
||||
# Get non-connected nodes within backdrops.
|
||||
all_nodes = harmony.send(
|
||||
{"function": "node.subNodes", "args": ["Top"]}
|
||||
)["result"]
|
||||
for node in [x for x in all_nodes if x not in dependencies]:
|
||||
within_unique_backdrops = bool(
|
||||
[x for x in self.get_backdrops(node) if x in unique_backdrops]
|
||||
)
|
||||
if within_unique_backdrops:
|
||||
dependencies.append(node)
|
||||
|
||||
# Make sure we dont export the instance node.
|
||||
if instance[0] in dependencies:
|
||||
dependencies.remove(instance[0])
|
||||
|
||||
func = """function func(args)
|
||||
{
|
||||
|
|
@ -30,7 +53,7 @@ class ExtractTemplate(pype.api.Extractor):
|
|||
}
|
||||
func
|
||||
"""
|
||||
harmony.send({"function": func, "args": [self.dependencies]})
|
||||
harmony.send({"function": func, "args": [dependencies]})
|
||||
func = """function func(args)
|
||||
{
|
||||
copyPaste.createTemplateFromSelection(args[0], args[1]);
|
||||
|
|
@ -56,10 +79,44 @@ class ExtractTemplate(pype.api.Extractor):
|
|||
"ext": "zip",
|
||||
"files": "{}.zip".format(instance.name),
|
||||
"stagingDir": staging_dir,
|
||||
"data": {"backdrops": unique_backdrops}
|
||||
}
|
||||
instance.data["representations"] = [representation]
|
||||
|
||||
def get_dependencies(self, node):
|
||||
def get_backdrops(self, node):
|
||||
func = """function func(probe_node)
|
||||
{
|
||||
var backdrops = Backdrop.backdrops("Top");
|
||||
var valid_backdrops = [];
|
||||
for(var i=0; i<backdrops.length; i++)
|
||||
{
|
||||
var position = backdrops[i].position;
|
||||
|
||||
var x_valid = false;
|
||||
var node_x = node.coordX(probe_node);
|
||||
if (position.x < node_x && node_x < (position.x + position.w)){
|
||||
x_valid = true
|
||||
};
|
||||
|
||||
var y_valid = false;
|
||||
var node_y = node.coordY(probe_node);
|
||||
if (position.y < node_y && node_y < (position.y + position.h)){
|
||||
y_valid = true
|
||||
};
|
||||
|
||||
if (x_valid && y_valid){
|
||||
valid_backdrops.push(backdrops[i])
|
||||
};
|
||||
}
|
||||
return valid_backdrops;
|
||||
}
|
||||
func
|
||||
"""
|
||||
return harmony.send(
|
||||
{"function": func, "args": [node]}
|
||||
)["result"]
|
||||
|
||||
def get_dependencies(self, node, dependencies):
|
||||
func = """function func(args)
|
||||
{
|
||||
var target_node = args[0];
|
||||
|
|
@ -82,9 +139,9 @@ class ExtractTemplate(pype.api.Extractor):
|
|||
if not dependency:
|
||||
continue
|
||||
|
||||
if dependency in self.dependencies:
|
||||
if dependency in dependencies:
|
||||
continue
|
||||
|
||||
self.dependencies.append(dependency)
|
||||
dependencies.append(dependency)
|
||||
|
||||
self.get_dependencies(dependency)
|
||||
self.get_dependencies(dependency, dependencies)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue