Python command implementing MPxPolyTweakUVCommand

Hi!

I would like to create a simple command manipulating UV coords in Python Maya using the MPxPolyTweakUVCommand class exposed by API. What initially looked like a simply task to do, turned out to quite difficult for me :wink: This is my code:

from builtins import object
from builtins import range
import maya.OpenMaya as OpenMaya
import maya.OpenMayaMPx as OpenMayaMPx
import sys
import os


class TweakUvTest(OpenMayaMPx.MPxPolyTweakUVCommand):

    def __init__(self):
        OpenMayaMPx.MPxPolyTweakUVCommand.__init__(self)

    def isUndoable(self):
        print('isUndoable')
        return False
    
    def hasSyntax(self):
        print('hasSyntax')
        return False
    
    def newSyntax(self, *args, **kwargs):
        print('newSyntax')
    
    def parseSyntax(self, *args, **kwargs):
        print('parseSyntax')
    
    def getTweakedUVs(self, mesh, uvList, uPos, vPos):
        print('getTweakedUVs')


kPluginCmdName = "TweakUvTest"


def cmdCreator():
    return OpenMayaMPx.asMPxPtr(TweakUvTest())

def syntaxCreator():
    print('syntaxCreator')
    return OpenMaya.MSyntax()

def initializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject, "Autodesk", "1.0", "Any")
    try:
        mplugin.registerCommand(kPluginCmdName, cmdCreator, syntaxCreator)
    except:
        sys.stderr.write("Failed to register command: %s\n" % kPluginCmdName)
        raise

def uninitializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject)
    try:
        mplugin.deregisterCommand(kPluginCmdName)
    except:
        sys.stderr.write("Failed to unregister command: %s\n" % kPluginCmdName)
        raise

Unfortunately when I run the command, the getTweakedUVs method is not being called at all. The output I am getting is only:

# Error: RuntimeError: file <string> line 2: (kFailure): Unexpected Internal Failure

Any ideas whatโ€™s wrong?