Thread: basics MAXScript
View Single Post
  #2 (permalink)  
Old 27th April 2007
Ceryni's Avatar
Ceryni Ceryni is offline
Tutorial contributor
Join Date: Jan 2007
Location: Uk
Posts: 67
Thanks: 0
Thanked 4 Times in 4 Posts
Send a message via MSN to Ceryni Send a message via Skype™ to Ceryni
Basic Modelling

Using the Listener will produce immediate results so here is a simple script for creating a box.

Creating First Model

In the Listener, Type:

b = box()

press enter.



Thats it.. you will get a box with set default parameters Length, width and height = 25; all segments = 1; located at 0,0,0

rather than having the parameters set at default you may change them using a simple piece of code like this

b = box height:50 width:10
pos: (10,10,20) name:"new box"


simply explained "b" is the name you want to give to the object ( the variable ) and "box" is the 3DS command for creating a box, the "()" is left blank for default parameters, and tells the listener to apply the script.
Height and width are self explantory.
pos = the position of the box in space and uses the standard axis "x,y,z"
name:"newbox" is the name given to the box in 3DS itself
you may also use:

--sets the position aswell
b.pos = (10,10,20)


If the command is correctly written you will get a reply from the listener that should read something similiar to this

"$Box:Box01 @ [0.000000,0.000000,0.000000]"

naturally you dont have to create a box: s = sphere() would work just as well.

Adding Comments

The standard practice when writing a script is to add "comment lines" this way it makes the script more understandable to yourself and others.

The syntax for a comment is a double hyphen "--" at the beginning of the comment.

--Create a simple box
b = box()
--the above script will not be affected by these comments

Rotation and Scaling.

These are particularily hard to do as it involves maths.
There are two types of rotation Euler and Quaternion. sadly i only really know how to use Euler so will teach you that.

Euler angles allow you to specify the rotation in degress about teh x,y,z axes, it rotates x axes first, then y , then finally z

Syntax for Euler angles is relatively easy to use.

rotate b (eulerangles 0 45 0)
--rotates the box 45 degrees on the y axes
ang = eulerangles 90 45 -45
--tells the listener to ready the rotation 90 on the x, 45 more on the right, and -45 on the z.
rotate b (ang)
--rotates the box along the axis and degress specified above.


Scaling is much like moving an object:

b.scale.z=3
b.scale.y=3
b.scale.z=3

This scales the objects on the axes. it can also be written

b.scale=(3.0, 3.0, 3.0)

Adding Modifiers.

To add a modifier, use the command "addmodifier",
syntax is: addmodifier objectname (modifiername parameters)

heres an example of how to set the modifier "bend" on a Cylinder.

--Create a cylinder of 50 in height and 20 segments
c = cylinder height:50 height segs:20
--add the modifier "bend" to shape "C" at an angle of 90 degrees
addmodifier c (bend angle:90)



Here is another 1 showing "twist" on a box

--create the angle of the twist and set "t" to the twist variable
t = twist angle:360
--create the box that the modifier will be applied to
b = box height:60 heightsegs:25
--Tell the Listener to apply the modifier.
addmodifier b (t)



Still to come: a short Animation written using MAXScript
Reply With Quote
The Following User Says Thank You to Ceryni For This Useful Post:
CHALLENGER (8th October 2007)