| Very introductory Maxscript tutorial 1 |
Dub. |
This tut should take about 5 mins to complete.
I'll hopefully do a few of these over the next while. I'll start off really really basic for those who have always wanted to learn maxscript but haven't been able to get started. (that was me for a long time!)
The best way to learn maxscript is to learn a few basic tricks that you can use in your everyday work. You can then extend your knowledge as you come across tasks that you can *almost do with your current knowledge.
Intro
Ok, first of all I'll go over a few basics.
To follow allong with these tuts, open the maxscript listener by hitting F11.
The pink area up the top is the listener where if you enable the macrorecorder, it will tell you what max is doing in maxscript terms as you do regular tasks in max. We won't pay attention to this area in this tut.
The white area is where everything will be happening. Delete the "Welcome to maxscript" message so we have a blank slate to start with.
The Basics
Create a sphere in the scene so we have an object to talk to.
There are two simple ways to refer to an existing scene object in max. You can select it and refer to the selection or you can refer to it by name. The way maxscript refers to objects is by their name with a $ in front. So to refer to the sphere you just created, type:
$Sphere01
Now, with the cursor at the end of that, hit the enter on the numeric keypad. That will execute the current line. If you want to execute more than one line, select them all and hit numeric enter.
once you hit enter, maxscript will return the following in blue: $Sphere:Sphere01 @ [10,-5,0]
The last numbers will vary depending on where you created the sphere in the scene. This is confirmation that you are talking about the sphere and that your syntax is correct.
Object Attributes
Now lets try something slightly more useful. Type:
$Sphere01.radius
and hit numeric enter to execute. maxscript will return the radius of the sphere! Notice how there is a hierarchy to the command. You started with the object itself then a period (.) then the parameter belonging to the object. You can refer to other parameters the same way. ie;
$Sphere01.segments will return the segments value.
Setting attribute values
Now what we want to do is change the values not just look at them.
Simply type:
$Sphere01.segments = 35
You'll notice as soon as you execute the line, the sphere changes it's segments to 35! Well you could have done that faster with the GUI right? What if you have 25 spheres all with different radii and you want to just change their segment count? (a common problem)
Working on selections of many objects
I referred earlier to the fact we can refer to objects by referring to the current selection. In maxscript the shortcut to this is to simply select an object (select your sphere) and type:
$
When you execute this, you'll get the same result as if you had typed $Sphere01 Now we are going to exploit the power of "mapped functions"
Create 10 spheres of random radii and position. Select them all. Now type the following and execute it:
$.segments = 10
All the spheres will retain all their setting except the segments on all of them will be set to 10.
Thats it for now!
Conclusion
Play around with other objects and other attributes. if you want to know what parameters are availiable to you on a given object, type:
showproperties $
For the sphere, that will return the following list:
.smooth : boolean .radius : float .segs : integer .mapcoords : boolean .slice : boolean .hemisphere : float .sliceFrom : angle .sliceTo : angle .chop : integer .recenter : boolean .realWorldMapSize : boolean false
Enjoy!
read 25867 times 11/21/2006 2:50:48 PM (last edit: 11/6/2009 3:51:32 PM)
|
TiMoN |
Never even tried to write any max-scripts, so "really basic" sounds good.
*saved*
We're putting the band back together
read 25846 times 11/21/2006 3:12:21 PM (last edit: 11/21/2006 3:12:21 PM)
|
-=LeadMagnet=- |
same here timon.
Nice one Dub. I'll have a go at this later when my headache subsides.
 Do A Barrel Roll!!!
read 25841 times 11/21/2006 3:14:06 PM (last edit: 11/21/2006 3:14:06 PM)
|
horizon |
woot tried it...when can we expect the next one, it's great but a bit short, need more need more now that I started
read 25823 times 11/21/2006 3:55:56 PM (last edit: 11/21/2006 3:55:56 PM)
|
Dub. |
haha :-) I hoped it would have that effect.
I'll do another tomorrow.
I want it to be very simple so that people won't get scared off and instead have their appetite whetted for other more difficult tutorials.
read 25820 times 11/21/2006 4:01:57 PM (last edit: 11/21/2006 4:01:57 PM)
|
horizon |
I'm scared of nuttin!!! give me a tut
read 25816 times 11/21/2006 4:09:40 PM (last edit: 11/21/2006 4:09:40 PM)
|
Galadrim |
good stuff man! I keep tellin myself that I should learn scripts one day; and you have given me a much needed push.
read 25812 times 11/21/2006 4:15:41 PM (last edit: 11/21/2006 4:15:41 PM)
|
paconavarro |
GREAT DUB... I really want to learn MXS :)
---
http://www.exododw.com
read 25797 times 11/21/2006 4:56:40 PM (last edit: 11/21/2006 4:56:40 PM)
|
Nik Clark |
Nice one, Dub. Maxscript is awesome, and is an invaluable tool.

read 25790 times 11/21/2006 5:02:24 PM (last edit: 11/21/2006 5:02:24 PM)
|
jbrophy |
/me sends a hit squad to Dub's house for giving away the secrets :P
j/k man. Good job
 Jesse Brophy jesse_brophy@hotmail.com
Fry Monkey
read 25777 times 11/21/2006 5:47:18 PM (last edit: 11/21/2006 5:47:18 PM)
|
horizon |
I think this is Dubs subtle plan to run Boomer labs out of bussiness
read 25770 times 11/21/2006 6:32:41 PM (last edit: 11/21/2006 6:32:41 PM)
|
Dub. |
haha
Nope!
As people reach the limits of maxscript, they will realise where C++ code is the better way to go and thats where Boomer comes in :-)
read 25762 times 11/21/2006 7:38:04 PM (last edit: 11/21/2006 7:38:04 PM)
|
markoid |
Real nice of you to do this Dub, cheers. Maxscript looks sooo useful and it's an area of Max I never got to...'til now :)...........more, more
WEBSITE
read 25743 times 11/21/2006 10:49:11 PM (last edit: 11/21/2006 10:49:11 PM)
|
vlady. |
Just logged in to thank you very much. I'm working as a programmer, dreaming of getting a job in 3ds someday and raising money so I could go to college somewhere where it's beying thought. Great thanks for this , please keep it up, I will follow the series =) Vlad

I will someday change this fluffy avatar.
read 25669 times 11/23/2006 2:57:54 AM (last edit: 11/23/2006 2:57:54 AM)
|
Manolo |
Really nice, Dub. After some years of maxing, 1st time I open the thingy -on purpose-. Looks highly promising.
Cheers,
Manolo
read 25635 times 11/23/2006 8:09:05 PM (last edit: 11/23/2006 8:09:05 PM)
|