From 9028b7ab6e7c5ec9f571663f259e2839c15a7420 Mon Sep 17 00:00:00 2001 From: Ben Souchet Date: Wed, 11 Sep 2024 15:31:07 +0200 Subject: [PATCH] Hiero Resolve Entries: Add global resolve entries used to be able to add width and height tokens --- .../Python/StartupUI/add_resolve_entries.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 openpype/hosts/hiero/api/startup/Python/StartupUI/add_resolve_entries.py diff --git a/openpype/hosts/hiero/api/startup/Python/StartupUI/add_resolve_entries.py b/openpype/hosts/hiero/api/startup/Python/StartupUI/add_resolve_entries.py new file mode 100644 index 00000000000..4bfee4ae6b1 --- /dev/null +++ b/openpype/hosts/hiero/api/startup/Python/StartupUI/add_resolve_entries.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" +Add user resolve entries +============================== +""" + +# Import dependencies +import hiero.core # noqa + + +def global_add_resolve_entries(self, resolver): + + # Get resolution + def get_resolution(task): + if hasattr(task._item, 'source'): + width = task._item.source().mediaSource().width() + height = task._item.source().mediaSource().height() + else: + current = task._sequence if task._sequence else task._clip + width = current.format().width() + height = current.format().height() + return str(width), str(height) + + # Add resolver for width + resolver.addResolver( + "{width}", + "Returns the width of the source plate", + lambda keyword, task: get_resolution(task)[0] + ) + + # Add resolver for height + resolver.addResolver( + "{height}", + "Returns the height of the source plate", + lambda keyword, task: get_resolution(task)[1] + ) + + +# This token can be applied to ANY export so add it to the base class +hiero.core.TaskPresetBase.addUserResolveEntries = global_add_resolve_entries