I think a lot of 3D artists overlook the power that scripting with their 3D application provides them.
"I'm an artist - so why do I care about scripting?" I hear you cry. Scripts are great for automating repetive tasks, and you don't need to be a programmer to take advantage of them, though if you understand a few of the basic aspects of programming like loops and variables then it becomes even more powerful.
I predominantly use 3d Studio Max at work (along with Silo for modelling), and I've found that maxscript is relatively easy to learn. I'm not a Maya user, but I understand that it's scripting language, Mel, is fantastic.
So how do you start to learn scripting? 3DSMax has a tool called the Maxscript Listener, which records almost everything you do in max. This is usually my first step - I open the listener, then I perform the entire task manually. The listener records all the steps (usually, sometimes the listener has selective hearing), and I can simply copy and paste them to a new script document where I can then edit until I'm content.
How about some examples of where scripting is useful?
I know that all the characters I build in my current project have the same bones, so rather than creating them from scratch each time, I have a script that loads them from an external file. After the bones are loaded, it creates 2 selection sets - 1 for all the bones (but no nubs), and another set with a drastically reduced bone list for the LOD model (no fingers, toes, helper or face bones for example). The script finds all the components that need a skin modifier applied, applies it and assigns the correct bone set - thats the benefit of a sensible naming convention for you.
I like all my renders to look the same, so I've written a render script - it simply loads a scene with my preferred lights, floor and camera, sets the background colour of the scene to be neutral and changes the lighting tint.
Setting up all your shaders? Press a button and maxscript converts all my max materials to shaders, with all the shader values set to our correct defaults.
It's not just 3d applications that can have their workflow improved by scripts - Photoshop is a good example of a 2d package that allows you to create actions to automate repetitive actions - such as resizing and sharpening an entire folder of textures.
I'm working this up into a post for rsart, so any feedback would be great folks. I was thinking of perhaps doing an example of a simple script - would that be useful to anyone? I do quite a lot of scripting, but it's really only basic stuff since we've got tools coders to make all the really complex stuff.
Replies
A simple script that I use a lot is rotating a character. I build my characters facing forwards - so that the front view in max is the front of my character. For reason (I suspect legacy code or tools), the characters have to be facing away from you for export. If this was something that was done once, it'd be fine, but you might be spinning the character a lot between editing, exporting, editing, exporting etc.
Manually you have to go to the front view to decide if the character is in the right orientation for your task, select a bone, put the model into figure mode, go to the character studio rotate root button, then rotate it 180 degrees.
None of that is hard to do, but it takes 15-20 seconds and it's not exactly creative.
My script has two buttons, "Edit mode" and "Export Mode". They both do the same thing, so I was clever enough to use functions, but essentially you press a button then:
It selects the root bone(always the same name in every model) and puts the model into figure mode. This means you don't have to search for a bone, which can be a pain in heavy scenes.
It gets the X position of the left foot. Why? Well, if the position of the left foot is positive, then the model is facing forwards. If it is negative, then the model is facing away from you.
It rotates the figure either 0 degrees or 180 degrees, depending on what orientation you want it to be in. The reason I do this is that it's simpler to always call the rotate function and make it rotate 0 degrees than it is to put in a check to see if it needs to.
Ely - Python is all well and good (as is Lua), but it's not Mel or Maxscript so it doesn't really have a practical application when it coms to scripting (apart from making you hate how cobbled together some of maxscript is)
http://www.rsart.co.uk/2007/01/02/scripting-streamlines-your-3d-workflow/
http://orderindebris.exorsus.net/misc/jkbFlattenVerts_2.1.rar
it'll average the position of a bunch of verts on a specified axis. or snap them to a given location. pretty handy. use it all the time. straight out of the box maya feels pretty heavy. but once you've learned a little MEL and have your shelves set with all sorts of custom shit and workflow enhancements she's a kitten
.
Ely - Python is all well and good (as is Lua), but it's not Mel or Maxscript so it doesn't really have a practical application
[/ QUOTE ]
Oh, I understand. But Python is implemented as a scripting language for some 3D design software. So there's no need for learning cobbled program specific languages. With that in mind, it would be easier for find Python scripters and tutorials, and it's a cool language to start with if you're not experienced with programming.
I have also customized my maya to act more like max with it's poly modeling tools and customizing the shelves.
Scripting is a tremendous help in just about every application I can think of. It's hard to explain just how much time it saves until you start using scripts/macros. I think a lot of people get used to there flow and feel there fast enough so they put it off.
I also use a program called Autohotkey. Its a scriptable macro tool with recorder. Its freeware and opensource.