maxscript for artists - distinctive-imaging · maxscript is a built in scripting language for 3ds...
TRANSCRIPT
{
{ MAXScript For Artists
Anton Vasilescu http://75ive.com
MAXScript is a built in scripting language for 3DS Max which helps with automating tasks. It allows you to perform and automate almost all the tasks which are performed by the 3DS Max user interface.
What is MAXScript?
ANTON VASILESCU http://75ive.com
.ms – which can be run and will execute directly from the MAXScript editor or through the “Run Script” command .mcr – or MacroScripts are associated with user interface elements and acts as a wrapper for a regular .ms file. * To edit a .mcr file which is added to your interface, just right click on it’s icon
Types of scripts
ANTON VASILESCU http://75ive.com
MAXScript menu/Run Script
Utilities panel/MAXScript button
How to run a MAXScript
ANTON VASILESCU http://75ive.com
You can open it one of the following ways: 1. From the MAXScript menu/MAXScript Listener
2. Right click on the mini listener on the bottom left corner of the UI and choose Open Listener Window
1. Press the F11 key
MAXScript Listener
ANTON VASILESCU http://75ive.com
Open the Viewport Configuration panel, choose your layout then click on the desired panel and click on Extended/MAXScript Listener option in the newly opened menu
Listener as custom viewport
ANTON VASILESCU http://75ive.com
YOUR BEST FRIEND! How to use it:
Contents – displays all the topics in an ordered fashion. Great to use when you start to familiarize yourself with the document and it’s structure
Index – displays all the commands in alphabetical order and it’s the easiest to find what you are looking for with
Search – use it when you don’t know the command’s name. The results are quite overwhelming and it’s quite hard to pinpoint what you need
Favorites – use it as much as you can to save the topics you feel like you need most
MAXScript Help
ANTON VASILESCU http://75ive.com
How to define a variable:
Variable types: Boolean → true / false Number (integer & float) → 1, 1.0 String→ “this is a string” Time → 2.5s, 1m15s, 18.25f, 4800t, 0.5n Pathname → $box01, $torso/left_arm, $*box* 2d and 3d point → [1,2], [1,2,3] Array → #(1,2,3), #(1, “foo”, #(1.2, 3), [1,2,3])
Variables
ANTON VASILESCU http://75ive.com
Local Variables - Local variables can only exist within a block. For this reason, they must be created in a block. If you try to define a local variable from the top level of MAXScript, you will receive an error message.
Global Variables - when a variable is global, it means that the variable can be used anywhere in the program.
Persistent Global Variables - You declare a particular global to be persistent and the value it contains is always saved to and restored from scene files as they are opened and closed. Therefore, you can keep direct references to objects in the scene in variables and those references will persist across scene save and reload.
Variable Types
ANTON VASILESCU http://75ive.com
Variable scope is one of the most important things and best grasped in the beginning! You could imagine the scopes as an onion with nested "layers". When a local variable is created at a certain level, it is visible only at this level and all scopes nested inside of it. * Best practice is to always have your script enclosed in a pair of parentheses
Variable Scope
ANTON VASILESCU http://75ive.com
ObjectSets represent the main scene object categories in 3ds Max
selection objects geometry lights cameras helpers shapes systems spacewarps
Object Sets
ANTON VASILESCU http://75ive.com
All objects with similar properties are part of similar a class. For example all spheres are part of the Spehre class. All omni lights are part of the Omnilight class. SuperClasses more generic classes from which each individual object class is derived. For example all geometry objects are part of GeometryClass. To query the objects about their class you would use the following functions:
classOf superClassOf isKindOf
Classes & Superclasses
ANTON VASILESCU http://75ive.com
Comparison Expressions == ← equal != ← not equal > ← greater than < ← less than >= ← greater than or equal <= ← less than or equal
If/Do (not recommended!), If/Then, If/Then/Else
CaseOf
Conditionals
ANTON VASILESCU http://75ive.com
Logical Expressions or and not
The loops are used to iterate through a range of numbers, time values, or a sequenced collection of values, such as an array or object set. For … Do/Collect
For … Where … Do/Collect
While/Do
Loops
ANTON VASILESCU http://75ive.com
One liner scripts
ANTON VASILESCU http://75ive.com
Disable Vray Dsplacement
ANTON VASILESCU http://75ive.com
Colorful Teapots
ANTON VASILESCU http://75ive.com
Geometry from Spline
ANTON VASILESCU http://75ive.com
http://75ive.com/tutorials/ http://Scriptspot.com http://forums.cgsociety.org/forumdisplay.php?f=98 Google MAXScript!
Additional Resources
ANTON VASILESCU http://75ive.com