mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Initial render publishing
This commit is contained in:
parent
19a46c7cd6
commit
331ffab46f
5 changed files with 208 additions and 0 deletions
82
pype/plugins/harmony/publish/extract_render.py
Normal file
82
pype/plugins/harmony/publish/extract_render.py
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
import os
|
||||
import tempfile
|
||||
|
||||
import pyblish.api
|
||||
from avalon import harmony
|
||||
import pype.lib
|
||||
|
||||
import clique
|
||||
|
||||
|
||||
class ExtractRender(pyblish.api.InstancePlugin):
|
||||
"""Produce a flattened image file from instance.
|
||||
This plug-in only takes into account the nodes connected to the composite.
|
||||
"""
|
||||
|
||||
label = "Extract Render"
|
||||
order = pyblish.api.ExtractorOrder
|
||||
hosts = ["harmony"]
|
||||
families = ["render"]
|
||||
|
||||
def process(self, instance):
|
||||
# Collect scene data.
|
||||
func = """function func(write_node)
|
||||
{
|
||||
return [
|
||||
about.getApplicationPath(),
|
||||
scene.currentProjectPath(),
|
||||
scene.currentScene()
|
||||
]
|
||||
}
|
||||
func
|
||||
"""
|
||||
result = harmony.send(
|
||||
{"function": func, "args": [instance[0]]}
|
||||
)["result"]
|
||||
application_path = result[0]
|
||||
project_path = result[1]
|
||||
scene_path = os.path.join(result[1], result[2] + ".xstage")
|
||||
|
||||
# Set output path to temp folder.
|
||||
path = tempfile.mkdtemp()
|
||||
func = """function func(args)
|
||||
{
|
||||
node.setTextAttr(args[0], "DRAWING_NAME", 1, args[1]);
|
||||
scene.saveAll();
|
||||
}
|
||||
func
|
||||
"""
|
||||
result = harmony.send(
|
||||
{
|
||||
"function": func,
|
||||
"args": [instance[0], path + "/" + instance.data["name"]]
|
||||
}
|
||||
)
|
||||
|
||||
# Execute rendering.
|
||||
output = pype.lib._subprocess([application_path, "-batch", scene_path])
|
||||
self.log.info(output)
|
||||
|
||||
# Collect rendered files.
|
||||
files = os.listdir(path)
|
||||
collections, remainder = clique.assemble(files, minimum_items=1)
|
||||
assert not remainder, (
|
||||
"There shouldn't have been a remainder for '%s': "
|
||||
"%s" % (instance[0], remainder)
|
||||
)
|
||||
assert len(collections) == 1, (
|
||||
"There should only be one image sequence in {}. Found: {}".format(
|
||||
path, len(collections)
|
||||
)
|
||||
)
|
||||
|
||||
extension = os.path.splitext(list(collections[0])[0])[-1][1:]
|
||||
representation = {
|
||||
"name": extension,
|
||||
"ext": extension,
|
||||
"files": list(collections[0]),
|
||||
"stagingDir": path,
|
||||
}
|
||||
instance.data["representations"] = [representation]
|
||||
|
||||
self.log.info("Extracted {instance} to {path}".format(**locals()))
|
||||
Loading…
Add table
Add a link
Reference in a new issue