This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hiero Resolve Entries: Add global resolve entries used to be able to …
…add width and height tokens
- Loading branch information
1 parent
d9731d0
commit 9028b7a
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
openpype/hosts/hiero/api/startup/Python/StartupUI/add_resolve_entries.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |