3dsmax 9, Technical artists part 1
Starting out in maxscript is easy, for programmers. Sometimes. Knowing 3d is obviously helpful, having an artist who knows about programming helps. But a hybrid, the technical artist, an artist that programs his own tools, but has enough skill to move forward with the programmers as code changes and adapts. Get learning.Some things to note : italics are programming terms. Bold is code examples, and other stuff should make sense automatically.
The artist programmer, a beginning.
Well lets start somewhere simple. There are some cool things you can do with max, literally, anything. Starting out can be difficult so im gonna explain piece by piece. One thing that you will use a lot of : VARIABLES. A variable stores things. Simple right? A sock drawer holds socks, a fridge holds refridgeratable (lol) objects. It makes sense that a variable has a type. There is text, numbers, and "objects","items","collections","maps". All these things are really easy to understand when its broken down. For example, a string holds text. Most strings in maxscript are referred to by string literals right? A string literal is just a bunch of words,numbers etc wrapped in double quotes. "a string" is a string where as, a string is most likely a syntax error. Variables are relatively easy to grasp. Variable = value. name = "fuzzy". location = "\models\textures". Thats all there is to it.
Numbers, pretty much the same. number = 2. age = 21. ageplustwo = age + number. See what i did there? Adding variables works most of the time. Like, variable plus variable can work most times if the types are the same, or if they can work together. Like, filename = "texture".filecount = 1.newfilename = filename + filecount. The output should be along the lines of texture1. You can add to the file count, and adjust the name of the rendered texture using a plus 1 after saving to the texture1 file.
If this is all confusing so far, go back and read it again lol. But the next part will have something my colleague asked for as an artist, when learning programming, Visual aid. No i lie, the next part is about the tools max gives us in max 9 (and other max versions) to edit, run and test scripts.
The maxscript tools in max.
There are a few things that are invaluable while testing and figuring out maxscript. There is, the documentation. Please, read the documentation when stuck. Its gibberish at times, its hard to understand but when you start seeing patterns at each interval you get stuck you learn faster. The maxscript listener (F11 by default). This is where you can type test code and see things on the fly, test if your functions exist, ask max wtf it is doing and what not. This is also, really really helpful. The maxscript editor in version 9 sucks, fullstop. But its faster then having to keep running scripts from the utility or the menu. So running the editor and using some damn cool shortcuts. After this bunch there are some helpful shortcuts, but for now there is also, the maxscript debugger. Its not highlighted, because i dont use it much either at first. There are other cool things you can use but for now lets use these.
Quick Reference
Maxscript editor -
Ctrl S - Save (yes, its important)
Ctrl D - Fix the coloring of the text in the editor
Ctrl E - "Evaluate" the code. This means it tests it, and then shows the errors in the listener or shows "OK".
Maxscript Listener -
Ctrl D - Clear All (so you can see wth its doing when it places things inbetween every other line)
A very small start
The documentation covers some very simple stuff which is nice. Im going to do the same as well, and im going to start out by usnig the maxscript listener too. Open the maxscript listener -> Welcome to MAXScript. Now that it is open and waiting we can start coding. Is it that simple to program in max? It can be. Visual aid, lets go!
Max gives us functions to use. Not a very technical term, functions do a function. They can do many functions, and ask other functions to do stuff, and even give us results. This is a later concept but for now lets remember that we need a variable, and a function that gives us something. When i say, "hey make a box, and name it pancake", i can always later tell my friend about pancake's hair. Pancake is 2m tall! Ridiculous.
This is what we are going to do. Storage = ask function to do something and give me a "handle" or name to reference the object im making, or item im using. "box = make a box for me","i want to make it blue", "box.color = blue". So max wants us to be all formal and use the maxscript language so lets make a box. From the documentation : "You can draw a box in MAXScript just by entering the box() command". I can see that if i type box() into the maxscript listener and hit enter, i can see a box created with default values. The box has options i can ask it to use from before its made, so i can say i want it to be 20 units high and 20 wide, 20 long. Again from the documentation :
mybox = box length:20 width:20 height:20
Type that into the listener window (on a new line) and hit enter. Do it again with different sizes and see how easy it is to do certain things. note : programming refers to a "return" of a function.This simply means that max is handing me something back.If you want to use it you can, if not ignore it.
The maxscript window shows some information, this is a return in the listener only and shows that the box now exists in the engine and in the code, as well as you should see a box in the viewport. Now we can set the properties of the box using its name that we filled up with , the box itself. mybox (the variable) contains the "returned" box, inside it. So i can say mybox's name should be "ArtCodeBox" instead of "box01". There are hordes of properties you will use later on , but for now we are changing its name.
mybox.name = "ArtCodeBox"
There, you will see the changes immediately in the window where the object name shows (by the toolbars, where the mesh wire color picker is).
Concluding
It seems horribly short and, rewheeling the invention. This may be true now but i want to start really slowly, and move into more advanced things later. Starting to understand programming is not the easiest thing when you are an artist. This is by no means a demeaning statement, as most programmers know nothing of art so play fair. There are tons of resources, tons of tutorials and of course, http://area.autodesk.com for a slick forums with fast responses, there is documentation and there is also, common sense. Learning comes from seeking knowledge, not complaining that the tool isnt robust enough.
For a second installment, and the coming soon third part, we are going heavy into simple, fast paced programming for artists that speeds up everyday tasks.
To all the artists : Please suggest some ideas. I have some, my colleague has some, what annoying thing would you like to automate (small things for now)?
Comments welcome, and of course ideas, suggestions, flames ( i can delete those, you see ).
FuzzYspo0N/Sven
*this blog is beta