Undo Redo Maya API problem

104 views
Skip to first unread message

justin hidair

unread,
Mar 18, 2017, 4:16:41 PM3/18/17
to Python Programming for Autodesk Maya
Wrote something cool, implemented all the required method,

doIt() and redoIt works , undoIt() don't.

When I undo the object disappear, why ???
I didn't touch anything related to object visibility, I even tried to refresh the viewport , still nothing...

In doIt/redoIt method I use setVertexNormals()


MStatus setVertexNormals

( MVectorArray normalsIn,


MIntArray vertexList,


MSpace::Space  space = MSpace::kObject 

)

Set Shared Normals for these vertices.

The length of the normalsIn array should be same as the length of the vertexList array.

Parameters
[in]normalsInThe normals to set
[in]vertexListThe object-relative (mesh-relative/global) vertex indices to set them for
[in]spaceWorld space or Object space


as you can see it doesn't take a MDGModifier but setVertexNormal do :


MStatus setVertexNormal


( MVector normalIn,


int  vertexId,


MSpace::Space  space = MSpace::kObject,


MDGModifier modifier = NULL 

)

Set Shared Normal for this vertex.

Parameters
[in]normalInThe normal to set
[in]vertexIdThe object-relative (mesh-relative/global) vertex index to set it for
[in]spaceWorld space or Object space
[in,out]modifierSince this method may modify the DG, if you wish to undo its effects, you need to keep track of what needs to be undone. If the modifier is non-null, and this MFnMesh refers to a shape, then it will add the command to be undone to the modifier. Use MDGModifier::undoIt to undo the effects of this method.


setVertexNormal is a pain in the ass performance wise, so I don't want to use it...

justin hidair

unread,
Mar 19, 2017, 1:02:32 AM3/19/17
to Python Programming for Autodesk Maya
a MEL command that created a Node made this, this MEL command also modifies the apparence of the mesh has it is cmds.polySoftEdge() ... so if someone gets here would you tell me how to properly undo the change made by a MEL command in a plugin within undoIt() method ? or tell me if It's just me and I'm screwing something ?

PS : I finally found a way but without using the MEL command above, It'll still be interesting to have an answer to the latter question thanks :)

justin hidair

unread,
Mar 19, 2017, 1:30:57 AM3/19/17
to Python Programming for Autodesk Maya
also for some reason I can Undo , but at one point it will go Undo : Redo , and Redo : Redo

justin hidair

unread,
Mar 19, 2017, 2:13:52 AM3/19/17
to Python Programming for Autodesk Maya
ok this is because again of a MEL command , just realise there is om.MGlobal.executeCommand() to properly do this,  using it prevent the plugin from doing 'shit' , ho Api..
Reply all
Reply to author
Forward
0 new messages