QUOTE(sh4dow @ 01/12/06, 01:53 AM)
hi
i keep coming back to this problem... duplicating objects along a path... i know that it works in 3dsmax but i just can't find a way to do that in maya. so what if i want to position objects along a spring? or some other random curve? and i'm not talking about 3 or 4 which you could position manually...
is there a way to do that in maya?
[snapback]224691[/snapback]
Hi there, i had the exact same frustration on duplicating objects along a curve (path to 3DS folks)...i had 5 engineers at one point looking over my shoulder trying to help me figure this one out in Maya when i first started working with this tool. Then i met Adrian Herbst, he teaches a Mel Scripting class at The Academy of Art in San Francisco. He turned me on to the script below...but if there's several other ways i've seen folks address this..also check out
http://forums.cgsociety.org/printthread.php?t=121358
I havent' taken a scripting class yet but i do know enough now to poke around and edit other scripts which i'm beginning to see as a whole unique feature set in Maya.
As given to me from Adrian...this script allows objects to be duplicated along a curve. To use, select the object, shift-select the curve, and after applying settings, click the button.
good luck
Jacky Powell
safarisister.com
copy and paste into text file named alongCurve.mel
---------copy & paste starting with next line -----------
global proc alongCurve ()
{
string $winName = window -title "Duplicate Along Curve"
;
columnLayout;
text -label "Number of items to create";
intField number;
text -label "Follow Axis";
radioButtonGrp -numberOfRadioButtons 3
-labelArray3 "X" "Y" "Z" axis;
text -label "Up Axis";
radioButtonGrp -numberOfRadioButtons 3
-labelArray3 "X" "Y" "Z" axis2;
button -label "Create Objects" -command "makeDupes()";
showWindow $winName;
}
global proc makeDupes()
{
int $number = intField -q -v number
;
if ($number < 2) $number = 1;
float $increment = 1/((float)$number-1);
int $whichAx = ` radioButtonGrp -query -sl axis`;
string $axis;
switch ($whichAx)
{
case 1:
$axis = "x";
break;
case 2:
$axis = "y";
break;
case 3:
$axis = "z";
break;
default:
$axis = "x";
break;
}
int $upAxis = ` radioButtonGrp -q -sl axis2 `;
string $ax2;
switch ($upAxis)
{
case 1:
$ax2 = "x";
break;
case 2:
$ax2 = "y";
break;
case 3:
$ax2 = "z";
break;
default:
$ax2 = "y";
break;
}
string $sel[] = ` ls -sl `;
string $newObj[] ;
string $motionPath ;
for ($i=0 ; $i<$number ; $i++)
{
select $sel[0] ;
duplicate -rr ;
select -tgl $sel[1];
$motionPath = ` pathAnimation -followAxis $axis -upAxis $ax2 -fractionMode true ` ;
CBdeleteConnection ($motionPath+".u");
setAttr ($motionPath+".uValue") ($i*$increment);
delete $motionPath;
}
}
--------end of script - do not include this line in your copy & paste-------------
Here's a quick and easy way that someone from the cgtalk.com posted...
1) create the curve
2) snap the object to the end of the curve.
3) Select your object, shift select the curve, Animate - Motions Paths - Attach to Motion paths.
(Now if u hit play, your object show move along the curve)
4) Select your object, Animate - Create Animation Snapshot
(In the options, u can change the increments, frame range etc)