Lesson 14: Key principles of understanding working with MaxScript

Here are the key principles to working with MaxScript, you need to know about all the things listed below to be able to understand how to write scripts. Here is a brief overview and description of each thing, I’ll try get around to linking everything to the relevant section on my blog.

Value Types

These are the key types of variables in maxscript.

String – “Text, always within quotations marks, \ is an escape characterm \t would be a tab, to avoid this you can type\\t or put@ before the first quotation”
Integer – A whole Number, 1,2,3 typing in 1.2 as integer would give you 1, typing 1.8 as integer would also give you 1, rounding does not take place automatically you need to write a function for it.
Float – A non-whole number, 1.2232 for example.
Boolean – a True or False value
Point2 – two values, [x,y], 2-dimensional position for bitmaps for example or [width,height], values are float within…. [1.23,5]
Point3 – three values, [x,y,z] or [r,g,b] this is a 3-dimensional position or colo(u)r value.
Color – expressed as (color 128 128 128) or (color 128 128 128 255), it’s either an RGB value with an assume alpha value of 255 (solid), or an RGBA value.
Box2 – This is an area of a 2d space, (Box2 x y w h), x-position, y-position, width and height
StringStream – Like a string value, but better for memory for large values, and formatting values.
FileStream – A StringStream value that is written/read from a file.
Array – A collection of values, this can be a mix of types: #(1,1.2,abc,”test”)

Class System

You need to be able to understand how the class system works in max, how things are sub-classes of superclasses, and which category

ClassOf – Find what class a max object belongs to, ie Classof $VRayLight001 returns VRayLight
SuperClassOf – findout what Superclass an object belongs to, SuperClassOf $VRayLight001 returns Light
GetClassinstances – get an array of all the objects which are of the specified class, getClassInstances VRaylight returns #(VrayLight001,VRayLight002)

Inspecting Things

ShowProperties – Shows the properties of the object, showProperties (Box()) will show all properties that can be set Box001.height =1o for example
ShowMethods – Shows the Methods associated with the object, treat theses as functions for targeted objects. layer.getlayerbyname “test”, note that there is no = , you’re not setting a value you’re calling a function.
ShowInterfaces – will show the Properties and the Methods associated with the object

Iterating and Looping

For i Loops – Iteration loops going through a numeric sequence, for i = 1 to 1000 by 2 do…..
For o Loops – For variable in collection do… for o in objects do o.boxmode = true
Collecting Loops – For when you want to go through an array and filter the items. ar_Objs = (for o in objects where o.boxmode collect o)

Functions – Call a function with arguments – testFunction valA valB – and understand how to return a value.

Understanding the Help File

To be able to learn more you’ve got to be able to understand what <BOOL>, <VOID> mean in the help file.

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 3dsmax, Lessons, MaxScript. Bookmark the permalink.

2 Responses to Lesson 14: Key principles of understanding working with MaxScript

  1. Have you had a chance to mess around with Python in Maxscript and if so could you share of those findings

    Like

  2. Very nice collection of beginner tools. Thank you.

    Like

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