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

EMSUSD-1612 allow duplicating material to USD #3907

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
28 changes: 21 additions & 7 deletions lib/mayaUsd/commands/PullPushCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,19 @@ MStatus parseUfePathArg(
return parseArgAsUfePath(text, outputPath);
}

MStatus parseDagPathArg(const MArgParser& argParser, int index, MDagPath& outputDagPath)
MStatus parseObjectArg(const MArgParser& argParser, int index, MObject& outputObject)
{
MString text;
MStatus status = parseTextArg(argParser, index, text);
CHECK_MSTATUS_AND_RETURN_IT(status);

return PXR_NS::UsdMayaUtil::GetMObjectByName(text, outputObject);
}

MStatus parseDagPathArg(const MArgParser& argParser, int index, MDagPath& outputDagPath)
{
MObject obj;
status = PXR_NS::UsdMayaUtil::GetMObjectByName(text, obj);
MStatus status = parseObjectArg(argParser, index, obj);
CHECK_MSTATUS_AND_RETURN_IT(status);

return MDagPath::getAPathTo(obj, outputDagPath);
Expand Down Expand Up @@ -428,11 +433,18 @@ MStatus DuplicateCommand::doIt(const MArgList& argList)
MArgParser argParser(syntax(), argList, &status);
CHECK_MSTATUS_AND_RETURN_IT(status);

status = parseUfePathArg(argParser, 0, _srcPath);
if (status != MS::kSuccess)
return reportError(status);
MObject srcMayaObject;
Ufe::Path srcPath;
status = parseUfePathArg(argParser, 0, srcPath);
if (status != MS::kSuccess) {
status = parseObjectArg(argParser, 0, srcMayaObject);
if (status != MS::kSuccess) {
return reportError(status);
}
}

status = parseUfePathArg(argParser, 1, _dstPath, true /*allowEmpty*/);
Ufe::Path dstPath;
status = parseUfePathArg(argParser, 1, dstPath, true /*allowEmpty*/);
if (status != MS::kSuccess)
return reportError(status);

Expand All @@ -452,7 +464,9 @@ MStatus DuplicateCommand::doIt(const MArgList& argList)
OpUndoItemRecorder undoRecorder(_undoItemList);

auto& manager = PXR_NS::PrimUpdaterManager::getInstance();
auto dstUfePaths = manager.duplicate(_srcPath, _dstPath, userArgs);
auto dstUfePaths = srcPath.empty()
? manager.duplicateToUsd(srcMayaObject, dstPath, userArgs)
: manager.duplicate(srcPath, dstPath, userArgs);

if (dstUfePaths.size() > 0) {
// Select the duplicate.
Expand Down
3 changes: 0 additions & 3 deletions lib/mayaUsd/commands/PullPushCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ class DuplicateCommand : public PullPushBaseCommand
private:
// Make sure callers need to call creator().
DuplicateCommand();

Ufe::Path _srcPath;
Ufe::Path _dstPath;
};

} // namespace ufe
Expand Down
Loading