Wednesday, 4 January 2012

Selecting animated objects

Quick little script for selecting any (dag) objects with animation on.
string $allObjects[]=`ls` ; select -cl; for($i=0;$i<`size($allObjects)`;$i++) if(`keyframe -q -keyframeCount $allObjects[$i]` != 0) select -tgl $allObjects[$i] ;
I was already aware that mel doesn't need curly brackets "{}" following if statements or for loops (will only execute the next line of code), it seems that it doesn't need them even if your incorporating another statement or loop :) such as the above code shows...

Tuesday, 3 January 2012

Toggle lighting script

simple script to toggle the lighting between "default" and "use all lighting" on the current panel.
string $currentPanel=`getPanel -withFocus` ; string $mode="default" ; if(`getPanel -to $currentPanel`=="modelPanel") if(`modelEditor -q -dl $currentPanel`=="default") $mode="all" ; modelEditor -edit -dl $mode $currentPanel ;

Monday, 12 December 2011

Maya 2012: Changing channelBox decimal places (precision)

Most maya users know that you can use more decimal places then Maya displays by default.
For example, it is possible to translate an object by 1.11111 although maya will display "1.111".
When you use getAttr, it will return the correct values, but to display in the channel box, very simply under Edit in the channelBox go settings -> Change Precision...
Simple as, decimal places range from 1 to 15.

Friday, 9 December 2011

Outlook 2010 - Filter e-mails between specific dates

Sounds to be much simpler than it should be (tbh only really searched for a few minutes), but...
Say you want to filter your emails between dates?
Atm, a specific date was easy enough, but between dates seemed more hassle and the only way I could see was to create a new search filter.
Under "Search" tab, search Tools -> Advanced Find, then "Advanced" tab - and under Define more criteria dropdown select "Date/Time Fields" -> "Received", Condition to "Between", and Value to "<start Date> and  <end Date>" then under "Browse", make sure you check "Include Subfolders", then "Find Now".
It was a pain in the ass, and would love to hear a simpler way of doing it...

Sunday, 27 November 2011

Getting the RSS feed from your blogspot blog?

Very simply, just add "/feeds/posts/default?alt=rss" to the end of your blog address. eg http://ldunham.blogspot.com/feeds/posts/default?alt=rss

python dictionaries

Python dictionaries are really, really damn useful in a pipeline. As you store information in a "key: value" type structure, like storing information on a character they repeatedly needs to be called throughout the pipeline, like its rig file path or characterId number. eg "chaInfo={'johnnyId':564,'davidId':565}", so when you call "character['johnnyId']", "564" is returned. Which can then be taken much further... "chaInfo={'johnny':{'num':'cha01','id':546,'file':{'mesh':'johnny_mesh_master.ma','rig':'johnny_rig_master.ma'}}}", so to get the right information you step through them, so for the rig file path you'd call "chaInfo['johnny']['path']['rig']", or the id number "chaInfo['johnny']['id']". So you could have all the information you need regarding an entity or object within a single file, which is very easily called as and when you need it.

Automating Hotkeys

Some people have asked about automating the creation of hotkeys as it can be abit fiddly for them to do it manually. The problem is, like scripting most things, you really need to understand what is actually going on and why. For example, to automate the creating a hotkey to print what is currently selected. The script is simply "print (`ls -sl`);" First of all we need to create a runTimeCommand, which ties the entire script needed to execute under a single runTimeCommand, just like most of maya's own scripts do. runTimeCommand -annotation "Prints whatever is currently selected" -category "User" -commandLanguage "mel" -command ("print (`ls -sl`);") printSelection; This sets up everything we need to display the command in the hotkeyEditor, without it, you can still assign a command to a hotkey but when your try to find it in the hotkey editor, maya will have no knowledge of it.
Now we need to create a nameCommand which ties the a script to execute under a single string command, just like most of maya's own scripts do. nameCommand -annotation "printSelectionNameCommand" -sourceType "mel" -command ("printSelection") printSelectionNameCommand; Finally we assign a key which runs this command with hotkey -keyShortcut "~" -name ("printSelectionNameCommand");Now that does seem like alot of work, but it sets up everything you need and with abit of wotk, most of it could be automated, but the things you would need to check and the info you need to enter, theres pretty much no point creating an alternative version of the hotkeyEditor as it requires the same information. What you could do, however, is to create perhaps hotkey presets, so instead of having to take 3 scripts as you move to a different station (3 being the pref's scripts "userHotkeys.mel", "userNamedCommands.mel" and "userRunTimeCommands.mel"), you could have them those hotkeys into a single custom script which saves its setup as a preset in its own script file. This could be furthered by doing the same with shelves, window prefs etc, all executed from one script rather than having to transfer the entire prefs folder. Its fairly simple, definitely not the best way of going about it, but its certainly possible.