Jumping Into MaxScript

As I was researching and testing out ideas for my next SimplyMax video tutorial, I decided to start learning a bit more about MaxScript. I was setting up some controls for a hand rig and encountered a part of the process that was unbelievably tedious. Parameter wiring the spinner controls to each finger bone involved at least 5 or 6 mouse clicks per finger as well as typing (copying-pasting) a similar expression every single time. Rather than set up everything manually, I opted for a mostly script-based approach. Enter MaxScript…

The first thing that was necessary was making sure I had a set naming convention. Having the base name for bones match the custom attribute names made it much easier to write out the MaxScript needed to wire things together. A simple Find and Replace took care of the repetitive scripts.

Next, I did a couple of isolated tests on short bone hierarchies. I had a couple of syntax glitches, but a trip into the MaxScript Reference saved the day. Once the tests worked, I ran the script on all of the bones. Everything worked great.

Setting up the finger controls was actually pretty easy. It was mostly using the exact same script which I got from the Macro Recorder and then changing the names of the bones and attributes I was wiring together. However, I still needed to actually set up the controller types for each bone before running the finger control setup script.

So, the next task I took upon myself was to write a script that allowed me to change controller types without digging into the depths of the Motion Panel. I created some temporary macros that would switch the selected object’s rotation controller to Float List on each of the rotation axes. Then I modified them to work more than one selected object. Realizing that I might need “reset” the controllers, I created another series of macros to change the controller types back to Bezier Float.

All of this was working quite well, but I ended up with several generic macro buttons in a docked toolbar. This would be fine if these were temporary scripts, but I really wanted something more organized and portable. Of course, this meant writing a custom floating window.

Writing the window was surprisingly easy. Creating a custom window with all of the buttons I needed was just a matter of moving all the separate macros into a single script file, creating the buttons I needed, and hooking up the buttons to the commands. I now have my very first custom utility window in Max.

Although I haven’t really done anything terribly complex yet, my first major stint into MaxScript has been a pleasant experience. Learning the syntax and structure of MaxScript is probably the most difficult part of the learning process. I think my experience with MEL is really helping a great deal. I understand the underlying logic and structure already. Now, it’s just a matter of learning the syntax.

Share This:
  • Digg
  • del.icio.us
  • StumbleUpon
  • Technorati
  • Google
  • TwitThis
  • E-mail this story to a friend!