Monday, June 24, 2013

Learning code from the Pros

It's been a while since I've posted anything, again, but as is the way of things sometimes there is little to post about. Recently I've been working at Goldtooth and learning a lot of python and other code related etiquette when it comes to creating pipelines and work flows from scratch.

While I've worked with a lot of programs and applications in the video game industry, it's great to be exposed to new tools in other industries, like Shotgun, Tank, RVIO, Nuke, etc. Although I will admit writing code to connect with a vast database can be daunting :)

When I'm not connecting with databases and the likes, I'm writing custom scripts to push thousands of files around... usually renaming them in the process. Sometimes renumbering entire frame sequences too. It's interesting to see how a good naming convention can really make parsing files a breeze, while files named all willy-nilly make it just the opposite, or at least make it so that I have to write a custom file handler, or brute force renamer to handle most situations.

One of the main functions I've written for myself is copy_RenameOnly(), and it takes a lot of parameters.
  • srcDir: source directory for the files
  • dstDir: where the renamed files need to go
  • fileName: The name of the new file sequence. Honestly I've given up trying to automate this because of the sheer number of different file names I encounter during the day. At least entering it manually gives me full control.
  • extension: Again, when dealing with EXRs, JPGs, JPEGs, TGAs... sometimes within the same folder, I decided to give explicit instructions as to which file type this function needs to look for when grabbing the list of files.
  • duration: when copying a lot of files I sometimes need to copy only a certain frame range.
  • print only: A useful addition that allows me to double check my output to make sure I've gotten everything correct.
Mind you this may not seem like a big deal, but there are days when I may need to rename a couple dozen directories to what the client needs, it helps to have all my custom tools at my disposal :)

One of the things I thought of doing was writing a script which would parse the Nuke scripts, extract all the read-in nodes to get the source frames, and then actually have my script write a python file and auto populate all the necessary fields for me so that I can just enter the destination file name and run it, saving me a lot of time and ensuring no typos with variable names etc.

I have a habit of doing a lot of the following... if only to stay more or less Pythonic and keep my lines within 80 characters and be able to reuse variables easily:

dst = "//localDrive/project/delivery_dir"
src = "//networkDrive/project/show/dir1/dir2/etc..."
shot_1 = "{0}/source_dir1".format(src)
shot_2 = "{0}/source_dir2".format(src)
shot_3 = "{0}/source_dir3".format(src)

copy_RenameOnly(shot_1, dst, "GoodFileName_1", "exr", ...) 
copy_RenameOnly(shot_2, dst, "GoodFileName_2", "exr", ...) 
copy_RenameOnly(shot_3, dst, "GoodFileName_3", "exr", ...) 
...

It looks streamlined, and it is to a degree, but I think it can be streamlined further by writing a code generator script to help me out further. Such is the life of a technical artist in the film and FX industry ^_^

In personal news, I'm slowly working away on my new game project. I've put my racing game on hold to work on something simpler that I can tackle myself in a reasonable time frame. Afterall, my first project should be about creating something from start to finish, even if it doesn't end up selling millions :)

I'll have more of that later!

No comments:

Post a Comment