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-114898 Improve Python bindings #2037

Merged
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
16 changes: 15 additions & 1 deletion lib/mayaUsd/python/wrapOpUndoItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ class PythonOpUndoItemList
_undoItemList.reset();
}

void undo()
{
if (_undoItemList)
ppt-adsk marked this conversation as resolved.
Show resolved Hide resolved
_undoItemList->undo();
}

void redo()
{
if (_undoItemList)
_undoItemList->redo();
}

private:
std::unique_ptr<MayaUsd::OpUndoItemList> _undoItemList;
std::unique_ptr<MayaUsd::OpUndoItemRecorder> _recorder;
Expand All @@ -73,6 +85,8 @@ void wrapOpUndoItem()
typedef PythonOpUndoItemList This;
class_<This, boost::noncopyable>("OpUndoItemList", init<>())
.def("__enter__", &This::enter)
.def("__exit__", &This::exit);
.def("__exit__", &This::exit)
.def("undo", &This::undo)
.def("redo", &This::redo);
}
}
20 changes: 14 additions & 6 deletions lib/mayaUsd/python/wrapPrimUpdaterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ using namespace boost;
PXR_NAMESPACE_USING_DIRECTIVE

namespace {
bool mergeToUsd(const std::string& nodeName)

bool mergeToUsd(const std::string& nodeName, const VtDictionary& userArgs = VtDictionary())
{
MObject obj;
MStatus status = UsdMayaUtil::GetMObjectByName(nodeName, obj);
Expand All @@ -54,9 +55,11 @@ bool mergeToUsd(const std::string& nodeName)
if (!PrimUpdaterManager::readPullInformation(dagPath, path))
return false;

return PrimUpdaterManager::getInstance().mergeToUsd(dagNode, path);
return PrimUpdaterManager::getInstance().mergeToUsd(dagNode, path, userArgs);
}

BOOST_PYTHON_FUNCTION_OVERLOADS(mergeToUsd_overloads, mergeToUsd, 1, 2)

bool editAsMaya(const std::string& ufePathString)
{
Ufe::Path path = Ufe::PathString::path(ufePathString);
Expand All @@ -80,25 +83,30 @@ bool discardEdits(const std::string& nodeName)
return PrimUpdaterManager::getInstance().discardEdits(path);
}

bool duplicate(const std::string& srcUfePathString, const std::string& dstUfePathString)
bool duplicate(
const std::string& srcUfePathString,
const std::string& dstUfePathString,
const VtDictionary& userArgs = VtDictionary())
{
Ufe::Path src = Ufe::PathString::path(srcUfePathString);
Ufe::Path dst = Ufe::PathString::path(dstUfePathString);

if (src.empty() || dst.empty())
return false;

return PrimUpdaterManager::getInstance().duplicate(src, dst);
return PrimUpdaterManager::getInstance().duplicate(src, dst, userArgs);
}

BOOST_PYTHON_FUNCTION_OVERLOADS(duplicate_overloads, duplicate, 2, 3)

} // namespace

void wrapPrimUpdaterManager()
{
class_<PrimUpdaterManager, noncopyable>("PrimUpdaterManager", no_init)
.def("mergeToUsd", mergeToUsd)
.def("mergeToUsd", mergeToUsd, mergeToUsd_overloads())
.def("editAsMaya", editAsMaya)
.def("canEditAsMaya", canEditAsMaya)
.def("discardEdits", discardEdits)
.def("duplicate", duplicate);
.def("duplicate", duplicate, duplicate_overloads());
}