|
Creating a User Interface
Start a New Script, so we can create an interface
to create a Box with Bend.
-
Click New Script, and type:
utility box_bend "Box with Bend"
(
)
The brackets are extremely important,
because they specify where the script starts and where it ends.
A utility is a script that will appear in the Utility
Panel, in MAXScript.
-
Select File/Evaluate in the MAXScript Editor.
The Evaluate command (CTRL + E) executes the script.
It will be added to the list of utilities, and can now be selected.
-
Select Box with Bend in the Utilities list in the MAXScript
Utility.
|
 |
There's nothing in the Interface, except a Close
button. MaxScript creates the close button, and the utility interface,
by default.
You will now create a button that will
start the object creation.
-
In the script, between the brackets type button make_it
"Create Box" and Evaluate it again. If your script is not opened, select
it again in the Utilities list.
The script now has an interface, but nothing happens
when the button is selected, because no event was associated to it. |
 |
-
Right after the command we entered, type:
on make_it pressed do
(
b = box()
b.height = 30
b.width = 60
b.heightsegs = 15
b.pos.x = 25
b.rotation.z_rotation = 45
addmodifier b (bend())
b.bend.angle = 45
b.bend.direction = 90
)
This sequence, that is the same one we executed before,
is the event that will be called from the script when the button is pressed.
This is the completed script:
|
utility box_bend
"Box with Bend"
(
button make_it "Create Box"
on make_it pressed do
(
b = box()
b.height = 30
b.width = 60
b.heightsegs = 15
b.pos.x = 257
b.rotation.z_rotation = 45
addmodifier b (bend())
b.bend.angle = 45
b.bend.direction = 90
)
) |
|
The last step required is a way to insert the Box
in any place. This can be done using the Pickpoint() command.
-
In the Editor, before b = box(), add one more
line:
pt = pickpoint prompt:"\nSelect the position
of the Box: "
-
Substitute b.pos.x = 25 with b.pos = pt,
which will indicate that the Box position is the coordinate picked by the
user in the pickpoint command.
This is the completed script already containing the
pickpoint command:
|
utility box_bend
"Box with Bend"
(
button make_it "Create Box"
on make_it pressed do
(
pt = pickpoint prompt:"\nSelect
the position of the Box:"
b = box()
b.height = 30
b.width = 60
b.heightsegs = 15
b.pos = pt
b.rotation.z_rotation = 45
addmodifier b (bend())
b.bend.angle = 45
b.bend.direction = 90
)
) |
|
Download the final script here.
Alexander Esppeschit
Bicalho © 1999
|