PDA

View Full Version : MEL Beginner needing some help


ZombieLife
02-28-2011, 05:00 AM
Hi everybody, I'm in my first scripting class and I'm getting stumped by my current assignment. The idea is to take an existing nurbs surface and use the isoparms as extrude guidelines to create n number of smaller tubes like a cluster of wires. I'm running into a wall trying to figure out how to have the extruded wires be spread out between the first and last parm. This is only my 3rd or 4th assignment and I'm still learning the ins and outs of this voodoo. This where I'm at so far, any insight would be hugely appreciated.

global proc makeWires(int $numCurves) source "makeTUUB.mel"; //makeTUUB is something we already wrote to automate nurb extrudes

ls -sl;
string $selz[];
$selz = `ls -sl`;
print $selz;
if (`size $selz`==0)
{
warning "Nothing Selected";
}
else
{
for ($i=0,$i<=$numCurves,++$i)
{
float $numberOfParms = `getAttr $loftSurface.spansV` //This was a guess, not sure what to do with it because I need to wires to be spread evenly



float $randomRadius = rand(.1,1.5); //wire radius

float $randomOffset = rand(0.01,0.2); //for lofting the wires

string $tCurvez[];


$tCurvez = `duplicateCurve -ch 0 -rn 0 -local 0 "loftedSurface1.v[$random]"`;


makeTUUB $tCurvez $randomRadius; //other global proc, tCurvez doesn't work as an array in a string input



delete $tCurvez;
}
}
makeWires 200

NaughtyNathan
02-28-2011, 10:24 AM
sorry Tyler, but almost every single line of your code has some issue or other which makes it harder to point you in the right direction or give you specific help... Also, I'm unsure what your ultimate aim is, are you wanting to extrude new wires tubes where the existing (visible edge) isoparms are on a surface, or simply distribute some wire tubes over the surface uniformly between surf.v[A] and surf.v[B]..?

anyway, here are some notes on your code (wrap your code in a code block!) the things I've "fixed" are in orange, errors are in red and comments are all grey.
source "makeTUUB.mel"; // put your sources outside the proc
// you probably don't want to source this EVERY time you run the function right?
global proc makeWires(int $numCurves)
{ // the code in your proc must be inside curly braces
ls -sl; // has no real effect - get rid of it
string $selz[] = `ls -sl`; // you don't need to declare the variables separately first
print $selz;
if (`size $selz` == 0)
{
warning "Nothing Selected"; // you never refer to $selz, so why do you need it?
}
else
{
for ($i=0,$i<=$numCurves,++$i)
{
// original syntax: $var.attr is incorrect,
// you must 'catenate' variables and literal strings like this: ($var+".attr")
float $numberOfParms = `getAttr ($loftSurface + ".spansV")`; // where does $loftSurface come from?!?
float $randomRadius = rand(.1,1.5); //wire radius
float $randomOffset = rand(0.01,0.2); //for lofting the wires
string $tCurvez[] = `duplicateCurve -ch 0 -rn 0 -local 0 "loftedSurface1.v[$random]"`;
// hardcoded object name: "loftedSurface1"..?!? that can't be right...
// where does $random come from?!?
// variable $random not catenated correctly inside literal string!
makeTUUB $tCurvez $randomRadius;
delete $tCurvez;
}
}
}
:nathaN

CGTalk Moderation
02-28-2011, 10:24 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.