ForEachLoop
main mel draw photography about

ForEachLoop

 


 

duplicate and align to multiple objects

Mel Scripting March 20th, 2009

If you want an object to be duplicated as many times as other multiple objects, and then align them together, this script is right for you.

First, select the multiple objects you want to align to, and lastly select the one desired object you want it to be duplicated and aligned to the multiple objects…sorry if I am vague. Here you go. :P If you want to duplicate not as instance, replace the `duplicate -instanceLeaf $lastnode` to `duplicate -rr $lastnode`. Note that I wrote the constraint command so that there are point, orient and scale options users could comment out to suit their different needs. Of course you could write an interface to have option check boxes, I just did it quickly here.

string $allnode[] = `ls -sl`;
$lastnode = $allnode[size($allnode) -1];
int $number = (size($allnode) - 2);
select -cl;
for ($x=0; $x<$number ; $x++)
{
string $new[] = `duplicate -instanceLeaf $lastnode`;
delete `pointConstraint $allnode[$x] $new[0]`;
delete `orientConstraint $allnode[$x] $new[0]`;
//delete `scaleConstraint $allnode[$x] $new[0]`;
select -add $new[0];
}

delete `pointConstraint $allnode[$number] $lastnode`;
delete `orientConstraint $allnode[$number] $lastnode`;
//delete `scaleConstraint $allnode[$number] $lastnode`;
select -add $lastnode;

Leave a Reply