API Example Bug: Maya API polyModifier.py splitUVCmd.py example does not work properly with tweaks. Fix needed.

API Example Bug: Maya API polyModifier.py splitUVCmd.py example does not work properly with tweaks. Fix needed.

Anonymous
Not applicable
624 Views
2 Replies
Message 1 of 3

API Example Bug: Maya API polyModifier.py splitUVCmd.py example does not work properly with tweaks. Fix needed.

Anonymous
Not applicable

Hello,
In the Maya API documentation, the example splitUVCmd.py which utilizes polyModifier.py factory base class does not handle tweaks properly when using redo and undo.

 

This is the only example provided in the documentation for writing mesh modification plugins however it does not work properly. 

 

When you undo and redo the command, the generate tweak node is not reinserted back onto the end node.

 

It's a complex example,  and honestly I don't understand it fully.

 

The problem is there is no tweak cleanup function provided, its incomplete. When redoing the command the tweaks are applied twice.

 

Can someone at autodesk at least fix the provided official example files?

 

To reproduce:

run splitUVcmd.py plugin

with polyModifier.py also in the same directory

 

use it on UV that have tweak data associated with them

try undo/redo

      see that tweak deltas are applied more than once

 

 

625 Views
2 Replies
Replies (2)
Message 2 of 3

fishypants
Participant
Participant

Just ran into this myself. Can confirm, its broken. In a multiple areas as well. I think the problem is the example relies on the MDGModifier and MDagModifer undoIt / redoIt methods, however, the part that copies the tweak values into the tweak node then resets the pnts attribute on the mesh is not part of the undoIt redoIt methods, so essentially the mesh still has the tweak data on it plus a tweak node with double tweak transformations on it.

Really wish Autodesk would update / fix this. There are some good nuggets of information in there but yeah, its incomplete and broken at the moment.

0 Likes
Message 3 of 3

fishypants
Participant
Participant

I think I actually fixed it . . . The problem was that the command to set the pnts attribute to zero was not part of the fDGModifier's command list so it never got recalled during an undo / redo operation. There is also a bug where the wrong tweak plug is referenced.

In polyModifierCmd.cpp:

Change line 736 from this:
tweak.setValue( nullVector );

To this:
fDGModifier.commandToExecute( "setAttr " + tweak.name + " 0 0 0" );

Change lines 751 + 752 from this:
tweak = meshTweakPlug.elementByLogicalIndex( fTweakIndexArray[i] );
tweak.setValue( nullVector );

To this:
tweak = upstreamTweakPlug.elementByLogicalIndex( fTweakIndexArray[ i ] );
fDGModifier.commandToExecute( "setAttr " + tweak.name + " 0 0 0" );

Haven't tested it on heavy meshes, and you might run into performance issues but at least the mechanism that resets the pnts attribute on the mesh will get included properly into the undo / redo queue. 

0 Likes