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

EMSUSD-291 Refactored MayaUSD help content ids #3255

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 4 additions & 16 deletions lib/mayaUsd/resources/scripts/mayaUsdDuplicateAsUsdDataOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from mayaUsdLibRegisterStrings import getMayaUsdLibString
from mayaUsdMergeToUSDOptions import getDefaultMergeToUSDOptionsDict
import mayaUsdOptions

from mayaUsd_help import *
from functools import partial


Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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():
"""
Expand Down
19 changes: 4 additions & 15 deletions lib/mayaUsd/resources/scripts/mayaUsdMergeToUSDOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import maya.cmds as cmds
import maya.mel as mel

from mayaUsd_help import *
from mayaUsdLibRegisterStrings import getMayaUsdLibString
import mayaUsdOptions

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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():
Expand Down
3 changes: 2 additions & 1 deletion lib/usd/ui/importDialog/USDImportDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion lib/usd/ui/layerEditor/mayaCommandHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions plugin/adsk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 8 additions & 0 deletions plugin/adsk/helpTable/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ---------------------------------------------------------------------------------------------
# install
# ---------------------------------------------------------------------------------------------

install(FILES "helpTableMayaUSD"
DESTINATION "${INSTALL_DIR_SUFFIX}/helpTable"
)

10 changes: 10 additions & 0 deletions plugin/adsk/helpTable/helpTableMayaUSD
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
UsdEditDuplicateAsMaya
?contextId=UsdEditDuplicateAsMaya
UsdHierarchyView
?contextId=UsdHierarchyView
UsdImportOptionsConfig
?contextId=UsdImportOptionsConfig
UsdLayerEditor
?contextId=UsdLayerEditor
UsdMergeMayaEditsToUsd
?contextId=UsdMergeMayaEditsToUsd
1 change: 1 addition & 0 deletions plugin/adsk/scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugin/adsk/scripts/USDMenuProc.mel
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
47 changes: 47 additions & 0 deletions plugin/adsk/scripts/mayaUsd_help.py
Original file line number Diff line number Diff line change
@@ -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"')