3DATS MAXScript Cheat Sheet PDF
3DATS MAXScript Cheat Sheet PDF
Selecting objects, $ and wildcards a [1].renderable = false access elements of array with brackets [ ]
$ current selection
Random Values
$Box01 object with the name Box01
$.pos.x = random 0 10 random value between 0 and 10 (integer)
select $Box01 select object with the name Box01
$Box01.height = random 2.0 5.0 random height between 2 and 5 (float)
$Tile* objects whose names start with Tile
$.rotation = random z rotation (enter as one line)
$Tile A* objects whose names start with Tile A (use this eulerangles 0 0 ( random 0.0 360 )
for objects with whitespace characters)
$.material.diffuseColor = random blue part of diffuse color
$* all objects color 0 0 ( random 0 360 )
Access and Modification of Object Properties Outputting Values to the MAXScript Listener
$.name = table set name of current object to table print $.position print position of current object
$Box01.width = 10 set width of object Box01 format % objects selected. selection. output number of selected objects
count
$Sphere01.radius = 5 set radius of object Sphere01
$.renderable = false turn off renderable property of current object
Hierarchies and Animation
$.<property> = value general syntax for modifying properties
$Tile.parent = $Wall link tile to wall object
Transforming Objects $.children [1].name = Tile_01 set name of first child object
$.material = StandardMaterial() apply standard material spacewarps forces, spacewarps, deflectors etc.
$.material = VRayMtl() apply VRay material selection current selection (this is the same as $)
$.material = VRayMtl diffuse:green apply green glossy reflective VRay material
reflection:gray reflection_glossi- Nifty one-liners
ness:0.7
Examples for using ObjectSets to apply a command to a bigger group of objects
$.material.diffuse = color 255 0 0 change diffuse color to red
(for VRay the name of this property is diffuse, for delete cameras deletes all cameras in current scene
standard materials it is diffuseColor !) delete $lights/Fill* delete all lights starting with Fill
hide shapes hides linework
Variables and data types, strings, arrays
freeze geometry freeze all geometric objects
SCALAR VARIABLES (= numbers, standard mathematical operations: +, -, *, /, ^)
$*.material = undefined removes all materials of scene
w = 10 assign the value 10 to w
h = 10 assign the value 10 to h $Tile*.material = medit.getCurMtl() apply currently selected material in editor to all
a=w*h calculate the area a objects whose name starts with Tile
STRINGS (= characters/text/symbols)
strPrefix = LIGHT_ assign string to a variable
$.name = strPrefix + $.name apply prefix to object name 03/2010
compiled by Markus Boos
project|gemini VFX Technical Direction
[email protected]
http://www.projectgemini.net
3DATS 3ds Max Training
for i = 1 to 10 do create 10 boxes at different x positions rendOutputFilename = set render output file path
( P:\\viz01\\beauty_v01_.exr
Box pos: [i * 30, 0, 0] ... for a full list of render parameters, please consult
) the MAXScript reference
for obj in (selection as array) set scale value for cylinders in current selection max quick render equivalent to pushing the render button
where classOf obj == Cylinder do
( render camera:$Camera01 frame:100 additional function to kick off renders indepen-
obj.scale.z = 2 outputfile: P:\\viz01\\beauty_v01_.exr dent of the current render dialog settings
)
Conditional Statements Renderer-Specific Settings (e.g. VRay)
Conditional statements are used to make a decisions based on comparisons at runtime. They
renderers.current = VRay() set current renderer to VRay
allow you to create different branches and to control the program flow.
renderers.current.adaptive- set adaptive sampling min rate
If ( $.pos.z < 0 ) then set wirecolor to red if object is below 0, other-
Subdivision_minRate = 1
$.wirecolor = red wise green
else renderers.current.adaptive- set adaptive sampling max rate
$.wirecolor = green Subdivision_maxRate = 2
if ( superclassof $ == Light) then delete$ delete current object if it is a light renderers.current.gi_on = true turn on VRays GI calculation
Functions ... for a full list of your renderers parameters, please
This is an example function to calculate the volume value from width, length and height. It consult its user manual
will return the result, in this case the volume calculation. Generally, functions can be used
to encapsulate code of any type or purpose to prevent repetition and clutter within bigger
scripts. Rollout Floater Basic Framework
function calculateVolume w l h = Function definition: What are the expected The following code is a basic framework for building your own tools with graphical user
( parameters (e.g. width, length, height) and interfaces (such as rollouts, buttons, sliders etc.) to increase the degree of interactivity of your
w*l*h what does the function do with it (e.g. multiply scripts and provide more advanced functionality.
) them to calculate volume) ? The result of the last ( -start a new local variable scope
expression in the function body will be returned global rofTool here and declare a global variable
as a value to the caller of the function. for the rollout floater
calculateVolume 10 20 5 Function call with concrete values: return result Rollout roTool Tool -start a new rollout definition
will be 1000. (
spinner spSpinner Value: -add a spinner and a button
button btnButton Do it ! control to the rollout
Mass changing properties
on btnButton pressed do -event handler for the button
for obj in ( selection as array ) do turn off visible to camera property
(
( obj.primaryVisibility = false ) for selected objects
format value: %\n spSpinner.value -output current spinner value
for obj in ( selection as array ) set the radius property for objects which expose )
where hasProperty obj radius do it (applies to spheres and cylinders but not to a )
( obj.radius = 10 ) box, for example)
try -mechanism to prevent opening
for obj in ( selection as array ) do turn off turbosmooth modifiers on selected ( more than one floater window.
( objects by iterating all objects and also all their closeRolloutFloater rofTool If the user executes the script
for m in obj.modifiers where modifiers. The classof command checks if m is a ) catch ( ) without closing the old floater, it
( classof m ) == TurboSmooth do Turbosmooth modifier and then disables it. will automatically close it before
( rofTool = newRolloutFloater Tool Floater300 100 bringing up the new floater.
m.enabled = false
) addRollout roTool rofTool -add rollout to the floater
) )
Environment Settings
backgroundColor = color 0 0 0 set environment background color The MAXScript reference provides a lot of examples, FAQs and scripts to help you build better
tools and improve your workflow. Furthermore, there are useful websites such as scriptspot.
useEnvironmentMap = false toggle environment map (true/false) com, cgarchitect.com, cgtalk.com and many more with a big collection of existing scripts and
friendly experts to ask. Have fun with MAXScript !
environmentMap = Checker () apply environment map (e.g. a checker map)