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

Nuke: Expose write knobs - OP-7592 #6137

Merged
10 changes: 10 additions & 0 deletions openpype/hosts/nuke/plugins/create/create_write_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ def create(self, subset_name, instance_data, pre_create_data):
instance.data_to_store()
)

settings = self.project_settings["nuke"]["create"]
exposed_knobs = settings["CreateWriteRender"]["exposed_knobs"]
write_node = nuke.allNodes(group=instance_node, filter="Write")[0]
for knob in exposed_knobs:
link = nuke.Link_Knob("")
link.makeLink(write_node.name(), knob)
link.setName(knob)
link.setFlag(0x1000)
instance_node.addKnob(link)

return instance

except Exception as er:
Expand Down
37 changes: 37 additions & 0 deletions openpype/hosts/nuke/plugins/publish/validate_write_nodes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from collections import defaultdict

import nuke

import pyblish.api
from openpype.pipeline.publish import get_errored_instances_from_context
from openpype.hosts.nuke.api.lib import (
Expand All @@ -11,6 +13,7 @@
from openpype.pipeline.publish import (
PublishXmlValidationError,
OptionalPyblishPluginMixin,
PublishValidationError
)


Expand Down Expand Up @@ -39,6 +42,19 @@ def process(self, context, plugin):

set_node_knobs_from_settings(write_node, correct_data["knobs"])

nuke_settings = instance.context.data["project_settings"]["nuke"]
create_settings = nuke_settings["create"]["CreateWriteRender"]
exposed_knobs = create_settings["exposed_knobs"]
for knob in exposed_knobs:
if knob in write_group_node.knobs():
continue

link = nuke.Link_Knob("")
link.makeLink(write_node.name(), knob)
link.setName(knob)
link.setFlag(0x1000)
write_group_node.addKnob(link)

self.log.debug("Node attributes were fixed")


Expand Down Expand Up @@ -134,6 +150,27 @@ def process(self, instance):
if check:
self._make_error(check)

nuke_settings = instance.context.data["project_settings"]["nuke"]
create_settings = nuke_settings["create"]["CreateWriteRender"]
exposed_knobs = create_settings["exposed_knobs"]
unexposed_knobs = []
for knob in exposed_knobs:
if knob not in write_group_node.knobs():
unexposed_knobs.append(knob)

"""
link = nuke.Link_Knob("")
link.makeLink(write_node.name(), knob)
link.setName(knob)
link.setFlag(0x1000)
write_group_node.addKnob(link)
"""

if unexposed_knobs:
raise PublishValidationError(
"Missing exposed knobs: {}".format(unexposed_knobs)
)

def _make_error(self, check):
# sourcery skip: merge-assign-and-aug-assign, move-assign-in-block
dbg_msg = "Write node's knobs values are not correct!\n"
Expand Down
18 changes: 15 additions & 3 deletions server_addon/nuke/server/settings/create_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ class CreateWriteRenderModel(BaseSettingsModel):
enum_resolver=instance_attributes_enum,
title="Instance attributes"
)

exposed_knobs: list[str] = Field(
title="Exposed Knobs",
default_factory=list
)
prenodes: list[PrenodeModel] = Field(
default_factory=list,
title="Preceding nodes",
Expand All @@ -80,7 +83,10 @@ class CreateWritePrerenderModel(BaseSettingsModel):
enum_resolver=instance_attributes_enum,
title="Instance attributes"
)

exposed_knobs: list[str] = Field(
title="Exposed Knobs",
default_factory=list
)
prenodes: list[PrenodeModel] = Field(
default_factory=list,
title="Preceding nodes",
Expand All @@ -106,7 +112,10 @@ class CreateWriteImageModel(BaseSettingsModel):
enum_resolver=instance_attributes_enum,
title="Instance attributes"
)

exposed_knobs: list[str] = Field(
title="Exposed Knobs",
default_factory=list
)
prenodes: list[PrenodeModel] = Field(
default_factory=list,
title="Preceding nodes",
Expand Down Expand Up @@ -145,6 +154,7 @@ class CreatorPluginsSettings(BaseSettingsModel):
"reviewable",
"farm_rendering"
],
"exposed_knobs": [],
"prenodes": [
{
"name": "Reformat01",
Expand Down Expand Up @@ -178,6 +188,7 @@ class CreatorPluginsSettings(BaseSettingsModel):
"farm_rendering",
"use_range_limit"
],
"exposed_knobs": [],
"prenodes": []
},
"CreateWriteImage": {
Expand All @@ -190,6 +201,7 @@ class CreatorPluginsSettings(BaseSettingsModel):
"instance_attributes": [
"use_range_limit"
],
"exposed_knobs": [],
"prenodes": [
{
"name": "FrameHold01",
Expand Down
2 changes: 1 addition & 1 deletion server_addon/nuke/server/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.8"
__version__ = "0.1.9"
Loading