Monday 7 November 2016

Maya 2016 - small changes make for some small headaches

Lately I've been running into a few issues with projects and scripts that relate to some small changes made in Maya 2016, and 2016.5.  Like most of my discoveries, I'm posting them to the blog here for those of you who may find them of use...




Render Layers

Maya 2016.5 changed the way it handles render layers...  I only discovered this when testing a scene on our Render farm which is running 2016.5 - My workstation still has 2016 so it wasn't until sending my job to the render farm did I discover this issue at all.

The error output from the render nodes complained about a Render layer being 'Legacy' and needed the Maya configuration to be adjusted to use it.  Obviously its on a farm - I couldn't tweak a remote machine - and hence the render failed to go through.

Maya 2016.5 appears to allow the user to decide what type of render layer system they want to use - Legacy or a new 2016.5 system...  However as far as I am aware from some online research, its a case of one-or-the-other and not either.  Why?  Who knows...

After a little googling, I found a solution.  A script that just forced Maya to deal with any render layer format (legacy or new).  Its what we needed - installed and no more problems.

In case you're running into the same situation - whether its a render farm or perhaps just a batch render that's failing - then this is a possible solution that may work for you.

Scripting Hot keys

One thing that I discovered while getting scripted tools set up a couple weeks back was that for some reason my hot key settings were not being applied.  I'd done this in a script that forced the ctrl s hot key to call a custom file save tool.

Setting a hot key in python is a rather simple process.  You define the script you want to call as a nameCommand, and then you assign this nameCommand to the hot key.  In my original code, I'd done the following.  The nameCommand runs a python script (using mel's python() command - though you can also just use python commands in here if you add the parameter stp='python')

cmds.nameCommand( 'SaverTool', c='python("import GP_saver as gp;sUI = gp.saveUI();sUI.show()")' )
cmds.hotkey( k='s', ctl=True, name="SaverTool")

Pressing ctrl s wasn't working.  This is due to a change made in Maya 2016.  All of Maya's built-in hotkeys are set to read-only, and hence cannot be modified...  However, a new hotkey set system has been put in place - and its actually a pretty good idea (that really should have been in Maya years ago).

A hotkey set is just that - an editable version of Maya's hot keys that are stored in a hotkeys folder found under a user's documents / maya / 2016 / prefs   folder.  With hotkeys stored this way in sets, setups can be shared with others very easily.

Anyways...  Carrying on...

Scripting a hotkey in 2016 is done through specifying the hotkey set to use, and then following the same steps to create the shortcut as before - which will then get updated in the hotkey set file.  Here's an update to my previous code.  The first part we want to try and create the hotkeySet (in this case called GPHotKeys) and make it the current one.  If the hotkeySet already exists (it generates an exception - hence the use of try/except in the code), we can then set it by editing the current set (edit=True).

Note that when we edit the current hotkeySet, we will get a True/False response...  This is good to know if you want to test for this in your own scripts...


# Set the hot key for custom saver script.
# First make sure we have a hotkeySet for the short cut
try:
    cmds.hotkeySet("GPHotKeys", current=True)
except:
    cmds.hotkeySet("GPHotKeys", edit=True, current=True)

cmds.nameCommand( 'SaverTool', c='python("import GP_saver as gp;saverUI = gp.saveUI();saverUI.show()")' )
cmds.hotkey( k='s', ctl=True, name="SaverTool")

So - how about getting things back to normal?  In the new system, you just set the current hot key set back to Maya's default (a hotkeySet called - well - 'Maya_Default').  Its pretty much as simple as that.

In this case, I've slapped on an if, just for examples' sake.  Note that we can also query the current set with the hotkeySet command as well.


if cmds.hotkeySet("Maya_Default", edit=True, current=True):
    print "Yes, Maya default keys are back!"
else:
    print "Doh! Something went wrong..."
    print "Current set: ",cmds.hotkeySet( q=True, current=True)

Evaluation modes

And one other 2016 update that caused a headache was using a character that was set up with a rigging script.  In this case, someone had generated a rig using Mixamo...  Nice rig, and while it appeared to perform just fine when tweaking and adjusting controls at the start, once keys were set, things quickly became a little wobbly.

By that, I mean the rig wouldn't always follow the controls.  When they were adjusted, you'd get visible shuddering and odd moments where the character would jump away from its controller for no reason.  This just made for headaches for anybody trying to animate the rig...

Turns out it all relates to Maya's evaluation mode - this is how Maya processes the scene internally, It seemed that 2016 had set the evaluation mode to Parallel - a mode that tries to make use of multi-core processors and GPU cores to accelerate performance.


You can find this option in Maya's Settings and Preferences panel, under Animation. (as seen above)

It was this, according to a post found on Mixamo's website, that is not properly supported by its rigging script (Well, at least in 2015 when the post was made).  They suggested switching it to DG (dependancy graph) which has been the default in Maya for most of its life.  This magically solved the issues!

I'm all for accelerating performance - however in this case it caused a decrease in artist performance with the rig glitching so badly.  Kinda finding a balance between machine and human performance was a necessity.

Before I go...

With most of this stuff all relating to Maya 2016+, if you need scripts to work on older versions of Maya, its worth noting how easy it is to test your version of Maya.  hotkeySet's didn't exist previously, so running the hotkeySet command in Maya 2015 will fail...  Here's all you need to know to read the Maya version number...

if not ( cmds.about( v=True)[:4] == '2016' ):
    print "This is for 2016 only... Sorry!"
else:
   print "Hurrah! You're running Maya 2016!"

Note how I grabbed the first 4 characters ([:4]) from the cmds.about value.  The reason is to just make sure we return only the 4 digit date/version in case there are additional characters included (in the case of 2016.5 - I don't have it currently installed, but I'll assume it would include a ".5" at the end of the string(??)

And that's it...

So there you have a small collection of snippets that may (or may not) come in useful.  Until next time (where I'll post up a pile of other handy code snippets for budding Maya TD's)...

0 comments:

Post a Comment