Nuke: merging openpype and fixing the merge

This commit is contained in:
Jakub Jezek 2021-04-06 15:42:52 +02:00
parent b149febc79
commit 36f08f595f
No known key found for this signature in database
GPG key ID: C4B96E101D2A47F3
10 changed files with 114 additions and 2121 deletions

View file

@ -2,16 +2,12 @@ import os
import sys
import nuke
from avalon import api as avalon
from openpype.tools import workfiles
from pyblish import api as pyblish
import avalon.api
import pyblish.api
from pype.api import Logger
from openpype.api import Logger
import openpype.hosts.nuke
from . import lib, menu
self = sys.modules[__name__]
self.workfiles_launched = False
log = Logger().get_logger(__name__)
AVALON_CONFIG = os.getenv("AVALON_CONFIG", "pype")
@ -25,7 +21,7 @@ INVENTORY_PATH = os.path.join(PLUGINS_DIR, "inventory")
# registering pyblish gui regarding settings in presets
if os.getenv("PYBLISH_GUI", None):
pyblish.register_gui(os.getenv("PYBLISH_GUI", None))
pyblish.api.register_gui(os.getenv("PYBLISH_GUI", None))
def reload_config():
@ -61,15 +57,16 @@ def install():
'''
log.info("Registering Nuke plug-ins..")
pyblish.register_plugin_path(PUBLISH_PATH)
avalon.register_plugin_path(avalon.Loader, LOAD_PATH)
avalon.register_plugin_path(avalon.Creator, CREATE_PATH)
avalon.register_plugin_path(avalon.InventoryAction, INVENTORY_PATH)
pyblish.api.register_plugin_path(PUBLISH_PATH)
avalon.api.register_plugin_path(avalon.api.Loader, LOAD_PATH)
avalon.api.register_plugin_path(avalon.api.Creator, CREATE_PATH)
avalon.api.register_plugin_path(avalon.api.InventoryAction, INVENTORY_PATH)
# Register Avalon event for workfiles loading.
avalon.on("workio.open_file", lib.check_inventory_versions)
avalon.api.on("workio.open_file", lib.check_inventory_versions)
pyblish.register_callback("instanceToggled", on_pyblish_instance_toggled)
pyblish.api.register_callback(
"instanceToggled", on_pyblish_instance_toggled)
workfile_settings = lib.WorkfileSettings()
# Disable all families except for the ones we explicitly want to see
family_states = [
@ -79,39 +76,27 @@ def install():
"gizmo"
]
avalon.data["familiesStateDefault"] = False
avalon.data["familiesStateToggled"] = family_states
# Workfiles.
launch_workfiles = os.environ.get("WORKFILES_STARTUP")
if launch_workfiles:
nuke.addOnCreate(launch_workfiles_app, nodeClass="Root")
avalon.api.data["familiesStateDefault"] = False
avalon.api.data["familiesStateToggled"] = family_states
# Set context settings.
nuke.addOnCreate(workfile_settings.set_context_settings, nodeClass="Root")
# nuke.addOnCreate(workfile_settings.set_favorites, nodeClass="Root")
nuke.addOnCreate(workfile_settings.set_favorites, nodeClass="Root")
nuke.addOnCreate(lib.open_last_workfile, nodeClass="Root")
nuke.addOnCreate(lib.launch_workfiles_app, nodeClass="Root")
menu.install()
def launch_workfiles_app():
'''Function letting start workfiles after start of host
'''
if not self.workfiles_launched:
self.workfiles_launched = True
workfiles.show(os.environ["AVALON_WORKDIR"])
def uninstall():
'''Uninstalling host's integration
'''
log.info("Deregistering Nuke plug-ins..")
pyblish.deregister_plugin_path(PUBLISH_PATH)
avalon.deregister_plugin_path(avalon.Loader, LOAD_PATH)
avalon.deregister_plugin_path(avalon.Creator, CREATE_PATH)
pyblish.api.deregister_plugin_path(PUBLISH_PATH)
avalon.api.deregister_plugin_path(avalon.api.Loader, LOAD_PATH)
avalon.api.deregister_plugin_path(avalon.api.Creator, CREATE_PATH)
pyblish.deregister_callback("instanceToggled", on_pyblish_instance_toggled)
pyblish.api.deregister_callback(
"instanceToggled", on_pyblish_instance_toggled)
reload_config()
menu.uninstall()
@ -123,7 +108,7 @@ def on_pyblish_instance_toggled(instance, old_value, new_value):
log.info("instance toggle: {}, old_value: {}, new_value:{} ".format(
instance, old_value, new_value))
from avalon.nuke import (
from avalon.api.nuke import (
viewer_update_and_undo_stop,
add_publish_knob
)

View file

@ -3,9 +3,14 @@ import re
import sys
from collections import OrderedDict
from avalon import api, io, lib
from avalon.tools import workfiles
import avalon.nuke
from avalon.nuke import lib as anlib
from avalon.nuke import (
save_file, open_file
)
from openpype.api import (
Logger,
Anatomy,
@ -13,6 +18,7 @@ from openpype.api import (
get_anatomy_settings,
get_hierarchy,
get_asset,
get_current_project_settings,
config,
ApplicationManager
)
@ -25,8 +31,10 @@ log = Logger().get_logger(__name__)
self = sys.modules[__name__]
self._project = None
self.workfiles_launched = False
self._node_tab_name = "{}".format(os.getenv("AVALON_LABEL") or "Avalon")
def get_node_imageio_setting(**kwarg):
''' Get preset data for dataflow (fileType, compression, bitDepth)
'''
@ -1616,3 +1624,41 @@ def find_free_space_to_paste_nodes(
xpos = min(group_xpos)
ypos = max(group_ypos) + abs(offset)
return xpos, ypos
def launch_workfiles_app():
'''Function letting start workfiles after start of host
'''
# get state from settings
open_at_start = get_current_project_settings()["nuke"].get(
"general", {}).get("open_workfile_at_start")
# return if none is defined
if not open_at_start:
return
if not self.workfiles_launched:
self.workfiles_launched = True
workfiles.show(os.environ["AVALON_WORKDIR"])
def open_last_workfile():
# get state from settings
open_last_version = get_current_project_settings()["nuke"].get(
"general", {}).get("create_initial_workfile")
log.info("Opening last workfile...")
last_workfile_path = os.environ.get("AVALON_LAST_WORKFILE")
if not os.path.exists(last_workfile_path):
# return if none is defined
if not open_last_version:
return
save_file(last_workfile_path)
else:
# to avoid looping of the callback, remove it!
nuke.removeOnCreate(open_last_workfile, nodeClass="Root")
# open workfile
open_file(last_workfile_path)

View file

@ -1,5 +1,8 @@
{
"general": {
"open_workfile_at_start": false,
"create_initial_workfile": true
},
"menu": {
"create": "ctrl+shift+alt+c",
"publish": "ctrl+alt+p",

View file

@ -12,37 +12,47 @@
"label": "General",
"children": [
{
"type": "dict",
"collapsible": true,
"key": "menu",
"label": "OpenPype Menu shortcuts",
"children": [
{
"type": "text",
"key": "create",
"label": "Create..."
},
{
"type": "text",
"key": "publish",
"label": "Publish..."
},
{
"type": "text",
"key": "load",
"label": "Load..."
},
{
"type": "text",
"key": "manage",
"label": "Manage..."
},
{
"type": "text",
"key": "build_workfile",
"label": "Build Workfile"
}
]
"type": "boolean",
"key": "open_workfile_at_start",
"label": "Open Workfile window at start of a Nuke session"
},
{
"type": "boolean",
"key": "create_initial_workfile",
"label": "Create initial workfile version if none available"
}
]
},
{
"type": "dict",
"collapsible": true,
"key": "menu",
"label": "OpenPype Menu shortcuts",
"children": [
{
"type": "text",
"key": "create",
"label": "Create..."
},
{
"type": "text",
"key": "publish",
"label": "Publish..."
},
{
"type": "text",
"key": "load",
"label": "Load..."
},
{
"type": "text",
"key": "manage",
"label": "Manage..."
},
{
"type": "text",
"key": "build_workfile",
"label": "Build Workfile"
}
]
},
@ -87,7 +97,7 @@
"name": "schema_nuke_publish",
"template_data": []
},
{
{
"type": "schema",
"name": "schema_nuke_load",
"template_data": []
@ -101,4 +111,4 @@
"name": "schema_publish_gui_filter"
}
]
}
}

View file

@ -1,126 +0,0 @@
import os
import sys
import nuke
import avalon.api
import pyblish.api
from pype.api import Logger
import pype.hosts.nuke
from . import lib, menu
log = Logger().get_logger(__name__)
AVALON_CONFIG = os.getenv("AVALON_CONFIG", "pype")
HOST_DIR = os.path.dirname(os.path.abspath(pype.hosts.nuke.__file__))
PLUGINS_DIR = os.path.join(HOST_DIR, "plugins")
PUBLISH_PATH = os.path.join(PLUGINS_DIR, "publish")
LOAD_PATH = os.path.join(PLUGINS_DIR, "load")
CREATE_PATH = os.path.join(PLUGINS_DIR, "create")
INVENTORY_PATH = os.path.join(PLUGINS_DIR, "inventory")
# registering pyblish gui regarding settings in presets
if os.getenv("PYBLISH_GUI", None):
pyblish.api.register_gui(os.getenv("PYBLISH_GUI", None))
def reload_config():
"""Attempt to reload pipeline at run-time.
CAUTION: This is primarily for development and debugging purposes.
"""
import importlib
for module in (
"{}.api".format(AVALON_CONFIG),
"{}.hosts.nuke.api.actions".format(AVALON_CONFIG),
"{}.hosts.nuke.api.menu".format(AVALON_CONFIG),
"{}.hosts.nuke.api.plugin".format(AVALON_CONFIG),
"{}.hosts.nuke.api.lib".format(AVALON_CONFIG),
):
log.info("Reloading module: {}...".format(module))
module = importlib.import_module(module)
try:
importlib.reload(module)
except AttributeError as e:
from importlib import reload
log.warning("Cannot reload module: {}".format(e))
reload(module)
def install():
''' Installing all requarements for Nuke host
'''
log.info("Registering Nuke plug-ins..")
pyblish.api.register_plugin_path(PUBLISH_PATH)
avalon.api.register_plugin_path(avalon.api.Loader, LOAD_PATH)
avalon.api.register_plugin_path(avalon.api.Creator, CREATE_PATH)
avalon.api.register_plugin_path(avalon.api.InventoryAction, INVENTORY_PATH)
# Register Avalon event for workfiles loading.
avalon.api.on("workio.open_file", lib.check_inventory_versions)
pyblish.api.register_callback(
"instanceToggled", on_pyblish_instance_toggled)
workfile_settings = lib.WorkfileSettings()
# Disable all families except for the ones we explicitly want to see
family_states = [
"write",
"review",
"nukenodes"
"gizmo"
]
avalon.api.data["familiesStateDefault"] = False
avalon.api.data["familiesStateToggled"] = family_states
# Set context settings.
nuke.addOnCreate(workfile_settings.set_context_settings, nodeClass="Root")
nuke.addOnCreate(workfile_settings.set_favorites, nodeClass="Root")
nuke.addOnCreate(lib.open_last_workfile, nodeClass="Root")
nuke.addOnCreate(lib.launch_workfiles_app, nodeClass="Root")
menu.install()
def uninstall():
'''Uninstalling host's integration
'''
log.info("Deregistering Nuke plug-ins..")
pyblish.api.deregister_plugin_path(PUBLISH_PATH)
avalon.api.deregister_plugin_path(avalon.api.Loader, LOAD_PATH)
avalon.api.deregister_plugin_path(avalon.api.Creator, CREATE_PATH)
pyblish.api.deregister_callback(
"instanceToggled", on_pyblish_instance_toggled)
reload_config()
menu.uninstall()
def on_pyblish_instance_toggled(instance, old_value, new_value):
"""Toggle node passthrough states on instance toggles."""
log.info("instance toggle: {}, old_value: {}, new_value:{} ".format(
instance, old_value, new_value))
from avalon.api.nuke import (
viewer_update_and_undo_stop,
add_publish_knob
)
# Whether instances should be passthrough based on new value
with viewer_update_and_undo_stop():
n = instance[0]
try:
n["publish"].value()
except ValueError:
n = add_publish_knob(n)
log.info(" `Publish` knob was added to write node..")
n["publish"].setValue(new_value)

File diff suppressed because it is too large Load diff

@ -1 +0,0 @@
Subproject commit b746fedf7286c3755a46f07ab72f4c414cd41fc0

@ -1 +0,0 @@
Subproject commit d277f474ab016e7b53479c36af87cb861d0cc53e

View file

@ -1,141 +0,0 @@
{
"general": {
"open_workfile_at_start": false,
"create_initial_workfile": true
},
"menu": {
"Pype": {
"Create...": "ctrl+shift+alt+c",
"Publish...": "ctrl+alt+p",
"Load...": "ctrl+alt+l",
"Manage...": "ctrl+alt+m",
"Build Workfile": "ctrl+alt+b"
}
},
"create": {
"CreateWriteRender": {
"fpath_template": "{work}/renders/nuke/{subset}/{subset}.{frame}.{ext}"
},
"CreateWritePrerender": {
"fpath_template": "{work}/prerenders/nuke/{subset}/{subset}.{frame}.{ext}"
}
},
"publish": {
"PreCollectNukeInstances": {
"sync_workfile_version": true
},
"ValidateKnobs": {
"enabled": false,
"knobs": {
"render": {
"review": true
}
}
},
"ValidateOutputResolution": {
"enabled": true,
"optional": true
},
"ValidateGizmo": {
"enabled": true,
"optional": true
},
"ValidateScript": {
"enabled": true,
"optional": true
},
"ValidateNukeWriteBoundingBox": {
"enabled": true,
"optional": true
},
"ExtractThumbnail": {
"enabled": true,
"nodes": {
"Reformat": [
[
"type",
"to format"
],
[
"format",
"HD_1080"
],
[
"filter",
"Lanczos6"
],
[
"black_outside",
true
],
[
"pbb",
false
]
]
}
},
"ExtractReviewDataLut": {
"enabled": false
},
"ExtractReviewDataMov": {
"enabled": true,
"viewer_lut_raw": false
},
"ExtractSlateFrame": {
"viewer_lut_raw": false
},
"NukeSubmitDeadline": {
"deadline_priority": 50,
"deadline_pool": "",
"deadline_pool_secondary": "",
"deadline_chunk_size": 1
}
},
"load": {
"LoadImage": {
"enabled": true,
"representations": []
},
"LoadMov": {
"enabled": true,
"representations": []
},
"LoadSequence": {
"enabled": true,
"representations": [
"png",
"jpg",
"exr",
""
]
}
},
"workfile_build": {
"profiles": [
{
"tasks": [
"compositing"
],
"current_context": [
{
"subset_name_filters": [],
"families": [
"render",
"plate"
],
"repre_names": [
"exr",
"dpx"
],
"loaders": [
"LoadSequence"
]
}
],
"linked_assets": []
}
]
},
"filters": {}
}

View file

@ -1,122 +0,0 @@
{
"type": "dict",
"collapsible": true,
"key": "nuke",
"label": "Nuke",
"is_file": true,
"children": [
{
"type": "dict",
"collapsible": true,
"key": "general",
"label": "General",
"children": [
{
"type": "boolean",
"key": "open_workfile_at_start",
"label": "Open Workfile window at start of a Nuke session"
},
{
"type": "boolean",
"key": "create_initial_workfile",
"label": "Create initial workfile version if none available"
}
]
},{
"type": "dict",
"collapsible": true,
"key": "menu",
"label": "Menu shortcuts",
"children": [
{
"type": "dict",
"collapsible": false,
"key": "Pype",
"label": "Pype",
"is_group": true,
"children": [
{
"type": "text",
"key": "Create...",
"label": "Create..."
},
{
"type": "text",
"key": "Publish...",
"label": "Publish..."
},
{
"type": "text",
"key": "Load...",
"label": "Load..."
},
{
"type": "text",
"key": "Manage...",
"label": "Manage..."
},
{
"type": "text",
"key": "Build Workfile",
"label": "Build Workfile"
}
]
}
]
},
{
"type": "dict",
"collapsible": true,
"key": "create",
"label": "Creator plugins",
"children": [
{
"type": "dict",
"collapsible": false,
"key": "CreateWriteRender",
"label": "CreateWriteRender",
"is_group": true,
"children": [
{
"type": "text",
"key": "fpath_template",
"label": "Path template"
}
]
},
{
"type": "dict",
"collapsible": false,
"key": "CreateWritePrerender",
"label": "CreateWritePrerender",
"is_group": true,
"children": [
{
"type": "text",
"key": "fpath_template",
"label": "Path template"
}
]
}
]
},
{
"type": "schema",
"name": "schema_nuke_publish",
"template_data": []
},
{
"type": "schema",
"name": "schema_nuke_load",
"template_data": []
},
{
"type": "schema",
"name": "schema_workfile_build"
},
{
"type": "schema",
"name": "schema_publish_gui_filter"
}
]
}