Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure defaultArnoldRenderOptions are loaded when using mtoa #62

Merged
merged 2 commits into from
Jan 5, 2024
Merged
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
25 changes: 23 additions & 2 deletions src/deadline/maya_submitter/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,26 @@ class Scene:
Functionality for retrieving settings from the active scene
"""

@staticmethod
def ensure_arnold_options_loaded() -> None:
try:
maya.cmds.listAttr("defaultArnoldRenderOptions")
except ValueError:
try:
from mtoa.core import createOptions

createOptions() # defaultArnoldRenderOptions are not created until this is called
except ModuleNotFoundError:
# This shouldn't be possible but we should handle it in case a customer figures out
# a way of loading an arnold scene without mtoa
maya.cmds.confirmDialog(
title="mtoa not loaded",
message=(
"Renderer is set to Arnold but mtoa is not loaded. Please load the mtoa "
"plugin before continuing to ensure all assets are submitted."
),
)

@staticmethod
def name() -> str:
"""
Expand Down Expand Up @@ -128,6 +148,7 @@ def autotx() -> bool:
Returns True if Arnold auto - converts textures to TX
"""
if Scene.renderer() == RendererNames.arnold.value:
Scene.ensure_arnold_options_loaded()
return maya.cmds.getAttr("defaultArnoldRenderOptions.autotx")
else:
return False
Expand All @@ -138,11 +159,10 @@ def use_existing_tiled_textures() -> bool:
Returns True if Arnold uses existing TX textures
"""
if Scene.renderer() == RendererNames.arnold.value:
Scene.ensure_arnold_options_loaded()
return maya.cmds.getAttr("defaultArnoldRenderOptions.use_existing_tiled_textures")
else:
return False
arnold_options = Scene._get_arnold_options()
return arnold_options.use_existing_tiled_textures.get() if arnold_options else False

@staticmethod
def error_on_arnold_license_fail() -> bool:
Expand All @@ -151,6 +171,7 @@ def error_on_arnold_license_fail() -> bool:
is not Arnold.
"""
if Scene.renderer() == RendererNames.arnold.value:
Scene.ensure_arnold_options_loaded()
return maya.cmds.getAttr("defaultArnoldRenderOptions.abortOnLicenseFail")
else:
return True
Expand Down