Hello everyone, I've been trying to write a lightweight Maya Python wrapper recently, using the Open Maya API to dynamically query the unique names of objects, and cmds for setting commands. However, I've encountered a problem. When I delete an object and also set its MObject path to None, if I want to undo the deletion, cmds can indeed correctly undo it. But at this point, the MObject path has already been set to None, and since it was set directly through Python, it doesn't support undo. I would like to ask whether it is possible to retain the MObject's memory path when deleting the object? This way, when I delete an object and undo the deletion, I can still use that path
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b56166dc-9576-4f76-99db-c09e2822987dn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/87933431-bc16-4319-865b-9736280307d4n%40googlegroups.com.
Ooo more wrappers. :) I’ve got one too you could reference for things like undo.
There’s also omx, along with a comparison of the two I made not too long ago.
For a UUID, Maya already has you covered. The MObjectHandle has a .hexCode you can use that you can optionally convert to a hex code. It will survive undo/redo, as objects remain in memory for as long as they remain in the undo queue.
handle = om.MObjectHandle(mobject) hsh = handle.hashCode() hx = "%x" % hshFor undo, the approach that both cmdx and omx takes is to perform all changes via an MDGModifier and wrap it with a MPxCommand. That way, it will take its place alongside all other undoable things in Maya.
import cmdx with cmdx.DagModifier() as mod: mod.set_attr(attr, value)And here’s a standalone sandbox project for undo/redo with the API in Maya, this is the one embedded into cmdx.
Hope it helps, and good luck! :)