move render resolution function to lib

This commit is contained in:
Kayla Man 2023-10-19 21:24:50 +08:00
parent 349cf6d35d
commit 977d0144d8
2 changed files with 21 additions and 21 deletions

View file

@ -483,3 +483,23 @@ def get_plugins() -> list:
plugin_info_list.append(plugin_info) plugin_info_list.append(plugin_info)
return plugin_info_list return plugin_info_list
@contextlib.contextmanager
def render_resolution(width, height):
"""Function to set render resolution option during
context
Args:
width (int): render width
height (int): render height
"""
current_renderWidth = rt.renderWidth
current_renderHeight = rt.renderHeight
try:
rt.renderWidth = width
rt.renderHeight = height
yield
finally:
rt.renderWidth = current_renderWidth
rt.renderHeight = current_renderHeight

View file

@ -2,7 +2,7 @@ import os
import logging import logging
import contextlib import contextlib
from pymxs import runtime as rt from pymxs import runtime as rt
from .lib import get_max_version from .lib import get_max_version, render_resolution
log = logging.getLogger("openpype.hosts.max") log = logging.getLogger("openpype.hosts.max")
@ -24,26 +24,6 @@ def play_preview_when_done(has_autoplay):
rt.preferences.playPreviewWhenDone = current_playback rt.preferences.playPreviewWhenDone = current_playback
@contextlib.contextmanager
def render_resolution(width, height):
"""Function to set render resolution option during
context
Args:
width (int): render width
height (int): render height
"""
current_renderWidth = rt.renderWidth
current_renderHeight = rt.renderHeight
try:
rt.renderWidth = width
rt.renderHeight = height
yield
finally:
rt.renderWidth = current_renderWidth
rt.renderHeight = current_renderHeight
@contextlib.contextmanager @contextlib.contextmanager
def viewport_camera(camera): def viewport_camera(camera):
"""Function to set viewport camera during context """Function to set viewport camera during context