Coding in VFX and Animation

Coding in VFX and Animation Header

Coding to Improve Your Laziness

For the month of April, I’ll be covering about the use of coding/scripting to improve your productivity in common Digital Content Creation (DCC) like Maya, 3ds Max,  Houdini, Nuke and After Effects etc.

Typically the approach here is more like writing a script to automate the repetitive tasks.

Imagine setting up the render settings, replacing texture paths for every cuts in a production environment for a feature length film BUT having a small team of less than 10 people so manual approach is not practical.

So why work hard when you can be a more productive lazy artist with some coding!

Coding in VFX to Automagically…

The ultimate end goal for any codes (specifically scripts) that we’ll be writing is to let the computer perform the “samey” repetitive tasks.

In the screenshot below, I’ve written a MEL script in Maya which generate a UI Panel that contains many buttons that will execute the functions from an external scripts. The goal here is not only for my personal use but for my FX team members too so they can avoid doing repetitive stuff and spend more time lazing around.

Maya Script Editor and Custom UI Panel

While you can’t write a script to turn back time to tell your old self to learn programming and Nuke (hehe), here are popular examples of what scripting can do:

  1. Replacing all the textures path in a scene file that met a certain criteria
  2. Create folders if doesn’t exists when outputting a geometry cache
  3. Renaming objects names by adding prefix/suffix, version etc
  4. Converting directory path to UNC (Universal Naming Convention) for network rendering
  5. Assign randomize rock materials to dozens of rock geometry
  6. Output WIP in Quicktime format with the date/time as prefix name
  7. Lookup for a specific type of nodes and change the parameter values
  8. Setup the renderer settings with the appropriate values based on project specifications

Here’s an example of a MEL Script that I wrote for an actual project to export the characters geometry cache as FBX 2013 from Maya 2014 to Maya 2013:

Before We Get Started

Before one start to code, it is important to have access to the internet (especially Google and Youtube) when you need to lookup for a problem.

The way I work is to think up what I wanted to automate and start coding the script and execute it.

If there is an error, this is your cue to start look up for that specific error and see what others have to say.

The same goes if you’re trying to figure out a particular method like casting a list of arrays as a specific types. Try it out and obviously you’ll failed if this is your first time. Note the error message and look up with the proper keywords to help narrow down your results.

Having a rudimentary fundamentals in programming language is a plus as it will help in understanding the following:

  • Variables
  • Arrays
  • Functions
  • Syntax

Listen, listen, listen! Or Maybe Not

Depending on the software, it will have a listener which are a great tool in listening to the actions that you performed.

The following GIF example shows the Script Editor in Maya where it prints out the actions when I set up the Vray Render Settings.

Maya Script Editor Listener GIF

3ds Max does have a listener too although personally I think Maya does better in capturing more actions than 3ds Max.

Sadly, this is not true for compositing software like Nuke and After Effects (AE) although the nature of Nuke means majority of the actions/nodes are actually text scripts which you can copy to any text editor where else AE requires the user to code their scripts in Adobe ExtendScript.

Again, the listener will be your best buddy whenever you need to code… if said buddy is available to listen to your complaints.

Did You Know…?

…that coding a script is pretty straightforward despite the lengthy wall of text as seen above.

EXCEPT

When it breaks.

Troubleshooting the error and getting it to work to your requirement is the fun (and stressful) part!

For the next few articles, I’ll be covering practical example as seen in an actual production for Maya, 3ds Max, After Effects and probably Nuke although I haven’t try writing a Python or TCL script for it.

Remember that there are plentiful of great resources to jumpstart your coding skills on the internet and I’m focusing on actual use instead of a step-by-step tutorials.

Happy coding!

Recommended Links

General Coding Practice
https://learnpythonthehardway.org/book/ (A great tutorial for complete newbie to coding for general purpose and it’s Python which are supported by many DCC software!)

MaxScript for 3ds Max
https://www.scriptspot.com/bobo/mxs2/mxs_tut/lesson01.html
https://www.scriptspot.com/bobo/mel2mxs/mel2mxs.htm (For Maya MEL Script to Max MaxScript)

MEL Script for Maya
https://www.csit.parkland.edu/~dbock/Class/csc233/Lecture/MELFundamentals.html
https://github.com/BigRoy/mayaVrayCommandDocs/wiki (this is specific for Vray for Maya but super useful)
https://polygonspixelsandpaint.tumblr.com/post/102799282929 (explains the MEL whatIs command)

Leave a Comment

seven + fourteen =