Hi
I am trying to write some code, which will help in reducing NURBS-Curve complexity. I have serveral hunded NURBS-Curves, each of which has up to 16.000 cvs.
The curves are derived from AutoCAD, they are some kind of height-information, which I have to use to generate a Poly-Terrain.
The code, that I have written so far works quite fine in general, but I guess there is something wrong with it, for It gets extremely slow and finally crashes MAYA when trying to reduce more than a few of the curves at once:
CODE
int $numbOfcvs = 0;
int $numbOfCurvesMin = 1;
int $numbOfCurvesMax = 1577;
int $currentCurve = 0;
int $currentCv = 0;
string $combineName = "empty";
int $leaveCv = 12; // every 12-th cv is to be kept. The rest will be deleted
for ($currentCurve = $numbOfCurvesMin; $currentCurve <= $numbOfCurvesMax; $currentCurve++)
{
select -cl ;
$combineName = "curve" + $currentCurve + ".controlPoints";
$numbOfcvs = `getAttr -s ($combineName)`;
for ($currentCv = 0; $currentCv < $numbOfcvs; $currentCv++)
{
$combineName = "curve" + $currentCurve + ".cv[" + $currentCv + "]";
if ($currentCv == 0)
{
select -r $combineName;
print "GOGO: \n";
}
if ($currentCv % $leaveCv != 0)
{
print $combineName;
print " / ";
select -add $combineName;
}
}
doDelete;
print "\n\n";
print "curve #";
print $currentCurve;
print " DONE \n\n";
};