Author Archive

Python, Recursive Functions and Returns

Written by mattanimation. Posted in Python, Uncategorized

So, I found out the other other day that if you want to have a value returned when using a recursive function you must include the return line in each instance of the return. Example:

Incorrect way:

 def cleanMyString(self, url):
      returnURL = ''
      if ':' in str(url.encode('utf-8')):
           fixMe = url.replace(':', '_')
           self.clean(fixMe)
      elif '$' in str(url.encode('utf-8')):
           fixMe = url.replace('$', '-')
           self.clean(fixMe)
      else:
            returnURL = url
           return returnURL

The result of this method is None unless the string did not match any of the conditions to re-curse.

Correct way:

 def cleanMyString(self, url):
      returnURL = ''
      if ':' in str(url.encode('utf-8')):
           fixMe = url.replace(':', '_')
           return self.clean(fixMe)
      elif '$' in str(url.encode('utf-8')):
           fixMe = url.replace('$', '-')
           return self.clean(fixMe)
      else:
          returnURL = url
          return returnURL

 

so we can see that instead of calling the function directly we need to put return in front, otherwise we get a return value of None.

Ignore what I said about QT in Maya

Written by mattanimation. Posted in Uncategorized

Well I was reading this post by Nathan Horne of Naughty Dog and read this :

How to load a designer file
  • DO NOT USE cmds.loadUi!!!
    • seriously, don’t.. forget it exists, now.
    • Who ever wrote it needs to be punched in the mouth.

 

This abruptly caught my attention. The article itself had already convinced me to want to use PySide and PyQt to code UIs but left me on the fence wether to use the QTDesigner or not, until I read this. Either way it is a very good read, take a look and listen to the experts!

QT Interfaces in Maya

Written by mattanimation. Posted in Maya, pyQT, Python, UI

There are a many sites that have information about how to setup/create a user interface in Maya using the QT frameworks components, specifically using Qt designer. Here are a couple of links I found especially useful:

http://ivoxelstudios.com/blog/?p=51

Now this one is pretty cool because Chris covers something that I have found to be kind of annoying to with loading a UI which is wanting to be able to grab the controls from the UI.

http://www.chris-g.net/2011/06/24/maya-qt-interfaces-in-a-class/

Another great resource is from John Neumann that covers creating a UI and loading it in Maya and then adding functionality using MEL.

http://www.animateshmanimate.com/2010/07/19/maya-andqt-tutorial/

Here is a video tutorial straight from Autodesk.

http://area.autodesk.com/blogs/stevenr/maya_2011_highlight_qt_user_interface

I just wanted to add to the resource results in google and put the most basic information needed to get started which is, what do I need to do to see my interface after I have created it?

well here is the most basic code I could strip it down to(python version of course):

import maya.cmds as cmds

pathToFile = 'path/to/your/file.ui'
qtWin = cmds.loadUI(uiFile=pathToFile)
cmds.showWindow(qtWin)

Now, if that’s not easy and straight forward I don’t know what is.
But now how do you edit your components? Well, whatever you named the object in QTDesigner will be the name of the object in Maya, just refer to it in string form, for example, if I had a textScrollList in my UI I would type something like the following to add an item to it:

cmds.textScrollList('nameOfMyWidget', e=True, a='smellyFeet')

So as you can see it’s easy to type the names of widgets and edit them, but wouldn’t it be nice to have all of them stored in a dictionary somewhere for easy reference? The link to Chris G’s blog post talks about this is is a must read.

One last thing worth mentioning is the docking ability to the interface, since this IS one of those features that everyone wants at least try one time even if it’s not always necessary. This information is at the end of the autodesk video but it’s nice to just have the code you need on had right, plus google can’t really search the video for code right?

so add this to the code above and comment out the cmds.showWindow part

dockLayout = cmds.paneLayout(configuration='single', parent=qtWin)
cmds.dockControl(allowedArea='all', area='right', floating=True, content=dockLayout, label='Custom Dock')
cmds.control(qtWin, e=True, parent=dockLayout)

and thats it! You can play with some of the args to get the functionality right, like if you set “floating” to false it will start out as docked to the right side of your layout in Maya. Good Luck!

AnimSchool Malcom Rig

Written by mattanimation. Posted in Maya, Mel, Rigging

AnimSchool just released their Malcom rig. The animations they have made so far have been awesome. You can get it here:

http://www.animschool.com/DownloadOffer.aspx

Review

After downloading and taking a look at the rig I must say I was surprised at how simple the rig was for how much control can be had with it. When I say simple I mean simplicity, specifically with the arm pull-off controls, no ribbons or splines, just a floating joint. This allows for the desired effect minus some of the cpu taxing calculations of the other setups(although I fear could be broken rather easily). The controls were a little messy for my liking but better than a lot out there. Most of the rig is joint driven with just a couple of blends for the face, this helps keep the rig light and speedy. The hands have very nice deformation on the fingers. There are a few custom attributes that allow for changing the appearance of the character. One that stood out was the leg cuffs, with this attr you can change the wrinkles in the characters pants.  I haven’t seen an attr like that and it gave me some ideas, it just scrambles some of the verts in that area, I think i’ts based off a linear SDK set to infinity. Over the rig is great for animators, plenty of controls to fix gimbal lock and other tweaks you might need to let the animators expressions shine through.