My Max-Script Toolbar(beginner-level) Part 1

Stragalet
6 min readJan 27, 2024

--

If you want to learn some Maxscript to create som easy tools well here you might be able to get some very basic knowledge.
Maxscript and any other scripting language can be scary and hard to try for most people, here I will try to explain things so everyone can give it a try!

If you came searching for the Copy Paste script go to the Part 2 and at the end you will find the code!

https://medium.com/@stragalet/my-max-script-toolbar-beginner-level-part-2-4cc06e87f935

Introduction

I have a toolbar that I created through the years, it allow me to go quite fast but it includes scripts of other people too so I can’t share it like it is. So I decided that I will create a new one, a bit more simplified and in the process possibly you can learn something new too!

I’m a generalist so this is not gonna be the best way to do this, but more like my way, still I hope you can find something valuable!

And I can say with confidence that some of the scripts here, even if they are simple, very simple might impact your workflow! or I really hope so!

Max Script Basics

Nowadays I usually script using VisualStudio + Fork (Github) and I have a deployment on a shared folder for several computers to get the same scripts… Did I lost you already? no worries if you didn’t understood anything this will be a perfect guide, because I won’t be touching that, at least not from start.

I will give here some very basic general knowledge about maxscript.

Listener

The Maxscript Listener is that two pink and white things down there, just right click and select “ Open listener window” to get the full size.
Here we can check some of the information while we do some scripting, but we also can write some very easy code, sometimes for checking sometimes because we just need to change with code 1 thing 1 time so is not worth the time to do more.

You can delete all the text there, there is no problem is just like a Log when its written there won’t affect Max in anyway. ( control + D )

To execute some code we press (enter) after the line we want to execute.
You can execute code in the pink window or in the white one but I usually execute from the top and check the result on the bottom.

Some easy code you can try typing here:

Print "hello world"

Just type that in the upper pink space after deleting everything first and press enter when after the last ”

That will show the word “hello world” in the listener a couple of times.. (why two that is for another day)

myTeapot = teapot radius:30

Clean the code again ( control + D ) and type this new line that will actually create a teapot for you with radius 30.
Execture that code several times, so we end up with several teapots, or just create several teapots doesn’t matter.

Select them all and execute this code, this is a bit more tricky we will go through at some point later but for now just run it.

for i in selection do i.pos = [random 100 -100, random 100 -100, random 100 -100]

You should en up with some mixed posistion teapots automatically, basically we are moving the teapots randomly +100 units to -100 units.

and now imagine we wanna just move them to the ground ( z = 0,0 ) all at once.
Select them all and use this code.

$.pos.z = 0

Now all the teapots moved to the floor.

MacroRecorder

You can activate MacroRecorder from the Listener itself:

Or from the top menu “Scripting”

What it does is it shows some usefull ( sometimes ) lines of code you can use (after a bit of modification ), it records what 3DsMax does and it shows it there, so we can actually pick that code and reutilize it.
It does not pick everything, and sometimes It doesn’t pick things the way you want, so don’t trust it too much, always go for the Max Maxscript documentation if you have doubts.

And! remember to turn it off it can slow down 3DsMax in certain situations.

If when it is activated we change the radius of one of the teapots you will get the following text there.

So we can see that a teapot has a parameter in maxscript that is called “radius” we already used that one before!

Script Window

So in the listner everything we type gets lost eventually so what if we want to make that work we did, permanent?
Then we use the Scripting Editor by going to Scripting, New Script.

It looks like that, there if we type for instance some of the things we typed before we can save that in a file.

Oh here we can’t execture pressing enter, we execute by pressing “Control+E”

Lets type this two lines only this time.

messageBox "hello world"
myTeapot = teapot radius:30

Notice that we changed “print” for “messageBox” this time, well that instead of printing the text in the listener will create a popup that we need to accept, once accepted it will create the teapot.

Press Control + E and a message should pop up inmediatly.
You can save this in a folder in your desktop or wherever.

The magic of Maxscript is that you can drag code that to a floating toolbar in the top menu and it will create a buton that is ready to be used.
Just create a new toolbar with a new name and you can put the script there selecting all the text and draging it there.

This is maybe the easiest and fastest way to create a toolbar with scripts, but it is not very customizable.
If you follow along you will learn how to do a better version of this and in the future customize it at your will.
That is all for the Basics of Maxscript, now lets go to create something a bit more usefull!

Go to the next step here… Lets create some custom toolbar for real!

Part 2 here:
https://medium.com/@stragalet/my-max-script-toolbar-beginner-level-part-2-4cc06e87f935

--

--

Stragalet

ストラガレットです! I like making 3DCG stuff OC. Indie Game dev