-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Backlog/framework loader nuke #557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lluisCM
wants to merge
6
commits into
backlog/framework-loader
Choose a base branch
from
backlog/framework-loader-nuke
base: backlog/framework-loader
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
95db3fc
Merge branch 'main' of github.com:ftrackhq/integrations
lluisCM 8788d36
Merge branch 'main' of github.com:ftrackhq/integrations
lluisCM 905d5ba
Merge branch 'main' of github.com:ftrackhq/integrations
lluisCM 26c3ae0
Merge branch 'main' of github.com:ftrackhq/integrations
lluisCM 2f642c3
add nuke loader modifications
lluisCM 47e3588
merge with loader
lluisCM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
52 changes: 52 additions & 0 deletions
52
projects/framework-nuke/extensions/plugins/nuke_image_loader.py
This file contains hidden or 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,52 @@ | ||
# :coding: utf-8 | ||
# :copyright: Copyright (c) 2024 ftrack | ||
import os | ||
|
||
import nuke | ||
|
||
from ftrack_utils.paths import check_image_sequence | ||
from ftrack_framework_core.plugin import BasePlugin | ||
from ftrack_framework_core.exceptions.plugin import PluginExecutionError | ||
|
||
|
||
class NukeImageLoaderPlugin(BasePlugin): | ||
'''Load an image or sequence into Nuke''' | ||
|
||
name = 'nuke_image_loader' | ||
|
||
def run(self, store): | ||
''' | ||
Expects the image to load in the :obj:`self.options`, loads the image | ||
''' | ||
image_path = store.get('component_path') | ||
if not image_path: | ||
raise PluginExecutionError(f'No image path provided in store!') | ||
|
||
n = nuke.nodes.Read() | ||
|
||
sequence_metadata = None | ||
if store.get('is_sequence'): | ||
# Expect path to be on the form folder/plate.%d.exr [1-35], convert to Nuke loadable | ||
# format | ||
sequence_metadata = check_image_sequence(image_path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use clique instead |
||
image_path = image_path[: image_path.rfind(' ')].replace( | ||
'%d', '%0{}d'.format(sequence_metadata['padding']) | ||
) | ||
else: | ||
# Check that file exists | ||
if not os.path.exists(image_path): | ||
raise PluginExecutionError( | ||
f'Image file does not exist: {image_path}' | ||
) | ||
|
||
n['file'].fromUserText(image_path) | ||
|
||
self.logger.debug(f'Created image read node, reading: {image_path}') | ||
|
||
if store.get('is_sequence'): | ||
n['first'].setValue(sequence_metadata['start']) | ||
n['last'].setValue(sequence_metadata['end']) | ||
self.logger.debug( | ||
'Image sequence frame range set: ' | ||
f'{sequence_metadata["start"]}-{sequence_metadata["end"]}' | ||
) |
33 changes: 33 additions & 0 deletions
33
projects/framework-nuke/extensions/plugins/nuke_movie_loader.py
This file contains hidden or 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,33 @@ | ||
# :coding: utf-8 | ||
# :copyright: Copyright (c) 2024 ftrack | ||
import os | ||
|
||
import nuke | ||
|
||
from ftrack_framework_core.plugin import BasePlugin | ||
from ftrack_framework_core.exceptions.plugin import PluginExecutionError | ||
|
||
|
||
class NukeMovieLoaderPlugin(BasePlugin): | ||
'''Load a movie into Nuke''' | ||
|
||
name = 'nuke_movie_loader' | ||
|
||
def run(self, store): | ||
''' | ||
Expects the movie to load in the :obj:`self.options`, loads the movie | ||
''' | ||
movie_path = store.get('component_path') | ||
if not movie_path: | ||
raise PluginExecutionError(f'No movie path provided in store!') | ||
|
||
# Check that file exists | ||
if not os.path.exists(movie_path): | ||
raise PluginExecutionError( | ||
f'Image file does not exist: {movie_path}' | ||
) | ||
|
||
n = nuke.nodes.Read() | ||
n['file'].fromUserText(movie_path) | ||
|
||
self.logger.debug(f'Created movie read node, reading: {movie_path}') |
33 changes: 33 additions & 0 deletions
33
projects/framework-nuke/extensions/tool-configs/nuke-image-loader.yaml
This file contains hidden or 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,33 @@ | ||
type: tool_config | ||
name: nuke-image-loader | ||
config_type: loader | ||
compatible: | ||
entity_types: | ||
- FileComponent | ||
supported_file_extensions: | ||
- ".png" | ||
- ".jpg" | ||
- ".jpeg" | ||
- ".exr" | ||
- ".tif" | ||
- ".tiff" | ||
- ".tga" | ||
- ".bmp" | ||
- ".hdr" | ||
- ".dpx" | ||
- ".cin" | ||
- ".psd" | ||
- ".tx" | ||
|
||
engine: | ||
- type: plugin | ||
tags: | ||
- context | ||
plugin: resolve_entity_path | ||
ui: show_component | ||
|
||
- type: plugin | ||
tags: | ||
- loader | ||
plugin: nuke_image_loader | ||
|
32 changes: 32 additions & 0 deletions
32
projects/framework-nuke/extensions/tool-configs/nuke-movie-loader.yaml
This file contains hidden or 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,32 @@ | ||
type: tool_config | ||
name: nuke-movie-loader | ||
config_type: loader | ||
compatible: | ||
entity_types: | ||
- FileComponent | ||
supported_file_extensions: | ||
- ".mov" | ||
- ".mp4" | ||
- ".avi" | ||
- ".mpg" | ||
- ".mpeg" | ||
- ".m4v" | ||
- ".mkv" | ||
- ".webm" | ||
- ".wmv" | ||
- ".flv" | ||
- ".vob" | ||
- ".ogv" | ||
|
||
engine: | ||
- type: plugin | ||
tags: | ||
- context | ||
plugin: resolve_entity_path | ||
ui: show_component | ||
|
||
- type: plugin | ||
tags: | ||
- loader | ||
plugin: nuke_movie_loader | ||
|
32 changes: 32 additions & 0 deletions
32
projects/framework-nuke/extensions/tool-configs/nuke-sequence-loader.yaml
This file contains hidden or 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,32 @@ | ||
type: tool_config | ||
name: nuke-sequence-loader | ||
config_type: loader | ||
compatible: | ||
entity_types: | ||
- SequenceComponent | ||
supported_file_extensions: | ||
- ".png" | ||
- ".jpg" | ||
- ".jpeg" | ||
- ".exr" | ||
- ".tif" | ||
- ".tiff" | ||
- ".tga" | ||
- ".bmp" | ||
- ".hdr" | ||
- ".dpx" | ||
- ".cin" | ||
- ".psd" | ||
- ".tx" | ||
engine: | ||
- type: plugin | ||
tags: | ||
- context | ||
plugin: resolve_entity_path | ||
ui: show_component | ||
|
||
- type: plugin | ||
tags: | ||
- loader | ||
plugin: nuke_image_loader | ||
|
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -7,6 +7,11 @@ | |
from functools import partial | ||
import platform | ||
|
||
try: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment from Mattias: |
||
from PySide6 import QtWidgets, QtCore | ||
except ImportError: | ||
from PySide2 import QtWidgets, QtCore | ||
|
||
import nuke, nukescripts | ||
|
||
import ftrack_api | ||
|
@@ -25,6 +30,7 @@ | |
from ftrack_utils.usage import set_usage_tracker, UsageTracker | ||
|
||
from ftrack_framework_nuke.utils import ( | ||
get_nuke_session_identifier, | ||
dock_nuke_right, | ||
find_nodegraph_viewer, | ||
run_in_main_thread, | ||
|
@@ -70,6 +76,7 @@ def get_ftrack_menu(menu_name='ftrack', submenu_name=None): | |
|
||
client_instance = None | ||
startup_tools = [] | ||
action_tools = [] | ||
|
||
|
||
@run_in_main_thread | ||
|
@@ -78,13 +85,31 @@ def on_run_tool_callback(tool_name, dialog_name=None, options=None): | |
tool_name, | ||
dialog_name, | ||
options, | ||
dock_func=partial(dock_nuke_right) if dialog_name else None, | ||
dock_func=dock_nuke_right if dialog_name else None, | ||
) | ||
# Prevent bug in Nuke were curve editor is activated on docking a panel | ||
if options.get("docked"): | ||
find_nodegraph_viewer(activate=True) | ||
|
||
|
||
@run_in_main_thread | ||
def on_subscribe_action_tool_callback( | ||
tool_name, label, dialog_name=None, options=None | ||
): | ||
client_instance.subscribe_action_tool( | ||
tool_name, | ||
label, | ||
dialog_name, | ||
options, | ||
session_identifier_func=get_nuke_session_identifier, | ||
) | ||
|
||
|
||
def on_exit(): | ||
'''Nuke shutdown, tear down client''' | ||
client_instance.close() | ||
|
||
|
||
def bootstrap_integration(framework_extensions_path): | ||
global client_instance | ||
|
||
|
@@ -171,8 +196,10 @@ def bootstrap_integration(framework_extensions_path): | |
|
||
for tool in dcc_config['tools']: | ||
run_on = tool.get("run_on") | ||
action = tool.get("action") | ||
on_menu = tool.get("menu", True) | ||
name = tool['name'] | ||
label = tool.get('label') or tool.get('name') | ||
name = tool.get('name') | ||
dialog_name = tool.get('dialog_name') | ||
options = tool.get('options', {}) | ||
# TODO: In the future, we should probably emit an event so plugins can | ||
|
@@ -185,32 +212,39 @@ def bootstrap_integration(framework_extensions_path): | |
tool['label'], | ||
f'{__name__}.onRunToolCallback("{name}","{dialog_name}", {options})', | ||
) | ||
|
||
if run_on: | ||
if run_on == "startup": | ||
# Add all tools on a global variable as they can't be executed until | ||
# root node is created. | ||
startup_tools.append( | ||
[ | ||
name, | ||
dialog_name, | ||
options, | ||
] | ||
) | ||
else: | ||
logger.error( | ||
f"Unsupported run_on value: {run_on} tool section of the " | ||
f"tool {tool.get('name')} on the tool config file: " | ||
f"{dcc_config['name']}. \n Currently supported values:" | ||
f" [startup]" | ||
) | ||
if run_on == "startup": | ||
startup_tools.append( | ||
[ | ||
name, | ||
dialog_name, | ||
options, | ||
] | ||
) | ||
if action: | ||
action_tools.append( | ||
[ | ||
name, | ||
label, | ||
dialog_name, | ||
options, | ||
] | ||
) | ||
|
||
# Add shutdown hook, for client to be properly closed when Nuke exists | ||
app = QtWidgets.QApplication.instance() | ||
app.aboutToQuit.connect(on_exit) | ||
|
||
|
||
def execute_startup_tools(): | ||
for tool in startup_tools: | ||
on_run_tool_callback(*tool) | ||
|
||
|
||
def subscribe_action_tools(): | ||
for tool in action_tools: | ||
on_subscribe_action_tool_callback(*tool) | ||
|
||
|
||
# Find and read DCC config | ||
try: | ||
bootstrap_integration(get_extensions_path_from_environment()) | ||
|
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use clique instead