From 0e2a69b4235b3fe016e8d754f5e6d5af570c32ae Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Fri, 11 Oct 2024 16:36:18 -0400 Subject: [PATCH] EMSUSD-1718 automatically close prefs when changing units When the USD import needs to change the Maya units preferences, we need to close the preferences window, otherwise it will overwrite the preferences when closed. --- lib/mayaUsd/fileio/jobs/readJob.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/mayaUsd/fileio/jobs/readJob.cpp b/lib/mayaUsd/fileio/jobs/readJob.cpp index ad2d702c84..d7d5caf802 100644 --- a/lib/mayaUsd/fileio/jobs/readJob.cpp +++ b/lib/mayaUsd/fileio/jobs/readJob.cpp @@ -756,7 +756,15 @@ void UsdMaya_ReadJob::_ConvertUpAxisAndUnitsByChangingMayaPrefs( } else { const MString mayaUnitText = UsdMayaUtil::ConvertMDistanceUnitToText(mayaUnit); MString changeUnitsCmd; - changeUnitsCmd.format("currentUnit -linear ^1s;", mayaUnitText); + changeUnitsCmd.format( + "global string $gPreferenceWindow;\n" + "if (`window -query -exists $gPreferenceWindow`) {\n" + " if (`window -query -visible $gPreferenceWindow`) {\n" + " window -edit -visible off $gPreferenceWindow;\n" + " }\n" + "}\n" + "currentUnit -linear ^1s;", + mayaUnitText); // Note: we *must* execute the units change on-idle because the import process // saves and restores all units! If we change it now, the change would be lost.