Lesson 3: Challenge and the Maxscript Listener

So I’ve given you a few things to look at, hopefully some of you have had a play, for those that haven’t, try making the button change the properties on other controls. i.e. press the button and the radio button changes, change the dropdownlist and the listbox changes.

I’ve talked about ‘print’ing and the maxscript listener but maybe I should do a quick recap on how to use it for those that don’t know.

(warning if you get random crashes when you are modelling disable the macro recorder)

If your maxscript listener is missing the pink part then you should see the splitter at the top and you can pull it down to reveal it. You can then go to MacroRecorder and enable the recorder. This will then output anything you do in the scene into the listener and give you maxscript code for it….. aha you say, life is easy… well not exactly. The maxscript listener will give you code, but it’s a bit sloppy and not optimized code, it might help you with identifying a property but you can’t often just copy the code and paste it in to a new script and expect it to work. Sometimes it’ll list ActionMan commands which won’t tell you very much and not give you the sort of thing you were hoping for, for example, if you wanted to align one object to another, it would be nice if there was a command for aligning, but there isn’t. 3dsmax has been built up of various different modules over decades of development and not all of it has ever been fully integrated into maxscript, so sometimes you just get the code to open an interface of a tool rather than the tool’s settings. For things like aligning you need to learn about transform, position, rotation etc and how to use it. Most new tools developed in 3dsmax and plugin will have maxscript interfaces thankfully, but sometimes the most simple thing is missing….

If you look a the image above you can see that you can type in 1 liners into the top or bottom section, the difference is that the top section will print to the bottom and the bottom section prints to the bottom as well, (is that a difference of a similarity?) You may wonder why the text is printed twice… well when you run a script the script will return the last value returned by the script, unless the script is enclosed by brackets (). I’ll go into scope and what that all means another time, but thought you may wonder why it’s there twice, once printed and then returned by the script. It’s important to know that you can’t write multi-line scripts in this listener window, that’s what the maxscript windows are for, it will allow you to test things in a global scope, ie type in something like test = 5*2… (damn talking about scopes again)… this is a complex issues which will rear it’s head at that really annoying moment when you’ve said you’ve finished your script, it works, you’ve tested it, you then restart your 3dsmax and suddenly your script breaks…. classic scope issue normally caused by typing things in the listener. I’ve not got time to explain all that but basically a quick word of advice, if you want to test some random code in the listener, don’t use the same variable names as in your script, I know I’ve confused you but it’ll make sense one day and you’ll be so annoyed when it happens.

Advertisements

About davewortley

Somewhere between an artist and a programmer, I like technical things, but being creative. I love problem solving and coming up with elaborate solutions. This blog is where I shall share ideas, tips, tutorials and anything that amuses me.
This entry was posted in Lessons, MaxScript. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s