Skip to content

Commit

Permalink
EMSUSD-1718 automatically close prefs when changing units
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pierrebai-adsk committed Oct 11, 2024
1 parent bcb5b3e commit 0e2a69b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/mayaUsd/fileio/jobs/readJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0e2a69b

Please sign in to comment.