Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Hiero Resolve Entries: Add global resolve entries used to be able to …
Browse files Browse the repository at this point in the history
…add width and height tokens
  • Loading branch information
BenSouchet committed Sep 11, 2024
1 parent d9731d0 commit 9028b7a
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9028b7a

Please sign in to comment.