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

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':'','rig':''}}}", 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.

switch cases' and variables

Whilst writing up a switch statement, it appeared that you cant use variables (arrays in this case) as a case statement.

for example int $mode=0 ; string $currentNum="One" ; string $array[]={"One","Two","Three"} ; if($mode==1) $array={"Three","Two","One"} ; switch($currentNum) { case $array[0]: print ("Next in array is "+$array[1]) ; break ; case $array[1]: print ("Next in array is "+$array[2]) ; break ; case $array[2]: print ("Next in array is "+$array[0]) ; break ; } However swapping the case $array[...] with a value like so... int $mode=0 ; string $currentNum="One" ; string $array[]={"One","Two","Three"} ; if($mode==1) $array={"Three","Two","One"} ; switch($currentNum) { case "One": print ("Next in array is "+$array[1]) ; break ; case "Two": print ("Next in array is "+$array[2]) ; break ; case "Three": print ("Next in array is "+$array[0]) ; break ; } Works just fine, which ended me using the old 'else if' instead. I haven't found anything that seems to mention this, and I know there are probably better ways anyway but it did stump me for a while.

Creating 'custom' Hotkeys

Something not everyone seems to be sure about, its fairly simple really.

1. To assign a hotkey, go to the hotkey editor (Window -> Settings/Preferences -> Hotkey Editor). 2. On the left field, you can select which category you would like to create the hotkey under, I recommend "user" as so you can organise custom hotkeys. 3. In the lower right of the window hit “New”, give the command a name and a description. 4. Finally you need to put the command you want to run in the "Command" field, taking into account whether it is mel or python (eg print "Hello World!\n" ; ) 5. Hit “Accept” and it will appear in your hotkey list. 6. Select the newly created Hotkey and on the right where under “Assign New Hotkey”, enter the Hotkey combination you want to use and hit “Query” check whether it is currently already assigned. 7. If its not and your happy to continue hit "Assign".


Toggling Camera views

Thought i'd start posting up some of the more useful answers i've given on forums. Start off with toggling through camera views, (i believe already possible in 2012 with [ and ] hotkeys) but this script would allow you to enter in the cameras or the order you want to toggle them in, obviously being able to cycle backwards also. Simply just use this script in a hotkey as is to cycle forwards and change the first line from $mode = 0 to $mode = 1 int $mode = 0 ; string $panel = `getPanel -wf` ; string $cam = `modelPanel -q -cam $panel` ; string $view = "persp" ; string $order[] = {"persp","front","side","top"} ; if($mode == 1) $order = {"top","side","front","persp"} ; if($cam == $order[0]) $view = $order[1] ; else if($cam == $order[1]) $view = $order[2] ; else if($cam == $order[2]) $view = $order[3] ; else if($cam == $order[3]) $view = $order[0] ; lookThroughModelPanel $view $panel ;

Saturday, 26 November 2011


As i was re-designing this blog, checking out examples etc, I noticed a few things i didnt seem to be able to do, like bordering specific code etc (virtually no HTML knowledge btw), so a quick look and i created a nice template using <code> and <breakquote> etc, but there seemed to be alot of code needed for what I wanted and it wasnt very practical. Thats when I found CSS.
So far its been absolutely lovely, very simple, quick and useful (so far anyways) so I took the html template and remade it into css, with a few differences, add tied to the <code> class, which now allows me to use white space, padd, fill etc very quickly, so I thought i'd share it as I had to take pieces from here and there (mainly the css documentation actually).
(I only bothered commenting on the not 100% bleedin' obvious)
.post code{ width:613px; margin: 10px 0px 10px 0px !important; background-color: #444444; font:13px arial,sans-serif; line-height:20px; /*spacing between lines*/ color: #df7401; white-space:pre-wrap;/*preserve white space but keep word wrapping*/ border:solid 1px #777777 !important; border-collapse:separate; padding: 8px !important; /*inside margins of border and text*/ float: left; /*objects orientation (not text, but whole object)*/ }

Friday, 25 November 2011

A proper post...?

I've been messing more and more with code recently, mainly python in effort to understand what im doing and how I could do it better.
Well it started off like that anyways, ended up creating spam mailers to some of the guys at work when setting up email notification on tool issues and task completion etc.
I decided this blog needed a paintover and some more interesting posting... so i gave it a paintover, still waiting on the posts :(

Had to delge deeper into shotgun's api (well not that deep...) and come out with a much better sense in using dictionaries and error checking, but only after wanting to deck my monitor and then having the 'oh... ok' moment.

I have been meaning to put an up-to-date(ish) showreel together, and now I've finally got the motivation to get it (well, 'them' really) sorted and sent off before the end of this year, which I will get done alongside the development and release of the animation toolset.

and now... a man chasing his dog.

Tuesday, 22 November 2011


a useful tool for building script based selection sets (mayas own are node based, so will only work in the scene you build them in). Selection Sets build with this also allows toggling of selection with ctrl+LMB.
Download it here free:

Currently building a customisable animation toolset (ld_animateMe) which will have a range of useful tools that'll save people time (possibly include links to external tools and ablity to add your own).

Its gotta be simple, quick, customisable and FREE!

Tuesday, 1 November 2011

simple offset script

very simple but useful offset script which will offset every selected objects SELECTED keyframes (selected in the timeslider) by 1 (can be adjusted by changing $offset var)

int $offset=1 ; string $mySel[]=`ls -sl` ; float $range[]=`timeControl -q -rangeArray $gPlayBackSlider` ; for($i=0;$i<size($mySel);$i++) keyframe -edit -relative -time ($range[0]+":"+$range[1]) -timeChange ($i*$offset) $mySel[$i] ;