From 3b1cd4743eec308176108f4b1cd145f0ca5c812d Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 4 Oct 2018 10:17:48 +0200 Subject: [PATCH 1/2] ensure time slider state is maintained when updating FPS --- colorbleed/maya/lib.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/colorbleed/maya/lib.py b/colorbleed/maya/lib.py index 2ea618c178..73794b4462 100644 --- a/colorbleed/maya/lib.py +++ b/colorbleed/maya/lib.py @@ -1404,9 +1404,19 @@ def set_scene_fps(fps, update=True): else: raise ValueError("Unsupported FPS value: `%s`" % fps) + # Get time slider current state + start_frame = cmds.playbackOptions(query=True, minTime=True) + end_frame = cmds.playbackOptions(query=True, maxTime=True) + current_frame = cmds.currentTime(query=True) + log.info("Updating FPS to '{}'".format(unit)) cmds.currentUnit(time=unit, updateAnimation=update) + # Set time slider data back to previous state + cmds.playbackOptions(edit=True, minTime=start_frame) + cmds.playbackOptions(edit=True, maxTime=end_frame) + cmds.currentTime(current_frame, edit=True, update=True) + # Force file stated to 'modified' cmds.file(modified=True) From 8b17f5b6f3a0472a03780b0516a5f165c6a8ac7d Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 4 Oct 2018 10:34:55 +0200 Subject: [PATCH 2/2] maintain animation start and end frames --- colorbleed/maya/lib.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/colorbleed/maya/lib.py b/colorbleed/maya/lib.py index 73794b4462..d4b0b8aa73 100644 --- a/colorbleed/maya/lib.py +++ b/colorbleed/maya/lib.py @@ -1407,6 +1407,11 @@ def set_scene_fps(fps, update=True): # Get time slider current state start_frame = cmds.playbackOptions(query=True, minTime=True) end_frame = cmds.playbackOptions(query=True, maxTime=True) + + # Get animation data + animation_start = cmds.playbackOptions(query=True, animationStartTime=True) + animation_end = cmds.playbackOptions(query=True, animationEndTime=True) + current_frame = cmds.currentTime(query=True) log.info("Updating FPS to '{}'".format(unit)) @@ -1415,6 +1420,11 @@ def set_scene_fps(fps, update=True): # Set time slider data back to previous state cmds.playbackOptions(edit=True, minTime=start_frame) cmds.playbackOptions(edit=True, maxTime=end_frame) + + # Set animation data + cmds.playbackOptions(edit=True, animationStartTime=animation_start) + cmds.playbackOptions(edit=True, animationEndTime=animation_end) + cmds.currentTime(current_frame, edit=True, update=True) # Force file stated to 'modified'