- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to make a MEL script which will generate a curve from selected objects but I'm not having much luck. I get an error saying "Invalid flag" followed by the information I am trying to put into the curve. Also, the variable that has the information keeps including blank data but I'm not sure why.
Please excuse my odd programming methods as I am an artist really 🙂
Here is my script:
//-----------------------------------------------------------------
proc makeNurbsCurveFromSelection()
{
// select -hi;
string $selection[] = `ls -sl`;
string $positions[] ;
spaceLocator -n tempLocator;
int $selectionSize = (size($selection));
matrix $itemPos[100] [3] ;
for ($i = 0 ; $i<$selectionSize ; $i++)
{
pointConstraint -n "tempConstraint" $selection[$i] tempLocator;
$itemPos [$i] [0]= `getAttr "tempLocator.translateX"`;
$itemPos [$i] [1]= `getAttr "tempLocator.translateY"`;
$itemPos [$i] [2]= `getAttr "tempLocator.translateZ"`;
delete "tempConstraint";
}
string $crvData[];
for ($i=0 ; $i<(($selectionSize)*4) ; $i++ )
{
$crvData[$i*4] = "-p";
$crvData[($i*4)+1] = (($itemPos [$i] [0]));
$crvData[($i*4)+2] = (($itemPos [$i] [1]));
$crvData[($i*4)+3] = (($itemPos [$i] [2]));
}
string $curveDataString = stringArrayToString($crvData," ");
curve -d 3 $curveDataString;
delete tempLocator;
}
//-----------------------------------------------------------------
Solved! Go to Solution.