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-1718 automatically close prefs when changing units #3960

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 28 additions & 0 deletions lib/mayaUsd/fileio/jobs/readJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,34 @@ void UsdMaya_ReadJob::_ConvertUpAxisAndUnitsByChangingMayaPrefs(
{
bool success = true;

// Close preference window if needed.
{
static const char* closePrefsCmd
= "global string $gPreferenceWindow;\n"
"if (`window -query -exists $gPreferenceWindow`) {\n"
" if (`window -query -visible $gPreferenceWindow`) {\n"
" string $title = getMayaUsdLibString(\"kAboutToChangePrefsTitle\");\n"
" string $body = getMayaUsdLibString(\"kAboutToChangePrefs\");\n"
" string $ok = getMayaUsdLibString(\"kSavePrefsChange\");\n"
" string $cancel = getMayaUsdLibString(\"kDiscardPrefsChange\");\n"
" string $result = `confirmDialog -title $title -message $body\n"
" -button $ok -button $cancel\n"
" -defaultButton $ok\n"
" -cancelButton $cancel`;\n"
" if ($result == $ok) {\n"
" savePrefsChanges;\n"
" }\n"
" else {\n"
" cancelPrefsChanges;\n"
" }\n"
" }\n"
"}\n";

if (!MGlobal::executeCommand(closePrefsCmd)) {
MGlobal::displayWarning("Failed to close the Maya preferences windows.");
}
}

// Set up-axis preferences if needed.
if (conversion.needUpAxisConversion) {
const bool rotateView = true;
Expand Down
7 changes: 7 additions & 0 deletions lib/mayaUsd/resources/scripts/mayaUsdLibRegisterStrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ def mayaUsdLibRegisterStrings():
register("kStageConversionUnknownMethod", "Unknown stage conversion method: %s")
register("kStageConversionSuccessful", "Mismatching axis/unit have been converted for accurate scale.")

# readJob.cpp
register("kAboutToChangePrefs", "The USD import is about to change the Maya preferences.\n" +
"Save your changes in the preferences window?")
register("kAboutToChangePrefsTitle", "Save Preferences")
register("kSavePrefsChange", "Save Preferences")
register("kDiscardPrefsChange", "Discard Preferences")


def registerPluginResource(pluginId, stringId, resourceStr):
'''See registerPluginResource.mel in Maya.
Expand Down