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

Nuke: load clip with options from settings #3497

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
55 changes: 37 additions & 18 deletions openpype/hosts/nuke/plugins/load/load_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,28 @@ class LoadClip(plugin.NukeLoader):
script_start = int(nuke.root()["first_frame"].value())

# option gui
defaults = {
"start_at_workfile": True
options_defaults = {
"start_at_workfile": True,
"add_retime": True
}

options = [
qargparse.Boolean(
"start_at_workfile",
help="Load at workfile start frame",
default=True
)
]

node_name_template = "{class_name}_{ext}"

@classmethod
def get_options(cls, *args):
return [
qargparse.Boolean(
"start_at_workfile",
help="Load at workfile start frame",
default=cls.options_defaults["start_at_workfile"]
),
qargparse.Boolean(
"add_retime",
help="Load with retime",
default=cls.options_defaults["add_retime"]
)
]

@classmethod
def get_representations(cls):
return (
Expand All @@ -86,7 +94,10 @@ def load(self, context, name, namespace, options):
file = self.fname.replace("\\", "/")

start_at_workfile = options.get(
"start_at_workfile", self.defaults["start_at_workfile"])
"start_at_workfile", self.options_defaults["start_at_workfile"])

add_retime = options.get(
"add_retime", self.options_defaults["add_retime"])

version = context['version']
version_data = version.get("data", {})
Expand Down Expand Up @@ -151,18 +162,21 @@ def load(self, context, name, namespace, options):
data_imprint = {}
for k in add_keys:
if k == 'version':
data_imprint.update({k: context["version"]['name']})
data_imprint[k] = context["version"]['name']
elif k == 'colorspace':
colorspace = repre["data"].get(k)
colorspace = colorspace or version_data.get(k)
data_imprint["db_colorspace"] = colorspace
if used_colorspace:
data_imprint["used_colorspace"] = used_colorspace
else:
data_imprint.update(
{k: context["version"]['data'].get(k, str(None))})
data_imprint[k] = context["version"]['data'].get(
k, str(None))

data_imprint.update({"objectName": read_name})
data_imprint["objectName"] = read_name

if add_retime and version_data.get("retime", None):
data_imprint["addRetime"] = True

read_node["tile_color"].setValue(int("0x4ecd25ff", 16))

Expand All @@ -174,7 +188,7 @@ def load(self, context, name, namespace, options):
loader=self.__class__.__name__,
data=data_imprint)

if version_data.get("retime", None):
if add_retime and version_data.get("retime", None):
self._make_retimes(read_node, version_data)

self.set_as_member(read_node)
Expand All @@ -198,7 +212,12 @@ def update(self, container, representation):
read_node = nuke.toNode(container['objectName'])
file = get_representation_path(representation).replace("\\", "/")

start_at_workfile = bool("start at" in read_node['frame_mode'].value())
start_at_workfile = "start at" in read_node['frame_mode'].value()

add_retime = [
key for key in read_node.knobs().keys()
if "addRetime" in key
]

project_name = legacy_io.active_project()
version_doc = get_version_by_id(project_name, representation["parent"])
Expand Down Expand Up @@ -286,7 +305,7 @@ def update(self, container, representation):
"updated to version: {}".format(version_doc.get("name"))
)

if version_data.get("retime", None):
if add_retime and version_data.get("retime", None):
self._make_retimes(read_node, version_data)
else:
self.clear_members(read_node)
Expand Down
6 changes: 5 additions & 1 deletion openpype/settings/defaults/project_settings/nuke.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,11 @@
"LoadClip": {
"enabled": true,
"_representations": [],
"node_name_template": "{class_name}_{ext}"
"node_name_template": "{class_name}_{ext}",
"options_defaults": {
"start_at_workfile": true,
"add_retime": true
}
}
},
"workfile_builder": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,52 @@
{
"key": "LoadImage",
"label": "Image Loader"
}
]
},
{
"type": "dict",
"collapsible": true,
"key": "LoadClip",
"label": "Clip Loader",
"checkbox_key": "enabled",
"children": [
{
"type": "boolean",
"key": "enabled",
"label": "Enabled"
},
{
"type": "list",
"key": "_representations",
"label": "Representations",
"object_type": "text"
},
{
"type": "text",
"key": "node_name_template",
"label": "Node name template"
},
{
"type": "splitter"
},
{
"key": "LoadClip",
"label": "Clip Loader"
"type": "dict",
"collapsible": false,
"key": "options_defaults",
"label": "Loader option defaults",
"children": [
{
"type": "boolean",
"key": "start_at_workfile",
"label": "Start at worfile beggining"
},
{
"type": "boolean",
"key": "add_retime",
"label": "Add retime"
}
]
}
]
}
Expand Down