From 7eaf7071b9a3adc63872a149a6f490c3b08e6ca7 Mon Sep 17 00:00:00 2001 From: Aram Azhari Date: Mon, 31 Jul 2023 11:13:56 -0400 Subject: [PATCH 1/4] EMSUSD-291 Refactored MayaUSD help content ids Moved MayaUSD Help Table into MayaUSD repo. Please refer to mayaUsd_help.py for usage. --- .../mayaUsdDuplicateAsUsdDataOptions.py | 20 ++------ .../scripts/mayaUsdMergeToUSDOptions.py | 19 ++------ lib/usd/ui/importDialog/USDImportDialog.cpp | 3 +- lib/usd/ui/layerEditor/mayaCommandHook.cpp | 6 ++- plugin/adsk/CMakeLists.txt | 1 + plugin/adsk/helpTable/CMakeLists.txt | 8 ++++ plugin/adsk/helpTable/helpTableMayaUSD | 10 ++++ plugin/adsk/scripts/CMakeLists.txt | 1 + plugin/adsk/scripts/USDMenuProc.mel | 2 +- plugin/adsk/scripts/mayaUsd_help.py | 47 +++++++++++++++++++ 10 files changed, 83 insertions(+), 34 deletions(-) create mode 100644 plugin/adsk/helpTable/CMakeLists.txt create mode 100644 plugin/adsk/helpTable/helpTableMayaUSD create mode 100644 plugin/adsk/scripts/mayaUsd_help.py diff --git a/lib/mayaUsd/resources/scripts/mayaUsdDuplicateAsUsdDataOptions.py b/lib/mayaUsd/resources/scripts/mayaUsdDuplicateAsUsdDataOptions.py index 8eb61916eb..f7f4db9732 100644 --- a/lib/mayaUsd/resources/scripts/mayaUsdDuplicateAsUsdDataOptions.py +++ b/lib/mayaUsd/resources/scripts/mayaUsdDuplicateAsUsdDataOptions.py @@ -20,7 +20,7 @@ from mayaUsdLibRegisterStrings import getMayaUsdLibString from mayaUsdMergeToUSDOptions import getDefaultMergeToUSDOptionsDict import mayaUsdOptions - +from mayaUsd_help import * from functools import partial @@ -72,9 +72,8 @@ def _createDuplicateAsUsdDataOptionsDialog(window): cmds.menuItem(label=getMayaUsdLibString("kResetSettingsMenuItem"), command=partial(_resetDuplicateAsUsdDataOptions, subLayout)) cmds.setParent(menuBarLayout) - if _hasDuplicateAsUsdDataOptionsHelp(): - menu = cmds.menu(label=getMayaUsdLibString("kHelpMenu"), parent=menuBarLayout) - cmds.menuItem(label=getMayaUsdLibString("kHelpDuplicateAsUsdDataOptionsMenuItem"), command=_helpDuplicateAsUsdDataOptions) + menu = cmds.menu(label=getMayaUsdLibString("kHelpMenu"), parent=menuBarLayout) + cmds.menuItem(label=getMayaUsdLibString("kHelpDuplicateAsUsdDataOptionsMenuItem"), command=_helpDuplicateAsUsdDataOptions) buttonsLayout = cmds.formLayout(parent=windowFormLayout) @@ -150,22 +149,11 @@ def _fillDuplicateAsUsdDataOptionsDialog(subLayout, optionsText, action): mayaUsdTranslatorExport("{subLayout}", "{action}=all;!output", "{optionsText}", "") '''.format(optionsText=optionsText, subLayout=subLayout, action=action)) - -def _hasDuplicateAsUsdDataOptionsHelp(): - """ - Returns True if the help topic for the options is available in Maya. - """ - # Note: catchQuiet returns 0 or 1, not the value, so we use a dummy assignment - # to produce the value to be returned by eval(). - url = mel.eval('''catchQuiet($url = `showHelp -q "''' + _kDuplicateAsUsdDataOptionsHelpContentId + '''"`); $a = $url;''') - return bool(url) - def _helpDuplicateAsUsdDataOptions(data=None): """ Shows help on the duplicate-as-Usd-data options dialog. """ - cmds.showHelp(_kDuplicateAsUsdDataOptionsHelpContentId) - + showHelpMayaUSD(_kDuplicateAsUsdDataOptionsHelpContentId); def _getDuplicateAsUsdDataOptionsVarName(): """ diff --git a/lib/mayaUsd/resources/scripts/mayaUsdMergeToUSDOptions.py b/lib/mayaUsd/resources/scripts/mayaUsdMergeToUSDOptions.py index 9175a761ae..1bda19bd08 100644 --- a/lib/mayaUsd/resources/scripts/mayaUsdMergeToUSDOptions.py +++ b/lib/mayaUsd/resources/scripts/mayaUsdMergeToUSDOptions.py @@ -17,6 +17,7 @@ import maya.cmds as cmds import maya.mel as mel +from mayaUsd_help import * from mayaUsdLibRegisterStrings import getMayaUsdLibString import mayaUsdOptions @@ -90,9 +91,8 @@ def _createMergeToUSDOptionsDialog(window, target): cmds.menuItem(label=getMayaUsdLibString("kResetSettingsMenuItem"), command=partial(_resetMergeToUSDOptions, target, subLayout)) cmds.setParent(menuBarLayout) - if _hasMergeToUSDOptionsHelp(): - menu = cmds.menu(label=getMayaUsdLibString("kHelpMenu"), parent=menuBarLayout) - cmds.menuItem(label=getMayaUsdLibString("kHelpMergeToUSDOptionsMenuItem"), command=_helpMergeToUSDOptions) + menu = cmds.menu(label=getMayaUsdLibString("kHelpMenu"), parent=menuBarLayout) + cmds.menuItem(label=getMayaUsdLibString("kHelpMergeToUSDOptionsMenuItem"), command=_helpMergeToUSDOptions) buttonsLayout = cmds.formLayout(parent=windowFormLayout) @@ -218,22 +218,11 @@ def _fillMergeToUSDOptionsDialog(target, subLayout, optionsText, action): mayaUsdTranslatorExport("{subLayout}", "{action}=all;!output", "{optionsText}", "") '''.format(optionsText=optionsText, subLayout=subLayout, action=action)) - -def _hasMergeToUSDOptionsHelp(): - """ - Returns True if the help topic for the options is available in Maya. - """ - # Note: catchQuiet returns 0 or 1, not the value, so we use a dummy assignment - # to produce the value to be returned by eval(). - url = mel.eval('''catchQuiet($url = `showHelp -q "''' + _kMergeToUSDOptionsHelpContentId + '''"`); $a = $url;''') - return bool(url) - def _helpMergeToUSDOptions(data=None): """ Shows help on the merge-to-USD options dialog. """ - # TODO: add help about the options UI instead of the merge command - cmds.showHelp(_kMergeToUSDOptionsHelpContentId) + showHelpMayaUSD(_kMergeToUSDOptionsHelpContentId) def _getMergeToUSDOptionsVarName(): diff --git a/lib/usd/ui/importDialog/USDImportDialog.cpp b/lib/usd/ui/importDialog/USDImportDialog.cpp index 17d18d1799..f7ca44f259 100644 --- a/lib/usd/ui/importDialog/USDImportDialog.cpp +++ b/lib/usd/ui/importDialog/USDImportDialog.cpp @@ -218,7 +218,8 @@ void USDImportDialog::onResetFileTriggered() void USDImportDialog::onHierarchyViewHelpTriggered() { - MGlobal::executeCommand("showHelp \"UsdHierarchyView\""); + MGlobal::executePythonCommand( + "from mayaUsd_help import *; showHelpMayaUSD(\"UsdHierarchyView\");"); } void USDImportDialog::onCheckedStateChanged(int nbChecked) diff --git a/lib/usd/ui/layerEditor/mayaCommandHook.cpp b/lib/usd/ui/layerEditor/mayaCommandHook.cpp index b35357c3e8..da7264289f 100644 --- a/lib/usd/ui/layerEditor/mayaCommandHook.cpp +++ b/lib/usd/ui/layerEditor/mayaCommandHook.cpp @@ -211,7 +211,11 @@ void MayaCommandHook::muteSubLayer(UsdLayer usdLayer, bool muteIt) } // Help menu callback -void MayaCommandHook::showLayerEditorHelp() { executeMel("showHelp UsdLayerEditor"); } +void MayaCommandHook::showLayerEditorHelp() +{ + MGlobal::executePythonCommand( + "from mayaUsd_help import *; showHelpMayaUSD(\"UsdLayerEditor\");"); +} // this method is used to select the prims with spec in a layer void MayaCommandHook::selectPrimsWithSpec(UsdLayer usdLayer) diff --git a/plugin/adsk/CMakeLists.txt b/plugin/adsk/CMakeLists.txt index e11bfb14f5..c20a1ce223 100644 --- a/plugin/adsk/CMakeLists.txt +++ b/plugin/adsk/CMakeLists.txt @@ -2,6 +2,7 @@ message("========== ADSK USD Plugin ==========") set(INSTALL_DIR_SUFFIX plugin/adsk) +add_subdirectory(helpTable) add_subdirectory(icons) add_subdirectory(plugin) add_subdirectory(scripts) diff --git a/plugin/adsk/helpTable/CMakeLists.txt b/plugin/adsk/helpTable/CMakeLists.txt new file mode 100644 index 0000000000..53f58fc2f9 --- /dev/null +++ b/plugin/adsk/helpTable/CMakeLists.txt @@ -0,0 +1,8 @@ +# --------------------------------------------------------------------------------------------- +# install +# --------------------------------------------------------------------------------------------- + +install(FILES "helpTableMayaUSD" + DESTINATION "${INSTALL_DIR_SUFFIX}/helpTable" + ) + diff --git a/plugin/adsk/helpTable/helpTableMayaUSD b/plugin/adsk/helpTable/helpTableMayaUSD new file mode 100644 index 0000000000..88128f41d0 --- /dev/null +++ b/plugin/adsk/helpTable/helpTableMayaUSD @@ -0,0 +1,10 @@ +UsdEditDuplicateAsMaya +?contextId=UsdEditDuplicateAsMaya +UsdHierarchyView +?contextId=UsdHierarchyView +UsdImportOptionsConfig +?contextId=UsdImportOptionsConfig +UsdLayerEditor +?contextId=UsdLayerEditor +UsdMergeMayaEditsToUsd +?contextId=UsdMergeMayaEditsToUsd \ No newline at end of file diff --git a/plugin/adsk/scripts/CMakeLists.txt b/plugin/adsk/scripts/CMakeLists.txt index 1d19e26b87..9325cee507 100644 --- a/plugin/adsk/scripts/CMakeLists.txt +++ b/plugin/adsk/scripts/CMakeLists.txt @@ -10,6 +10,7 @@ list(APPEND scripts_src mayaUsd_createStageFromFile.mel mayaUsd_createStageWithNewLayer.py mayaUsd_createStageFromAsset.mel + mayaUsd_help.py mayaUsd_imageFileDialogs.mel mayaUsd_layerEditorFileDialogs.mel mayaUsd_fileOptions.mel diff --git a/plugin/adsk/scripts/USDMenuProc.mel b/plugin/adsk/scripts/USDMenuProc.mel index aeb9314b67..03b426d362 100644 --- a/plugin/adsk/scripts/USDMenuProc.mel +++ b/plugin/adsk/scripts/USDMenuProc.mel @@ -249,7 +249,7 @@ global proc mayaUsdMenu_EditAsMayaDataOptions(string $obj) if ($helpItem != "") { menuItem -edit -label `getMayaUsdString("kHelpOnEditAsMayaDataOptions")` - -command ( "showHelp UsdImportOptionsConfig" ) + -command ("python(\"from mayaUsd_help import *; showHelpMayaUSD('UsdImportOptionsConfig');\")") $helpItem; } diff --git a/plugin/adsk/scripts/mayaUsd_help.py b/plugin/adsk/scripts/mayaUsd_help.py new file mode 100644 index 0000000000..2d860d8217 --- /dev/null +++ b/plugin/adsk/scripts/mayaUsd_help.py @@ -0,0 +1,47 @@ +# Copyright 2023 Autodesk +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +def showHelpMayaUSD(contentId): + """ + Helper method to display help content. + + Note that this is a wrapper around Maya's showHelp() method and showHelpMayaUSD() + should be used for all help contents in Maya USD. + + Example usage of this method: + + - In Python scripts: + from mayaUsd_help import * + showHelpMayaUSD("someContentId"); + + - In MEL scripts: + python(\"from mayaUsd_help import *; showHelpMayaUSD('someContentId');\") + + - In C++: + MGlobal::executePythonCommand( + "from mayaUsd_help import *; showHelpMayaUSD(\"someContentId\");"); + + Input contentId refers to the contentId that is registered in helpTableMayaUSD + file which is used to open help pages. + """ + import os + import maya.mel as mel + # Finding the path to helpTableMayaUSD file. + dirName = mel.eval('pluginInfo -q -p mayaUsdPlugin') + dirName = os.path.dirname(dirName) + "/../helpTable/" + "helpTableMayaUSD" + # Setting the default helpTable to helpTableMayaUSD + mel.eval('showHelp -helpTable "%s"; showHelp "%s";'% (dirName,contentId)) + # Restoring Maya's default helpTable + mel.eval('showHelp -helpTable "helpTable"') From 9ad80f2a5190cd723d358e52e610900f9ddf7823 Mon Sep 17 00:00:00 2001 From: Aram Azhari Date: Mon, 31 Jul 2023 11:48:50 -0400 Subject: [PATCH 2/4] Converted a tab into spaces --- plugin/adsk/scripts/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/adsk/scripts/CMakeLists.txt b/plugin/adsk/scripts/CMakeLists.txt index 9325cee507..fc5cb188cc 100644 --- a/plugin/adsk/scripts/CMakeLists.txt +++ b/plugin/adsk/scripts/CMakeLists.txt @@ -10,7 +10,7 @@ list(APPEND scripts_src mayaUsd_createStageFromFile.mel mayaUsd_createStageWithNewLayer.py mayaUsd_createStageFromAsset.mel - mayaUsd_help.py + mayaUsd_help.py mayaUsd_imageFileDialogs.mel mayaUsd_layerEditorFileDialogs.mel mayaUsd_fileOptions.mel From 82012c9406d871ec4f6e28a257ce7a24d069c513 Mon Sep 17 00:00:00 2001 From: Aram Azhari Date: Thu, 3 Aug 2023 10:58:36 -0400 Subject: [PATCH 3/4] Moved the help function to mayaUsdUtils.py. Also moved the helpTable to maya-Usd/resources folder. --- lib/mayaUsd/resources/CMakeLists.txt | 1 + .../resources}/helpTable/CMakeLists.txt | 2 +- .../resources}/helpTable/helpTableMayaUSD | 0 .../mayaUsdDuplicateAsUsdDataOptions.py | 2 +- .../scripts/mayaUsdMergeToUSDOptions.py | 2 +- lib/mayaUsd/resources/scripts/mayaUsdUtils.py | 35 ++++++++++++++ lib/usd/ui/importDialog/USDImportDialog.cpp | 2 +- lib/usd/ui/layerEditor/mayaCommandHook.cpp | 2 +- plugin/adsk/CMakeLists.txt | 1 - plugin/adsk/scripts/CMakeLists.txt | 1 - plugin/adsk/scripts/USDMenuProc.mel | 2 +- plugin/adsk/scripts/mayaUsd_help.py | 47 ------------------- 12 files changed, 42 insertions(+), 55 deletions(-) rename {plugin/adsk => lib/mayaUsd/resources}/helpTable/CMakeLists.txt (81%) rename {plugin/adsk => lib/mayaUsd/resources}/helpTable/helpTableMayaUSD (100%) delete mode 100644 plugin/adsk/scripts/mayaUsd_help.py diff --git a/lib/mayaUsd/resources/CMakeLists.txt b/lib/mayaUsd/resources/CMakeLists.txt index 9f7e4e171e..3f4fbec8f5 100644 --- a/lib/mayaUsd/resources/CMakeLists.txt +++ b/lib/mayaUsd/resources/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(ae) +add_subdirectory(helpTable) add_subdirectory(icons) add_subdirectory(scripts) diff --git a/plugin/adsk/helpTable/CMakeLists.txt b/lib/mayaUsd/resources/helpTable/CMakeLists.txt similarity index 81% rename from plugin/adsk/helpTable/CMakeLists.txt rename to lib/mayaUsd/resources/helpTable/CMakeLists.txt index 53f58fc2f9..c261ba7e46 100644 --- a/plugin/adsk/helpTable/CMakeLists.txt +++ b/lib/mayaUsd/resources/helpTable/CMakeLists.txt @@ -3,6 +3,6 @@ # --------------------------------------------------------------------------------------------- install(FILES "helpTableMayaUSD" - DESTINATION "${INSTALL_DIR_SUFFIX}/helpTable" + DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/helpTable" ) diff --git a/plugin/adsk/helpTable/helpTableMayaUSD b/lib/mayaUsd/resources/helpTable/helpTableMayaUSD similarity index 100% rename from plugin/adsk/helpTable/helpTableMayaUSD rename to lib/mayaUsd/resources/helpTable/helpTableMayaUSD diff --git a/lib/mayaUsd/resources/scripts/mayaUsdDuplicateAsUsdDataOptions.py b/lib/mayaUsd/resources/scripts/mayaUsdDuplicateAsUsdDataOptions.py index f7f4db9732..4284ec8b78 100644 --- a/lib/mayaUsd/resources/scripts/mayaUsdDuplicateAsUsdDataOptions.py +++ b/lib/mayaUsd/resources/scripts/mayaUsdDuplicateAsUsdDataOptions.py @@ -19,8 +19,8 @@ from mayaUsdLibRegisterStrings import getMayaUsdLibString from mayaUsdMergeToUSDOptions import getDefaultMergeToUSDOptionsDict +from mayaUsdUtils import showHelpMayaUSD import mayaUsdOptions -from mayaUsd_help import * from functools import partial diff --git a/lib/mayaUsd/resources/scripts/mayaUsdMergeToUSDOptions.py b/lib/mayaUsd/resources/scripts/mayaUsdMergeToUSDOptions.py index 1bda19bd08..079a902d08 100644 --- a/lib/mayaUsd/resources/scripts/mayaUsdMergeToUSDOptions.py +++ b/lib/mayaUsd/resources/scripts/mayaUsdMergeToUSDOptions.py @@ -17,8 +17,8 @@ import maya.cmds as cmds import maya.mel as mel -from mayaUsd_help import * from mayaUsdLibRegisterStrings import getMayaUsdLibString +from mayaUsdUtils import showHelpMayaUSD import mayaUsdOptions from functools import partial diff --git a/lib/mayaUsd/resources/scripts/mayaUsdUtils.py b/lib/mayaUsd/resources/scripts/mayaUsdUtils.py index 57efddd474..2ea1d9e004 100644 --- a/lib/mayaUsd/resources/scripts/mayaUsdUtils.py +++ b/lib/mayaUsd/resources/scripts/mayaUsdUtils.py @@ -193,4 +193,39 @@ def saveWantPayloadLoaded(want): opVarName = "mayaUsd_WantPayloadLoaded" cmds.optionVar(iv=(opVarName, want)) +def showHelpMayaUSD(contentId): + """ + Helper method to display help content. + + Note that this is a wrapper around Maya's showHelp() method and showHelpMayaUSD() + should be used for all help contents in Maya USD. + + Example usage of this method: + + - In Python scripts: + from mayaUsdUtils import showHelpMayaUSD + showHelpMayaUSD("someContentId"); + + - In MEL scripts: + python(\"from mayaUsdUtils import showHelpMayaUSD; showHelpMayaUSD('someContentId');\") + + - In C++: + MGlobal::executePythonCommand( + "from mayaUsdUtils import showHelpMayaUSD; showHelpMayaUSD(\"someContentId\");"); + + Input contentId refers to the contentId that is registered in helpTableMayaUSD + file which is used to open help pages. + """ + import os + try: + # Finding the path to helpTableMayaUSD file. + dirName = cmds.pluginInfo('mayaUsdPlugin', q=True, p=True) + dirName = os.path.dirname(dirName) + "/../../../lib/helpTable/" + "helpTableMayaUSD" + # Setting the default helpTable to helpTableMayaUSD + cmds.showHelp(dirName, helpTable=True) + # Showing the help content + cmds.showHelp(contentId) + finally: + # Restoring Maya's default helpTable + cmds.showHelp('helpTable', helpTable=True) diff --git a/lib/usd/ui/importDialog/USDImportDialog.cpp b/lib/usd/ui/importDialog/USDImportDialog.cpp index f7ca44f259..34c77f6d38 100644 --- a/lib/usd/ui/importDialog/USDImportDialog.cpp +++ b/lib/usd/ui/importDialog/USDImportDialog.cpp @@ -219,7 +219,7 @@ void USDImportDialog::onResetFileTriggered() void USDImportDialog::onHierarchyViewHelpTriggered() { MGlobal::executePythonCommand( - "from mayaUsd_help import *; showHelpMayaUSD(\"UsdHierarchyView\");"); + "from mayaUsdUtils import showHelpMayaUSD; showHelpMayaUSD(\"UsdHierarchyView\");"); } void USDImportDialog::onCheckedStateChanged(int nbChecked) diff --git a/lib/usd/ui/layerEditor/mayaCommandHook.cpp b/lib/usd/ui/layerEditor/mayaCommandHook.cpp index da7264289f..b5388acda3 100644 --- a/lib/usd/ui/layerEditor/mayaCommandHook.cpp +++ b/lib/usd/ui/layerEditor/mayaCommandHook.cpp @@ -214,7 +214,7 @@ void MayaCommandHook::muteSubLayer(UsdLayer usdLayer, bool muteIt) void MayaCommandHook::showLayerEditorHelp() { MGlobal::executePythonCommand( - "from mayaUsd_help import *; showHelpMayaUSD(\"UsdLayerEditor\");"); + "from mayaUsdUtils import showHelpMayaUSD; showHelpMayaUSD(\"UsdLayerEditor\");"); } // this method is used to select the prims with spec in a layer diff --git a/plugin/adsk/CMakeLists.txt b/plugin/adsk/CMakeLists.txt index c20a1ce223..e11bfb14f5 100644 --- a/plugin/adsk/CMakeLists.txt +++ b/plugin/adsk/CMakeLists.txt @@ -2,7 +2,6 @@ message("========== ADSK USD Plugin ==========") set(INSTALL_DIR_SUFFIX plugin/adsk) -add_subdirectory(helpTable) add_subdirectory(icons) add_subdirectory(plugin) add_subdirectory(scripts) diff --git a/plugin/adsk/scripts/CMakeLists.txt b/plugin/adsk/scripts/CMakeLists.txt index fc5cb188cc..1d19e26b87 100644 --- a/plugin/adsk/scripts/CMakeLists.txt +++ b/plugin/adsk/scripts/CMakeLists.txt @@ -10,7 +10,6 @@ list(APPEND scripts_src mayaUsd_createStageFromFile.mel mayaUsd_createStageWithNewLayer.py mayaUsd_createStageFromAsset.mel - mayaUsd_help.py mayaUsd_imageFileDialogs.mel mayaUsd_layerEditorFileDialogs.mel mayaUsd_fileOptions.mel diff --git a/plugin/adsk/scripts/USDMenuProc.mel b/plugin/adsk/scripts/USDMenuProc.mel index 03b426d362..0c259a8e54 100644 --- a/plugin/adsk/scripts/USDMenuProc.mel +++ b/plugin/adsk/scripts/USDMenuProc.mel @@ -249,7 +249,7 @@ global proc mayaUsdMenu_EditAsMayaDataOptions(string $obj) if ($helpItem != "") { menuItem -edit -label `getMayaUsdString("kHelpOnEditAsMayaDataOptions")` - -command ("python(\"from mayaUsd_help import *; showHelpMayaUSD('UsdImportOptionsConfig');\")") + -command ("python(\"from mayaUsdUtils import showHelpMayaUSD; showHelpMayaUSD('UsdImportOptionsConfig');\")") $helpItem; } diff --git a/plugin/adsk/scripts/mayaUsd_help.py b/plugin/adsk/scripts/mayaUsd_help.py deleted file mode 100644 index 2d860d8217..0000000000 --- a/plugin/adsk/scripts/mayaUsd_help.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2023 Autodesk -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -def showHelpMayaUSD(contentId): - """ - Helper method to display help content. - - Note that this is a wrapper around Maya's showHelp() method and showHelpMayaUSD() - should be used for all help contents in Maya USD. - - Example usage of this method: - - - In Python scripts: - from mayaUsd_help import * - showHelpMayaUSD("someContentId"); - - - In MEL scripts: - python(\"from mayaUsd_help import *; showHelpMayaUSD('someContentId');\") - - - In C++: - MGlobal::executePythonCommand( - "from mayaUsd_help import *; showHelpMayaUSD(\"someContentId\");"); - - Input contentId refers to the contentId that is registered in helpTableMayaUSD - file which is used to open help pages. - """ - import os - import maya.mel as mel - # Finding the path to helpTableMayaUSD file. - dirName = mel.eval('pluginInfo -q -p mayaUsdPlugin') - dirName = os.path.dirname(dirName) + "/../helpTable/" + "helpTableMayaUSD" - # Setting the default helpTable to helpTableMayaUSD - mel.eval('showHelp -helpTable "%s"; showHelp "%s";'% (dirName,contentId)) - # Restoring Maya's default helpTable - mel.eval('showHelp -helpTable "helpTable"') From 44801a51dbf919d3c6799c3ab7df759c6a2b39d9 Mon Sep 17 00:00:00 2001 From: Aram Azhari Date: Thu, 10 Aug 2023 11:19:44 -0400 Subject: [PATCH 4/4] Updated the helptable path to use an env variable The newly defined env variable is MAYAUSD_LIB_LOCATION which points to the 'lib' path. --- lib/mayaUsd/resources/scripts/mayaUsdUtils.py | 5 ++--- modules/mayaUSD.mod.template | 1 + modules/mayaUSD_Win.mod.template | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/mayaUsd/resources/scripts/mayaUsdUtils.py b/lib/mayaUsd/resources/scripts/mayaUsdUtils.py index 2ea1d9e004..b642ed9cb7 100644 --- a/lib/mayaUsd/resources/scripts/mayaUsdUtils.py +++ b/lib/mayaUsd/resources/scripts/mayaUsdUtils.py @@ -220,10 +220,9 @@ def showHelpMayaUSD(contentId): try: # Finding the path to helpTableMayaUSD file. - dirName = cmds.pluginInfo('mayaUsdPlugin', q=True, p=True) - dirName = os.path.dirname(dirName) + "/../../../lib/helpTable/" + "helpTableMayaUSD" + helpTablePath = os.path.join(os.environ['MAYAUSD_LIB_LOCATION'], 'helpTable/helpTableMayaUSD'); # Setting the default helpTable to helpTableMayaUSD - cmds.showHelp(dirName, helpTable=True) + cmds.showHelp(helpTablePath, helpTable=True) # Showing the help content cmds.showHelp(contentId) finally: diff --git a/modules/mayaUSD.mod.template b/modules/mayaUSD.mod.template index 7ac4a0ad5c..26d06b063d 100644 --- a/modules/mayaUSD.mod.template +++ b/modules/mayaUSD.mod.template @@ -21,6 +21,7 @@ ${PXR_OVERRIDE_PLUGINPATH_NAME}+:=lib/usd MAYAUSD_VERSION=${MAYAUSD_VERSION} PXR_MTLX_STDLIB_SEARCH_PATHS+:=libraries ${MAYAUSD_GTEST_PATH} +MAYAUSD_LIB_LOCATION:=lib + MayaUSD ${MAYAUSD_VERSION} ${CMAKE_INSTALL_PREFIX}/plugin/adsk plug-ins: plugin diff --git a/modules/mayaUSD_Win.mod.template b/modules/mayaUSD_Win.mod.template index 853d086be5..6080893317 100644 --- a/modules/mayaUSD_Win.mod.template +++ b/modules/mayaUSD_Win.mod.template @@ -29,6 +29,7 @@ ${PXR_OVERRIDE_PLUGINPATH_NAME}+:=lib/usd MAYAUSD_VERSION=${MAYAUSD_VERSION} PXR_MTLX_STDLIB_SEARCH_PATHS+:=libraries ${MAYAUSD_GTEST_PATH} +MAYAUSD_LIB_LOCATION:=lib + MayaUSD ${MAYAUSD_VERSION} ${CMAKE_INSTALL_PREFIX}/plugin/adsk plug-ins: plugin