Maya> mel>Mel Procedures part two

Mel Procedures part two

Share |

Let's look at the code we have so far;

We want our code now to not only allow you to set the radius, but also how many. First let's add another value. We do this the same way we added the last value. We separate these by a comma.

Now we have the two values. We've already assigned the first one to the radius. Now we need to assign the next value to how many are created. There's pretty much a standard way of doing this. The syntax goes like this;

In that syntax, we create a new value ' $i ' . This is the value that represents the creation of multiple objects..

When you implement it into our code it should look like this; remember, the command we want to duplicate is polySphere -r $radius; so take that out of the first brackets and put it in the second. Remember, where there's one bracket there has to be another.

Now put this in the script editor and execute it. Now type in on the command line; makesphere 2 3. This should create 3 spheres with the radius of 2. When you execute this command in the command line, the spheres should be inside of each other. To check if they're there, open the outliner (window>outliner). You should see 3 spheres listed. Now let's do one last thing to this code. We want to name our sphere's sphere1, and so on instead of pShpere1m and so on. To do this, we're going to access the name attribute of the polysphere. Then we're going to declare our new name + $i by adding + $i at the end, it'll name our spheres sphere1, sphere2, and on like that. Let's see what this would look like in our code.

Now enter the code in the script editor and then execute. Now type in the command line makesphere 2 3. It should create 3 spheres named 1 through 3.

Home Tutorials About the Author Site Map
User Agreement Privacy Policy ©2015