From f1e64a063eab0080f9a1b2160b382581374eb126 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 30 Jun 2023 16:37:57 +0200 Subject: [PATCH] Maya: Convert frame values to integers (#5188) * convert frame values to integers * convert instance frame information to integer * fix condition in collect instances * Convert frame handles to int. * Make sure handles are integers Co-authored-by: Toke Jepsen * convert the float frame range value getting from attributes in maya to integer * hound shut * move int conversion later * safe context value conversion --------- Co-authored-by: Toke Stuart Jepsen Co-authored-by: Kayla Man --- .../maya/plugins/publish/collect_instances.py | 33 ++++++++++++++----- .../publish/collect_maya_scene_time.py | 14 ++++---- .../maya/plugins/publish/extract_playblast.py | 4 +-- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/collect_instances.py b/openpype/hosts/maya/plugins/publish/collect_instances.py index 87a4de162d..74bdc11a2c 100644 --- a/openpype/hosts/maya/plugins/publish/collect_instances.py +++ b/openpype/hosts/maya/plugins/publish/collect_instances.py @@ -104,25 +104,40 @@ class CollectInstances(pyblish.api.ContextPlugin): # Define nice label name = cmds.ls(objset, long=False)[0] # use short name - label = "{0} ({1})".format(name, - data["asset"]) + label = "{0} ({1})".format(name, data["asset"]) + + # Convert frame values to integers + for attr_name in ( + "handleStart", "handleEnd", "frameStart", "frameEnd", + ): + value = data.get(attr_name) + if value is not None: + data[attr_name] = int(value) # Append start frame and end frame to label if present - if "frameStart" and "frameEnd" in data: + if "frameStart" in data and "frameEnd" in data: # Take handles from context if not set locally on the instance for key in ["handleStart", "handleEnd"]: if key not in data: - data[key] = context.data[key] + value = context.data[key] + if value is not None: + value = int(value) + data[key] = value - data["frameStartHandle"] = data["frameStart"] - data["handleStart"] # noqa: E501 - data["frameEndHandle"] = data["frameEnd"] + data["handleEnd"] # noqa: E501 + data["frameStartHandle"] = int( + data["frameStart"] - data["handleStart"] + ) + data["frameEndHandle"] = int( + data["frameEnd"] + data["handleEnd"] + ) - label += " [{0}-{1}]".format(int(data["frameStartHandle"]), - int(data["frameEndHandle"])) + label += " [{0}-{1}]".format( + data["frameStartHandle"], data["frameEndHandle"] + ) instance.data["label"] = label - instance.data.update(data) + self.log.debug("{}".format(instance.data)) # Produce diagnostic message for any graphical # user interface interested in visualising it. diff --git a/openpype/hosts/maya/plugins/publish/collect_maya_scene_time.py b/openpype/hosts/maya/plugins/publish/collect_maya_scene_time.py index 7e198df14d..6a20cb151f 100644 --- a/openpype/hosts/maya/plugins/publish/collect_maya_scene_time.py +++ b/openpype/hosts/maya/plugins/publish/collect_maya_scene_time.py @@ -17,10 +17,12 @@ class CollectMayaSceneTime(pyblish.api.InstancePlugin): def process(self, instance): instance.data.update({ - "frameStart": cmds.playbackOptions(query=True, minTime=True), - "frameEnd": cmds.playbackOptions(query=True, maxTime=True), - "frameStartHandle": cmds.playbackOptions(query=True, - animationStartTime=True), - "frameEndHandle": cmds.playbackOptions(query=True, - animationEndTime=True) + "frameStart": int( + cmds.playbackOptions(query=True, minTime=True)), + "frameEnd": int( + cmds.playbackOptions(query=True, maxTime=True)), + "frameStartHandle": int( + cmds.playbackOptions(query=True, animationStartTime=True)), + "frameEndHandle": int( + cmds.playbackOptions(query=True, animationEndTime=True)) }) diff --git a/openpype/hosts/maya/plugins/publish/extract_playblast.py b/openpype/hosts/maya/plugins/publish/extract_playblast.py index 3ceef6f3d3..9580c13841 100644 --- a/openpype/hosts/maya/plugins/publish/extract_playblast.py +++ b/openpype/hosts/maya/plugins/publish/extract_playblast.py @@ -261,8 +261,8 @@ class ExtractPlayblast(publish.Extractor): "ext": capture_preset["Codec"]["compression"], "files": collected_files, "stagingDir": stagingdir, - "frameStart": start, - "frameEnd": end, + "frameStart": int(start), + "frameEnd": int(end), "fps": fps, "tags": tags, "camera_name": camera_node_name