om2-Convert-ResetSkinClusters to a python MPxCommand Part 1


Disclaimer:
All code here is provided as is without support.
Use at your own risk! These posts assume you have some knowledge of import/running python script in maya. If Gifs/Images are not displaying in Chrome try a different browser.

I split this into 2 posts recently as getting the base boilerplate gist has grown trying to get args to work.
Also updated to be entirely om2 as the links below head more to om1 formatting.
Hopefully this might provide some insights into converting some useful blog scripts out there to your own cmds.myNewScript() commands.

Step 1: Gathering Info

Doing a quick google. Here’s the info I found to use:

  • Maya Python Plugin Overview P1
  • Maya Python Plugin Overview P2
  • Your First Maya Python Plug-in
  • MSyntax
  • MArgParser
  • MPxCommand
    I'm choosing the more direct info as I want to understand this setup, rather than just being spoon fed a walk through which I find my brain tends to mindlessly "copy paste" from and subsequently struggles to remember wth I just did.
    Yes that means you should check through all those links at some point to flesh out your knowledge of whats going on below :)
    Now a good place to start is rounding up the boilerplate code as AutoDesk expects it.
    Boilerplate code is the same code we can expect to use over and over and over in every plugin we'll be writing ( with modifications to it for each plugin!)

    Maya Python Plugin Overview P1 has a good base to start from. How ever having listened to the video while fleshing this post I'm also going to need;
  • isUndoable() -- Returns a boolean
  • undoIt() -- Maya calls this when undo is called eg: dgModifier.undoIt() <-- more complex commands may need more
  • redoIt() -- Maya calls this when redo is called eg: dgModifier.doIt() <-- more complex commands may need more

    So I have added those into my boilerplate gist as well and I've added some additional comments in the boiler plate found in the API Doc for furture refrence for what is what.

    Why?
    Well what I'm aiming for is to have a base file I can copy paste from that gives me the entire layout for a python plugin to leverage for future plugins.
    You'll notice the above gist is already a lot of code, but it's the shell of what we need for Maya to work out what is going on. It's a chunk of data to remember, so I'm stashing it in a gist. On to part2 of the post. Part02