Merge pull request #4744 from BigRoy/maya_2020_fix_capture

This commit is contained in:
Milan Kolar 2023-04-03 18:01:09 +02:00 committed by GitHub
commit fc5f8ceeb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 10 deletions

View file

@ -869,7 +869,6 @@
"dynamics": false,
"fluids": false,
"follicles": false,
"gpuCacheDisplayFilter": false,
"greasePencils": false,
"grid": false,
"hairSystems": true,
@ -896,7 +895,10 @@
"polymeshes": true,
"strokes": false,
"subdivSurfaces": false,
"textures": false
"textures": false,
"pluginObjects": {
"gpuCacheDisplayFilter": false
}
},
"Camera Options": {
"displayGateMask": false,

View file

@ -426,11 +426,6 @@
"key": "follicles",
"label": "Follicles"
},
{
"type": "boolean",
"key": "gpuCacheDisplayFilter",
"label": "GPU Cache"
},
{
"type": "boolean",
"key": "greasePencils",
@ -565,6 +560,12 @@
"type": "boolean",
"key": "textures",
"label": "Texture Placements"
},
{
"type": "dict-modifiable",
"key": "pluginObjects",
"label": "Plugin Objects",
"object_type": "boolean"
}
]
},

View file

@ -732,11 +732,23 @@ def _applied_viewport_options(options, panel):
"""Context manager for applying `options` to `panel`"""
options = dict(ViewportOptions, **(options or {}))
plugin_options = options.pop("pluginObjects", {})
# BUGFIX Maya 2020 some keys in viewport options dict may not be unicode
# This is a local OpenPype edit to capture.py for issue #4730
# TODO: Remove when dropping Maya 2020 compatibility
if int(cmds.about(version=True)) <= 2020:
options = {
str(key): value for key, value in options.items()
}
plugin_options = {
str(key): value for key, value in plugin_options.items()
}
# Backwards compatibility for `pluginObjects` flattened into `options`
# separate the plugin display filter options since they need to
# be set differently (see #55)
plugins = cmds.pluginDisplayFilter(query=True, listFilters=True)
plugin_options = dict()
plugins = set(cmds.pluginDisplayFilter(query=True, listFilters=True))
for plugin in plugins:
if plugin in options:
plugin_options[plugin] = options.pop(plugin)
@ -745,7 +757,14 @@ def _applied_viewport_options(options, panel):
try:
cmds.modelEditor(panel, edit=True, **options)
except TypeError as e:
logger.error("Cannot apply options {}".format(e))
# Try to set as much as possible of the state by setting them one by
# one. This way we can also report the failing key values explicitly.
for key, value in options.items():
try:
cmds.modelEditor(panel, edit=True, **{key: value})
except TypeError:
logger.error("Failing to apply option '{}': {}".format(key,
value))
# plugin display filter options
for plugin, state in plugin_options.items():