Hi everybody,
I'm trying to code in MEL, but when I execute the script below I get this error: // Error: No object matches name: //
Does a function require a selected object?
global proc CreateCurve(int $numVerts, float $curveLenght)
{
string $curve;
string $array[];
float $calculate = $curveLenght / $numVerts;
if ($numVerts < 1 || $numVerts = 1)
{
int $arraynumber;
int $arraynumber = 1;
float $newfloat;
do {
$array[$arraynumber] = "-p 0 0" + $calculate + " ";
$newfloat = $newfloat + $calculate;
$arraynumber = $arraynumber + 1;
}while ($newfloat < $curveLenght);
curve $array;
}else{
print("The number of vertices must be larger than the number one.n");
}
}
Any help is truly appreciated
I hope this helps. Let me know if you have any questions
global proc CreateCurve(int $numVerts, float $curveLenght)
{
if ($numVerts < 2)//error if arg $numVerts is less than 2.
{
error "Need at least 2 verts to create a curve";
}
if ($curveLenght<=0)//error if arg has $curveLenght is less than 0.
{
error "The length of the rope must be more than 0";
}
float $segmentLength = $curveLenght / $numVerts;
float $total = 0;
string $args;
while($total<$curveLenght)
{
$args += ("-p 0 0 " + $total + " "); //same as $args = ($args + "-p 0 0 " + $total + " ")
$total += $segmentLength; //same as $total = $total+$segmentLength
}
eval("curve "+$args);//eval will run whatever is between tha parenthesis as a mel command.
}
Thank you so much! I have a lot to learn I see. I wouldnt have thought of the adding += Thanks again! 