Skip to content

Commit

Permalink
Merge pull request #3489 from Autodesk/bailp/EMSUSD-647/copy-shape-node
Browse files Browse the repository at this point in the history
EMSUSD-647 fix copying the proxy shape node
  • Loading branch information
seando-adsk authored Dec 1, 2023
2 parents 971d750 + e74b940 commit f0b70f3
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions lib/mayaUsd/nodes/layerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <mayaUsd/utils/utilFileSystem.h>
#include <mayaUsd/utils/utilSerialization.h>

#include <pxr/base/arch/env.h>
#include <pxr/base/tf/instantiateType.h>
#include <pxr/base/tf/weakBase.h>
#include <pxr/usd/ar/resolver.h>
Expand Down Expand Up @@ -194,6 +195,14 @@ bool isCrashing()
#endif
}

bool isCopyingSceneNodes()
{
// When Maya is copy nodes, it exports them and sets this environment
// variable during the export to let exporters know it is cutting or
// copying nodes in a temporary Maya scene file.
return PXR_NS::ArchHasEnv("MAYA_CUT_COPY_EXPORT");
}

constexpr auto kSaveOptionUICmd = "usdFileSaveOptions(true);";

} // namespace
Expand Down Expand Up @@ -412,9 +421,11 @@ void LayerDatabase::prepareForWriteCheck(bool* retCode, bool isExport)

int dialogResult = true;

if (MGlobal::kInteractive == MGlobal::mayaState() && !isCrashing()
&& LayerDatabase::instance().saveInteractionRequired()) {
MGlobal::executeCommand(kSaveOptionUICmd, dialogResult);
if (!isCopyingSceneNodes()) {
if (MGlobal::kInteractive == MGlobal::mayaState() && !isCrashing()
&& LayerDatabase::instance().saveInteractionRequired()) {
MGlobal::executeCommand(kSaveOptionUICmd, dialogResult);
}
}

if (dialogResult) {
Expand Down Expand Up @@ -619,10 +630,10 @@ bool LayerDatabase::saveUsd(bool isExport)
auto opt = MayaUsd::utils::serializeUsdEditsLocationOption();

if (MayaUsd::utils::kIgnoreUSDEdits != opt) {
// When Maya is crashing, we don't want to save the the USD file to avoid
// overwriting them with possibly unwanted data. Instead, we will save the
// USD data inside the temporary crash recovery Maya file.
if (isCrashing()) {
// When Maya is crashing or copying/cutting scene nodes, we don't want to
// save the the USD file to avoid overwriting them with possibly unwanted
// data. Instead, we will save the USD data inside the temporary crash recovery Maya file.
if (isCrashing() || isCopyingSceneNodes()) {
result = kPartiallyCompleted;
opt = MayaUsd::utils::kSaveToMayaSceneFile;
} else if (_batchSaveDelegate && _proxiesToSave.size() > 0) {
Expand Down

0 comments on commit f0b70f3

Please sign in to comment.