Friday, March 4, 2011

Nice Python function for dictionaries

Not my code but found this whilst browsing for some functionality. Basically allows you to use .dot formatting when accessing keys in a dict:


class dotdictify(dict):
    marker = object()
    def __init__(self, value=None):
        if value is None:
            pass
        elif isinstance(value, dict):
            for key in value:
                self.__setitem__(key, value[key])
        else:
            raise TypeError, 'expected dict'

    def __setitem__(self, key, value):
        if isinstance(value, dict) and not isinstance(value, dotdictify):
            value = dotdictify(value)
        dict.__setitem__(self, key, value)

    def __getitem__(self, key):
        found = self.get(key, dotdictify.marker)
        if found is dotdictify.marker:
            found = dotdictify()
            dict.__setitem__(self, key, found)
        return found

    __setattr__ = __setitem__
    __getattr__ = __getitem__



Now we can use '.' rather than having to use standard ['key'] syntax: eg:

life = {'bigBang' :  {'stars':  {'planets': {} }}}

life = dotdictify(life)

print life.bigBang.stars.planets
instead of:
print life['bigBang']['stars']['planets']

life.bigBang.stars.planets.earth = { 'singleCellLife' : {} }
print life.bigBang.stars.planets

Ok, so it's just syntax candy, but does makes things easier to read in code.

Tuesday, March 1, 2011

Maya 2012

At last we can start to talk about it, I think anyway. Looking good so far, Viewport2 particularly is looking and feeling quite solid, or it is in the latest build :)

Official Maya 2012 release details here:

http://area.autodesk.com/maya2012

more release details from Cory here:

http://area.autodesk.com/blogs/cory/maya-1

Friday, November 19, 2010

Audio Sound node - follow on

Following on from my previous post about audio:

In the Trax editor you can actually trim the sound directly. It's very hidden and there's no graphical hint at all, but if you LMB drag on the top left / right of the sound node, over the top time text, then you'll be able to trim the sound directly. If you're in the CamSequencer you can also, by doing a Shift MMB Drag, shift the audio itself within the sound track. All hidden features, but they work (only in 2011)

Wednesday, November 17, 2010

Hidden Audio functionality in Maya2011

New Audio Handling in Maya2011

I wanted to point out a couple of hidden features for Audio handling that aren't in the docs and that kind of slipped into Maya2011 via the CameraSequencer upgrades. The audio node in Maya used to just have 2 main attrs, path and offset, that was all you could do, point it to a wav and set the start time. If you now look at an audio node in 2011 there's a ton of new attributes to control the behaviour of the audio. Unfortunately most of this is hidden unless you're using the AttributeEditor or CameraSequencer, in which case RMB on a sound you'll get access to Mute, that's about it. In the Trax sound is still just a simple, poorly supported add-on..... or is it?



Firstly there's now a Mute attr, so you can mute out those audio's you don't want, this displays in both Sequencer and Trax, but for Trax you have to set the attr direct.  Now for the more complex stuff. If you're used to editing in Trax you're used to sliding the start and end times, trimming the clip etc. There's no UI support for Sound for any of this, BUT you can still do it via the attr's directly.



So, 2 sets of attrs work together. Offset and EndFrame, SourceStart and SourceEnd. The Offset is no longer what it used to be, this is the start of the clip nothing more. If like us you have tons of sound code designed to offset audio then it's all stuffed! you need to manage both Offset and EndFrame at the same time now in order to shift a sound node along time.

However, using the Source attrs you can now trim the audio, directly in Maya..... there's not a lot been mentioned about this and we only found it by accident.

 The 2 sound nodes here are the same bit of audio, but the lower has been offset to start at frm 120, because the source start has also been moved to frm120 the audio is still in sync with the original one, just trimmed to start later on. The end source has been moved in, trimming the audio to stop earlier. You can also add silence to the start of the sound if needed.

Thought I'd share that as it's actually going to be really useful, think I'll push for the UI  integration from Autodesk so that the sound node is treated like the clips are, about to be trimmed directly rather than having to set the attrs up manually.

Mark

Thursday, September 30, 2010

Maya 2011 Subscription Pack now available

Autodesk have just made the Maya2011 Subscription Advantage Pack available on the Subscription Center for download. Great another bug fix build and a few new toys to play with, then never use again.

BE WARNED: point release 2011.5
They've made this a full point release so it now makes a ...docs/maya/Maya2011.5 for your prefs. Ok, this is fine, our pipelines can easily cope with this but what they've also done is had the program install into:

\Autodesk\Maya 2011 Subscription Advantage Pack

Not only not following their own naming conventions, but also filling the path with WHITE SPACES! How the hell are large scale studio pipelines which need to support multiple versions of Apps meant to deal with that one in a consistent manner? We can no longer guarantee any naming conventions and that's going to make life really tough. Our pipeline installer adds a python sitecustomize.py file into the Python\lib\site-packages dir so we need to be able to find it.

Oh, and to make it even better `getApplicationVersionAsFloat` returns 2011 not 2011.5! Great, thanks guys not that really has scuppered us.

WHY... and if somebody from Autodesk uses the word "Interoperability" again to try and persuade me that moving between apps is a good idea, just because they own them all, I'm going to kill them then dance over their still burning embers!

Friday, September 10, 2010

Relative Namespaces in Maya2011

I just wanted to add a quick pointer to the namespace -rel flag in Maya 2011 and how it can make managing namespaces a whole lot easier. By default this is set to false, meaning that all namespaces are treated from the root space (":") When you look in the Reference editor what you see as the namespace is the actual ns that the file was imported into.

Lets say you had imported a file 3 times on itself, so ended up with nested namespaces:

THIS:IS:ATEST:Myfile.ma

Now if you look in the ref editor you'll see the namespace as ATEST. If you try and change it it'll say the namespace doesn't exist. This is because your by default in root (":") space. This is where the rel flag can really help, it makes the namespace handling RELATIVE to the current space your in.

So mel:
namespace -set "THIS:IS";
namespace -rel true;
file -e -ns "FIXED" "C:/Test_Rig.ma";
namespace -rel false; 
namespace -set ":";

So here were setting ourself into the namespace THIS:IS, making all namespace actions relative to this, setting the new namespace to FIXED and then returning ourselves to root sapce and tuirning off the rel falg. The result is you've now changed the namespace that it said couldn't be changed, ending up with

THIS:IS:FIXED

Mark

Monday, September 6, 2010

fileBrowserDialog is no more! Thankyou Pymel!

Anybody who's used the Maya fileBrowserDialog command will know what a pain in the arse it is, having to always pass in a function for it to use on the returned selection. Why the hell couldn't it just give you back the path.
import pymel.core as pCore
print 'Folder Selected : %s' % (pCore.promptForFolder())
import pymel.core as pCore
print 'File Selected : %s' % (pCore.promptForPath())
Well, no more, I might have guessed that Chad would have simplified this and bingo Pymel promptForFolder() and promptForPath() functions. At last, it opens the file prompt window and just gives you back the return.

Chad,Pymel thankyou!