Skip to content

Commit

Permalink
Merge pull request #2590 from Autodesk/t_bailp/MAYA-115170/conflicts-…
Browse files Browse the repository at this point in the history
…when-stripping-namespaces

MAYA-115170 fix export when exportRoots and stripNamespaces are combined
  • Loading branch information
neilh-adsk authored Sep 13, 2022
2 parents e80c082 + 1c00a3e commit ef43122
Show file tree
Hide file tree
Showing 6 changed files with 404 additions and 229 deletions.
25 changes: 24 additions & 1 deletion lib/mayaUsd/commands/baseExportCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <mayaUsd/fileio/jobs/jobArgs.h>
#include <mayaUsd/fileio/shading/shadingModeRegistry.h>
#include <mayaUsd/fileio/utils/writeUtil.h>
#include <mayaUsd/utils/utilDictionary.h>

#include <pxr/pxr.h>

Expand Down Expand Up @@ -332,11 +333,33 @@ MStatus MayaUSDExportCommand::doIt(const MArgList& args)
frameSamples.insert(tmpArgList.asDouble(0));
}

// The priority order for what objects get exported is (from highest to lowest):
//
// - Requesting to export the current selection.
// - Explicit export roots provided to the command.
// - Explicit objects given to the command.
// - Otherwise defaults to all objects.
//
// This priority order is embodied from code here and from code in the function
// UsdMayaUtil::GetFilteredSelectionToExport.

MSelectionList objSelList;
UsdMayaUtil::MDagPathSet dagPaths;
bool exportSelected = argData.isFlagSet(kSelectionFlag);
if (!exportSelected) {
argData.getObjects(objSelList);
if (userArgs.count(UsdMayaJobExportArgsTokens->exportRoots) > 0) {
const auto exportRoots = DictUtils::extractVector<std::string>(
userArgs, UsdMayaJobExportArgsTokens->exportRoots);
if (exportRoots.size() > 0) {
for (const std::string& root : exportRoots) {
objSelList.add(root.c_str());
}
}
}

if (objSelList.isEmpty()) {
argData.getObjects(objSelList);
}
}
UsdMayaUtil::GetFilteredSelectionToExport(exportSelected, objSelList, dagPaths);

Expand Down
Loading

0 comments on commit ef43122

Please sign in to comment.