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

MAYA-115170 fix export when exportRoots and stripNamespaces are combined #2590

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
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