create camera node with Camera4 instead of Camera2 in Nuke 14.0

This commit is contained in:
Kayla Man 2024-01-11 21:10:13 +08:00
parent 399bb404c4
commit dbf02e266f
2 changed files with 21 additions and 1 deletions

View file

@ -3483,3 +3483,20 @@ def get_filenames_without_hash(filename, frame_start, frame_end):
new_filename = filename_without_hashes.format(frame)
filenames.append(new_filename)
return filenames
def create_camera_node_by_version():
"""Function to create the camera with the latest node class
For Nuke version 14.0 or later, the Camera4 camera node class
would be used
For the version before, the Camera2 camera node class
would be used
Returns:
Node: camera node
"""
nuke_version = nuke.NUKE_VERSION_STRING
nuke_number_version = next(ver for ver in re.findall("\d+\.\d+", nuke_version))
if float(nuke_number_version) >= 14.0:
return nuke.createNode("Camera4")
else:
return nuke.createNode("Camera2")

View file

@ -4,6 +4,9 @@ from openpype.hosts.nuke.api import (
NukeCreatorError,
maintained_selection
)
from openpype.hosts.nuke.api.lib import (
create_camera_node_by_version
)
class CreateCamera(NukeCreator):
@ -32,7 +35,7 @@ class CreateCamera(NukeCreator):
"Creator error: Select only camera node type")
created_node = self.selected_nodes[0]
else:
created_node = nuke.createNode("Camera2")
created_node = create_camera_node_by_version()
created_node["tile_color"].setValue(
int(self.node_color, 16))