From 32a30127a37da7ee0ac8aee6d4a69265b70c110e Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 29 Mar 2023 23:06:21 +0200 Subject: [PATCH 1/3] Fix playblasting in Maya 2020 with override viewport options #4730 --- openpype/vendor/python/common/capture.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/openpype/vendor/python/common/capture.py b/openpype/vendor/python/common/capture.py index 09a42d84d1..e99ea5438d 100644 --- a/openpype/vendor/python/common/capture.py +++ b/openpype/vendor/python/common/capture.py @@ -733,6 +733,14 @@ def _applied_viewport_options(options, panel): options = dict(ViewportOptions, **(options or {})) + # 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() + } + # separate the plugin display filter options since they need to # be set differently (see #55) plugins = cmds.pluginDisplayFilter(query=True, listFilters=True) From 82c1dcc8f1a3c18fc51012f254d8ec7a18544d41 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 30 Mar 2023 22:32:12 +0200 Subject: [PATCH 2/3] Maya `capture.py` allow to explicitly pass `pluginObjects`. This way we can pass e.g. `gpuCacheDisplayFilter` value preset setting for a plug-in even when it might not exist as an argument. --- .../settings/defaults/project_settings/maya.json | 6 ++++-- .../schemas/schema_maya_capture.json | 11 ++++++----- openpype/vendor/python/common/capture.py | 16 ++++++++++++++-- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/openpype/settings/defaults/project_settings/maya.json b/openpype/settings/defaults/project_settings/maya.json index e914eb29f9..4b2b794a36 100644 --- a/openpype/settings/defaults/project_settings/maya.json +++ b/openpype/settings/defaults/project_settings/maya.json @@ -867,7 +867,6 @@ "dynamics": false, "fluids": false, "follicles": false, - "gpuCacheDisplayFilter": false, "greasePencils": false, "grid": false, "hairSystems": true, @@ -894,7 +893,10 @@ "polymeshes": true, "strokes": false, "subdivSurfaces": false, - "textures": false + "textures": false, + "pluginObjects": { + "gpuCacheDisplayFilter": false + } }, "Camera Options": { "displayGateMask": false, diff --git a/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_capture.json b/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_capture.json index 416e530db2..3f63f08158 100644 --- a/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_capture.json +++ b/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_capture.json @@ -422,11 +422,6 @@ "key": "follicles", "label": "Follicles" }, - { - "type": "boolean", - "key": "gpuCacheDisplayFilter", - "label": "GPU Cache" - }, { "type": "boolean", "key": "greasePencils", @@ -561,6 +556,12 @@ "type": "boolean", "key": "textures", "label": "Texture Placements" + }, + { + "type": "dict-modifiable", + "key": "pluginObjects", + "label": "Plugin Objects", + "object_type": "boolean" } ] }, diff --git a/openpype/vendor/python/common/capture.py b/openpype/vendor/python/common/capture.py index e99ea5438d..2263640d75 100644 --- a/openpype/vendor/python/common/capture.py +++ b/openpype/vendor/python/common/capture.py @@ -732,6 +732,7 @@ 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 @@ -740,11 +741,14 @@ def _applied_viewport_options(options, panel): 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) @@ -754,6 +758,14 @@ def _applied_viewport_options(options, panel): 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(): From 5b0a9772f0d9fb51fc109038c3bcf9d5008b3f88 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Fri, 31 Mar 2023 12:45:40 +0200 Subject: [PATCH 3/3] Update openpype/vendor/python/common/capture.py --- openpype/vendor/python/common/capture.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openpype/vendor/python/common/capture.py b/openpype/vendor/python/common/capture.py index 2263640d75..224699f916 100644 --- a/openpype/vendor/python/common/capture.py +++ b/openpype/vendor/python/common/capture.py @@ -757,7 +757,6 @@ 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():