From 37e17f3ba03d6b0c101492d9d9a7da41be5fedc9 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 15 Jun 2023 14:52:41 +0800 Subject: [PATCH 01/13] bug fix the standin being not loaded when they are first loaded --- .../hosts/maya/plugins/load/load_arnold_standin.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_arnold_standin.py b/openpype/hosts/maya/plugins/load/load_arnold_standin.py index 7c3a732389..dd2e8d0885 100644 --- a/openpype/hosts/maya/plugins/load/load_arnold_standin.py +++ b/openpype/hosts/maya/plugins/load/load_arnold_standin.py @@ -1,5 +1,6 @@ import os import clique +import time import maya.cmds as cmds @@ -35,9 +36,14 @@ class ArnoldStandinLoader(load.LoaderPlugin): color = "orange" def load(self, context, name, namespace, options): - - # Make sure to load arnold before importing `mtoa.ui.arnoldmenu` - cmds.loadPlugin("mtoa", quiet=True) + # Make sure user has loaded arnold before importing `mtoa.ui.arnoldmenu` + # and getting attribute from defaultArnoldRenderOption.operator + # Otherwises standins will not be loaded successfully for + # every first time using this loader after the build + if not cmds.pluginInfo("mtoa", query=True, loaded=True): + raise RuntimeError("Plugin 'mtoa' must be loaded" + " before using this loader") + # cmds.loadPlugin("mtoa", quiet=True) import mtoa.ui.arnoldmenu version = context['version'] From 9ba54ecace3a5554c737f83f489154a99d597a49 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 15 Jun 2023 15:09:40 +0800 Subject: [PATCH 02/13] hound fix --- openpype/hosts/maya/plugins/load/load_arnold_standin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_arnold_standin.py b/openpype/hosts/maya/plugins/load/load_arnold_standin.py index dd2e8d0885..f41afefcf4 100644 --- a/openpype/hosts/maya/plugins/load/load_arnold_standin.py +++ b/openpype/hosts/maya/plugins/load/load_arnold_standin.py @@ -1,6 +1,5 @@ import os import clique -import time import maya.cmds as cmds @@ -36,7 +35,8 @@ class ArnoldStandinLoader(load.LoaderPlugin): color = "orange" def load(self, context, name, namespace, options): - # Make sure user has loaded arnold before importing `mtoa.ui.arnoldmenu` + # Make sure user has loaded arnold + # before importing `mtoa.ui.arnoldmenu` # and getting attribute from defaultArnoldRenderOption.operator # Otherwises standins will not be loaded successfully for # every first time using this loader after the build From b01424111aa579f95a77b3d0b39bace1e02a8a03 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 15 Jun 2023 21:25:41 +0800 Subject: [PATCH 03/13] roy's comment --- .../maya/plugins/load/load_arnold_standin.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/load/load_arnold_standin.py b/openpype/hosts/maya/plugins/load/load_arnold_standin.py index f41afefcf4..a729e0bb06 100644 --- a/openpype/hosts/maya/plugins/load/load_arnold_standin.py +++ b/openpype/hosts/maya/plugins/load/load_arnold_standin.py @@ -23,6 +23,20 @@ def is_sequence(files): return sequence +def post_process(): + import maya.utils + from qtpy import QtWidgets + + # I'm not sure this would work, but it'd be the simplest trick to try + cmds.refresh(force=True) + + # I suspect this might work + maya.utils.processIdleEvents() + + # I suspect this one might work too but it's might be a hard to track whether it solves all cases (and whether the events were already submitted to Qt at that time this command starts to run) So I'd always try to avoid this when possible. + QtWidgets.QApplication.instance().processEvents() + + class ArnoldStandinLoader(load.LoaderPlugin): """Load as Arnold standin""" @@ -40,10 +54,13 @@ class ArnoldStandinLoader(load.LoaderPlugin): # and getting attribute from defaultArnoldRenderOption.operator # Otherwises standins will not be loaded successfully for # every first time using this loader after the build + """ if not cmds.pluginInfo("mtoa", query=True, loaded=True): raise RuntimeError("Plugin 'mtoa' must be loaded" " before using this loader") - # cmds.loadPlugin("mtoa", quiet=True) + """ + cmds.loadPlugin("mtoa", quiet=True) + post_process() import mtoa.ui.arnoldmenu version = context['version'] From 5bb476cfa439d168c4e5668c30bc7945f38713a7 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 15 Jun 2023 21:27:38 +0800 Subject: [PATCH 04/13] hound fix --- openpype/hosts/maya/plugins/load/load_arnold_standin.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_arnold_standin.py b/openpype/hosts/maya/plugins/load/load_arnold_standin.py index a729e0bb06..9016359c2f 100644 --- a/openpype/hosts/maya/plugins/load/load_arnold_standin.py +++ b/openpype/hosts/maya/plugins/load/load_arnold_standin.py @@ -27,13 +27,8 @@ def post_process(): import maya.utils from qtpy import QtWidgets - # I'm not sure this would work, but it'd be the simplest trick to try cmds.refresh(force=True) - - # I suspect this might work maya.utils.processIdleEvents() - - # I suspect this one might work too but it's might be a hard to track whether it solves all cases (and whether the events were already submitted to Qt at that time this command starts to run) So I'd always try to avoid this when possible. QtWidgets.QApplication.instance().processEvents() From d077491617d2c1f8b95b7c86568a88c16ff290b5 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 15 Jun 2023 21:28:56 +0800 Subject: [PATCH 05/13] add docstring --- openpype/hosts/maya/plugins/load/load_arnold_standin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openpype/hosts/maya/plugins/load/load_arnold_standin.py b/openpype/hosts/maya/plugins/load/load_arnold_standin.py index 9016359c2f..f45a070c85 100644 --- a/openpype/hosts/maya/plugins/load/load_arnold_standin.py +++ b/openpype/hosts/maya/plugins/load/load_arnold_standin.py @@ -24,6 +24,10 @@ def is_sequence(files): def post_process(): + """ + Make sure mtoa script finished loading + before the loader doing any action + """ import maya.utils from qtpy import QtWidgets From 2f95aab31efdd90dbdf0b899059d87416190e329 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 15 Jun 2023 22:31:55 +0800 Subject: [PATCH 06/13] clean up the code --- .../maya/plugins/load/load_arnold_standin.py | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_arnold_standin.py b/openpype/hosts/maya/plugins/load/load_arnold_standin.py index f45a070c85..1a582647cc 100644 --- a/openpype/hosts/maya/plugins/load/load_arnold_standin.py +++ b/openpype/hosts/maya/plugins/load/load_arnold_standin.py @@ -2,6 +2,7 @@ import os import clique import maya.cmds as cmds +import maya.utils from openpype.settings import get_project_settings from openpype.pipeline import ( @@ -23,19 +24,6 @@ def is_sequence(files): return sequence -def post_process(): - """ - Make sure mtoa script finished loading - before the loader doing any action - """ - import maya.utils - from qtpy import QtWidgets - - cmds.refresh(force=True) - maya.utils.processIdleEvents() - QtWidgets.QApplication.instance().processEvents() - - class ArnoldStandinLoader(load.LoaderPlugin): """Load as Arnold standin""" @@ -48,18 +36,15 @@ class ArnoldStandinLoader(load.LoaderPlugin): color = "orange" def load(self, context, name, namespace, options): - # Make sure user has loaded arnold - # before importing `mtoa.ui.arnoldmenu` - # and getting attribute from defaultArnoldRenderOption.operator - # Otherwises standins will not be loaded successfully for - # every first time using this loader after the build - """ if not cmds.pluginInfo("mtoa", query=True, loaded=True): - raise RuntimeError("Plugin 'mtoa' must be loaded" - " before using this loader") - """ - cmds.loadPlugin("mtoa", quiet=True) - post_process() + # Allow mtoa plugin load to process all its events + # because otherwise `defaultArnoldRenderOptions.operator` + # does not exist yet and some connections to the standin + # can't be correctly generated on create resulting in an error + cmds.loadPlugin("mtoa") + cmds.refresh(force=True) + maya.utils.processIdleEvents() + import mtoa.ui.arnoldmenu version = context['version'] From c388ee94636e7eac952d7cff5c067fc03173ecb4 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 16 Jun 2023 22:08:21 +0800 Subject: [PATCH 07/13] add collector to tray publisher for getting frame range data --- .../publish/collect_anatomy_frame_range.py | 33 +++++++++++++++++++ .../project_settings/traypublisher.json | 4 +++ .../schema_project_traypublisher.json | 4 +++ 3 files changed, 41 insertions(+) create mode 100644 openpype/plugins/publish/collect_anatomy_frame_range.py diff --git a/openpype/plugins/publish/collect_anatomy_frame_range.py b/openpype/plugins/publish/collect_anatomy_frame_range.py new file mode 100644 index 0000000000..71a5dcfeb0 --- /dev/null +++ b/openpype/plugins/publish/collect_anatomy_frame_range.py @@ -0,0 +1,33 @@ +import pyblish.api + + +class CollectAnatomyFrameRange(pyblish.api.InstancePlugin): + """Collect Frame Range specific Anatomy data. + + Plugin is running for all instances on context even not active instances. + """ + + order = pyblish.api.CollectorOrder + 0.491 + label = "Collect Anatomy Frame Range" + hosts = ["traypublisher"] + + def process(self, instance): + self.log.info("Collecting Anatomy frame range.") + asset_doc = instance.data.get("assetEntity") + if not asset_doc: + self.log.info("Missing required data..") + return + + asset_data = asset_doc["data"] + for key in ( + "fps", + "frameStart", + "frameEnd", + "handleStart", + "handleEnd" + ): + if key not in instance.data and key in asset_data: + value = asset_data[key] + instance.data[key] = value + + self.log.info("Anatomy frame range collection finished.") diff --git a/openpype/settings/defaults/project_settings/traypublisher.json b/openpype/settings/defaults/project_settings/traypublisher.json index 3a42c93515..6b8bdcfcc5 100644 --- a/openpype/settings/defaults/project_settings/traypublisher.json +++ b/openpype/settings/defaults/project_settings/traypublisher.json @@ -318,6 +318,10 @@ } }, "publish": { + "CollectAnatomyFrameRange": { + "enabled": true, + "active": true + }, "ValidateFrameRange": { "enabled": true, "optional": true, diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json b/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json index 3703d82856..44442a07d4 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json @@ -343,6 +343,10 @@ "type": "schema_template", "name": "template_validate_plugin", "template_data": [ + { + "key": "CollectAnatomyFrameRange", + "label": "Collect Anatomy frame range" + }, { "key": "ValidateFrameRange", "label": "Validate frame range" From ec8c70db272ae51bb7118d6c7f359dff953efc6d Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 16 Jun 2023 22:14:06 +0800 Subject: [PATCH 08/13] delete unrelated code --- .../publish/collect_anatomy_frame_range.py | 33 +++++++++++++++++++ .../project_settings/traypublisher.json | 4 +++ .../schema_project_traypublisher.json | 4 +++ 3 files changed, 41 insertions(+) create mode 100644 openpype/plugins/publish/collect_anatomy_frame_range.py diff --git a/openpype/plugins/publish/collect_anatomy_frame_range.py b/openpype/plugins/publish/collect_anatomy_frame_range.py new file mode 100644 index 0000000000..71a5dcfeb0 --- /dev/null +++ b/openpype/plugins/publish/collect_anatomy_frame_range.py @@ -0,0 +1,33 @@ +import pyblish.api + + +class CollectAnatomyFrameRange(pyblish.api.InstancePlugin): + """Collect Frame Range specific Anatomy data. + + Plugin is running for all instances on context even not active instances. + """ + + order = pyblish.api.CollectorOrder + 0.491 + label = "Collect Anatomy Frame Range" + hosts = ["traypublisher"] + + def process(self, instance): + self.log.info("Collecting Anatomy frame range.") + asset_doc = instance.data.get("assetEntity") + if not asset_doc: + self.log.info("Missing required data..") + return + + asset_data = asset_doc["data"] + for key in ( + "fps", + "frameStart", + "frameEnd", + "handleStart", + "handleEnd" + ): + if key not in instance.data and key in asset_data: + value = asset_data[key] + instance.data[key] = value + + self.log.info("Anatomy frame range collection finished.") diff --git a/openpype/settings/defaults/project_settings/traypublisher.json b/openpype/settings/defaults/project_settings/traypublisher.json index 3a42c93515..6b8bdcfcc5 100644 --- a/openpype/settings/defaults/project_settings/traypublisher.json +++ b/openpype/settings/defaults/project_settings/traypublisher.json @@ -318,6 +318,10 @@ } }, "publish": { + "CollectAnatomyFrameRange": { + "enabled": true, + "active": true + }, "ValidateFrameRange": { "enabled": true, "optional": true, diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json b/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json index 3703d82856..44442a07d4 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json @@ -343,6 +343,10 @@ "type": "schema_template", "name": "template_validate_plugin", "template_data": [ + { + "key": "CollectAnatomyFrameRange", + "label": "Collect Anatomy frame range" + }, { "key": "ValidateFrameRange", "label": "Validate frame range" From 00eab724a4dec7df938013349cdd5ecaa9fc5645 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 16 Jun 2023 22:15:58 +0800 Subject: [PATCH 09/13] delete unrelated code --- .../publish/collect_anatomy_frame_range.py | 33 ------------------- .../project_settings/traypublisher.json | 4 --- .../schema_project_traypublisher.json | 4 --- 3 files changed, 41 deletions(-) delete mode 100644 openpype/plugins/publish/collect_anatomy_frame_range.py diff --git a/openpype/plugins/publish/collect_anatomy_frame_range.py b/openpype/plugins/publish/collect_anatomy_frame_range.py deleted file mode 100644 index 71a5dcfeb0..0000000000 --- a/openpype/plugins/publish/collect_anatomy_frame_range.py +++ /dev/null @@ -1,33 +0,0 @@ -import pyblish.api - - -class CollectAnatomyFrameRange(pyblish.api.InstancePlugin): - """Collect Frame Range specific Anatomy data. - - Plugin is running for all instances on context even not active instances. - """ - - order = pyblish.api.CollectorOrder + 0.491 - label = "Collect Anatomy Frame Range" - hosts = ["traypublisher"] - - def process(self, instance): - self.log.info("Collecting Anatomy frame range.") - asset_doc = instance.data.get("assetEntity") - if not asset_doc: - self.log.info("Missing required data..") - return - - asset_data = asset_doc["data"] - for key in ( - "fps", - "frameStart", - "frameEnd", - "handleStart", - "handleEnd" - ): - if key not in instance.data and key in asset_data: - value = asset_data[key] - instance.data[key] = value - - self.log.info("Anatomy frame range collection finished.") diff --git a/openpype/settings/defaults/project_settings/traypublisher.json b/openpype/settings/defaults/project_settings/traypublisher.json index 6b8bdcfcc5..3a42c93515 100644 --- a/openpype/settings/defaults/project_settings/traypublisher.json +++ b/openpype/settings/defaults/project_settings/traypublisher.json @@ -318,10 +318,6 @@ } }, "publish": { - "CollectAnatomyFrameRange": { - "enabled": true, - "active": true - }, "ValidateFrameRange": { "enabled": true, "optional": true, diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json b/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json index 44442a07d4..3703d82856 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json @@ -343,10 +343,6 @@ "type": "schema_template", "name": "template_validate_plugin", "template_data": [ - { - "key": "CollectAnatomyFrameRange", - "label": "Collect Anatomy frame range" - }, { "key": "ValidateFrameRange", "label": "Validate frame range" From 3314c5f282539f6688ee24ee583e53e95c6c8e04 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 19 Jun 2023 21:57:30 +0800 Subject: [PATCH 10/13] use createOptions() for defaultArnoldRenderOptions --- openpype/hosts/maya/plugins/load/load_arnold_standin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_arnold_standin.py b/openpype/hosts/maya/plugins/load/load_arnold_standin.py index 1a582647cc..d71b40e877 100644 --- a/openpype/hosts/maya/plugins/load/load_arnold_standin.py +++ b/openpype/hosts/maya/plugins/load/load_arnold_standin.py @@ -42,8 +42,10 @@ class ArnoldStandinLoader(load.LoaderPlugin): # does not exist yet and some connections to the standin # can't be correctly generated on create resulting in an error cmds.loadPlugin("mtoa") - cmds.refresh(force=True) - maya.utils.processIdleEvents() + # create defaultArnoldRenderOptions for + # `defaultArnoldRenderOptions.operator`` + from mtoa.core import createOptions + createOptions() import mtoa.ui.arnoldmenu From 92c6cee333d08bb685574f896d33abc253a6d220 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 19 Jun 2023 21:58:31 +0800 Subject: [PATCH 11/13] hound fix --- openpype/hosts/maya/plugins/load/load_arnold_standin.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/load/load_arnold_standin.py b/openpype/hosts/maya/plugins/load/load_arnold_standin.py index d71b40e877..a12ecf8f9f 100644 --- a/openpype/hosts/maya/plugins/load/load_arnold_standin.py +++ b/openpype/hosts/maya/plugins/load/load_arnold_standin.py @@ -2,7 +2,6 @@ import os import clique import maya.cmds as cmds -import maya.utils from openpype.settings import get_project_settings from openpype.pipeline import ( From 3020ccd90abdf8528052c07eb437e4bd065721f1 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 19 Jun 2023 23:00:44 +0800 Subject: [PATCH 12/13] update docstring --- .../hosts/maya/plugins/load/load_arnold_standin.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_arnold_standin.py b/openpype/hosts/maya/plugins/load/load_arnold_standin.py index a12ecf8f9f..a085f8d575 100644 --- a/openpype/hosts/maya/plugins/load/load_arnold_standin.py +++ b/openpype/hosts/maya/plugins/load/load_arnold_standin.py @@ -36,13 +36,11 @@ class ArnoldStandinLoader(load.LoaderPlugin): def load(self, context, name, namespace, options): if not cmds.pluginInfo("mtoa", query=True, loaded=True): - # Allow mtoa plugin load to process all its events - # because otherwise `defaultArnoldRenderOptions.operator` - # does not exist yet and some connections to the standin - # can't be correctly generated on create resulting in an error cmds.loadPlugin("mtoa") - # create defaultArnoldRenderOptions for - # `defaultArnoldRenderOptions.operator`` + # create defaultArnoldRenderOptions before creating aiStandin + # which tried to connect it. Since we load the plugin and directly + # create aiStandin without the defaultArnoldRenderOptions, + # here needs to create the render options for aiStandin creation. from mtoa.core import createOptions createOptions() From 4ffab0bb678855d2b963d63cb982c614099cf447 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 19 Jun 2023 23:20:08 +0800 Subject: [PATCH 13/13] update docstring --- openpype/hosts/maya/plugins/load/load_arnold_standin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_arnold_standin.py b/openpype/hosts/maya/plugins/load/load_arnold_standin.py index a085f8d575..38a7adfd7d 100644 --- a/openpype/hosts/maya/plugins/load/load_arnold_standin.py +++ b/openpype/hosts/maya/plugins/load/load_arnold_standin.py @@ -37,10 +37,10 @@ class ArnoldStandinLoader(load.LoaderPlugin): def load(self, context, name, namespace, options): if not cmds.pluginInfo("mtoa", query=True, loaded=True): cmds.loadPlugin("mtoa") - # create defaultArnoldRenderOptions before creating aiStandin - # which tried to connect it. Since we load the plugin and directly + # Create defaultArnoldRenderOptions before creating aiStandin + # which tries to connect it. Since we load the plugin and directly # create aiStandin without the defaultArnoldRenderOptions, - # here needs to create the render options for aiStandin creation. + # we need to create the render options for aiStandin creation. from mtoa.core import createOptions createOptions()