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

nuke: bake preset single input exception #2331

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions openpype/hosts/nuke/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, *args, **kwargs):
self.data["subset"]):
msg = ("The subset name `{0}` is already used on a node in"
"this workfile.".format(self.data["subset"]))
self.log.error(msg + '\n\nPlease use other subset name!')
self.log.error(msg + "\n\nPlease use other subset name!")
raise NameError("`{0}: {1}".format(__name__, msg))
return

Expand All @@ -53,15 +53,15 @@ class NukeLoader(api.Loader):
container_id = None

def reset_container_id(self):
self.container_id = ''.join(random.choice(
self.container_id = "".join(random.choice(
string.ascii_uppercase + string.digits) for _ in range(10))

def get_container_id(self, node):
id_knob = node.knobs().get(self.container_id_knob)
return id_knob.value() if id_knob else None

def get_members(self, source):
"""Return nodes that has same 'containerId' as `source`"""
"""Return nodes that has same "containerId" as `source`"""
source_id = self.get_container_id(source)
return [node for node in nuke.allNodes(recurseGroups=True)
if self.get_container_id(node) == source_id
Expand Down Expand Up @@ -116,11 +116,13 @@ class ExporterReview(object):

def __init__(self,
klass,
instance
instance,
multiple_presets=True
):

self.log = klass.log
self.instance = instance
self.multiple_presets = multiple_presets
self.path_in = self.instance.data.get("path", None)
self.staging_dir = self.instance.data["stagingDir"]
self.collection = self.instance.data.get("collection", None)
Expand Down Expand Up @@ -152,12 +154,10 @@ def get_file_info(self):

def get_representation_data(self, tags=None, range=False):
add_tags = tags or []

repre = {
'outputName': self.name,
'name': self.name,
'ext': self.ext,
'files': self.file,
"name": self.name,
"ext": self.ext,
"files": self.file,
"stagingDir": self.staging_dir,
"tags": [self.name.replace("_", "-")] + add_tags
}
Expand All @@ -168,6 +168,9 @@ def get_representation_data(self, tags=None, range=False):
"frameEnd": self.last_frame,
})

if self.multiple_presets:
repre["outputName"] = self.name

self.data["representations"].append(repre)

def get_view_input_process_node(self):
Expand All @@ -183,19 +186,19 @@ def get_view_input_process_node(self):
anlib.reset_selection()
ipn_orig = None
for v in nuke.allNodes(filter="Viewer"):
ip = v['input_process'].getValue()
ipn = v['input_process_node'].getValue()
ip = v["input_process"].getValue()
ipn = v["input_process_node"].getValue()
if "VIEWER_INPUT" not in ipn and ip:
ipn_orig = nuke.toNode(ipn)
ipn_orig.setSelected(True)

if ipn_orig:
# copy selected to clipboard
nuke.nodeCopy('%clipboard%')
nuke.nodeCopy("%clipboard%")
# reset selection
anlib.reset_selection()
# paste node and selection is on it only
nuke.nodePaste('%clipboard%')
nuke.nodePaste("%clipboard%")
# assign to variable
ipn = nuke.selectedNode()

Expand Down Expand Up @@ -234,9 +237,11 @@ def __init__(self,
ext=None,
cube_size=None,
lut_size=None,
lut_style=None):
lut_style=None,
multiple_presets=True):
# initialize parent class
super(ExporterReviewLut, self).__init__(klass, instance)
super(ExporterReviewLut, self).__init__(
klass, instance, multiple_presets)

# deal with now lut defined in viewer lut
if hasattr(klass, "viewer_lut_raw"):
Expand Down Expand Up @@ -349,9 +354,11 @@ def __init__(self,
instance,
name=None,
ext=None,
multiple_presets=True
):
# initialize parent class
super(ExporterReviewMov, self).__init__(klass, instance)
super(ExporterReviewMov, self).__init__(
klass, instance, multiple_presets)
# passing presets for nodes to self
self.nodes = klass.nodes if hasattr(klass, "nodes") else {}

Expand Down
10 changes: 8 additions & 2 deletions openpype/hosts/nuke/plugins/publish/extract_review_data_mov.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def process(self, instance):
instance.data["representations"] = []

staging_dir = os.path.normpath(
os.path.dirname(instance.data['path']))
os.path.dirname(instance.data["path"]))

instance.data["stagingDir"] = staging_dir

Expand Down Expand Up @@ -83,9 +83,15 @@ def process(self, instance):
"Baking output `{}` with settings: {}".format(
o_name, o_data))

# check if settings have more then one preset
# so we dont need to add outputName to representation
# in case there is only one preset
multiple_presets = bool(len(self.outputs.keys()) > 1)

# create exporter instance
exporter = plugin.ExporterReviewMov(
self, instance, o_name, o_data["extension"])
self, instance, o_name, o_data["extension"],
multiple_presets)

if "render.farm" in families:
if "review" in instance.data["families"]:
Expand Down