Scripting Octopus

Basics – Part 3

Estimated reading: 2 minutes 614 views

So let’s get start programming shall we? :)

Because maxscripting is not just simply triggering polyop functions and setting Editable Poly object parameters, but also controlling the baviour based on what sub-object selection we have or how many objects we have selected, we can create more complex tools.

The For Loop

The for loop is one of the most precious command which basically let’s us doing a whole bunch of operations one by one in each iteration. In maxscript the for loop looks like this:

for i = 1 to 10 do
(
	-- My command
	print i
)

In this little snippet the command will print out the numbers from 1 to 10. Which is good, but nothing useful right? But we can actually make it a really useful script without much effort.

for i = 1 to {2} do
(
	$.EditablePoly.GrowSelection()
)

Not much of a different right? But what have we done here? Well, only two things:

  1. I have copied out the grow command from the macro recorder and pasted it between the two brackets,
  2. and I changed the constant ’10’ value to the {2} dynamic variable. The {2} dyn variable will feed the mouse wheel value there.

So this will simplify our Grow Selection command, and from now we can control it with the mouse wheel. :)

Now this was also very simple right? Now let’s jump to the next lesson, where I’ll show you how to control the program flow with the ‘if’ statement!

Share this Doc

Basics – Part 3

Or copy link

CONTENTS
Shopping Cart
×