wow, so many solutions.. btw i already got it but the hard way. finally here is what i wrote. i was trying to identify dup objects.. As you can see i have long lines for removeDuplicateFloatArray() haha.
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//USAGE : SELECT OBJECTS AND RUN
// for local space , use -a instead of -wa
//
_Rename_Duplicate_Objects();
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// PROCEDURES
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
global proc _Rename_Duplicate_Objects() // main procedure ***********************************
{
float $myAreas[]={};
float $myAreasSolo[]={};
float $area_array[];;
$mysel = ls -sl;
$myAreas = getAreas($mysel);
$myAreasSolo = removeDuplicateFloatArray($myAreas);
for ($sel in $mysel)
{
select $sel ;
$area_array = polyEvaluate -wa;
for ($area in $myAreasSolo)
{
if ($area_array[0] == $area)
{
$newname = ("_"+$area);
prefixNode $newname $sel;
}
}
}
}
global proc float[] getAreas (string $array[])
{
int $i = 0;
float $tempArea[]={};
float $finalArea[]={};
float $finalAreaSorted[]={};
string $sels[] = $array;
for ($sel in $sels)
{
print ("SELECTION IS " + $sel + "\n");
select -r $sel;
$tempArea = polyEvaluate -wa;
print("TEMPAREA" + $tempArea[0] + "\n");
$finalArea[$i] = $tempArea[0];
$i++;
}
$finalAreaSorted = sort $finalArea;
return $finalAreaSorted;
}
global proc float[] removeDuplicateFloatArray (float $array[])
{
float $nums[] = $array;
float $temp_nums[]={};
float $new_nums[]={};
float $temp;
int $i = 0;
int $j = 0;
int $found = 0;
for ($num in $nums)
{
$found = 0;
$temp = $num;
$temp_nums[$i] = $temp;
for ($temp_num in $temp_nums)
{
if ($temp == $temp_num)
{
$found = $found +1;
}
}
if ($found > 1)
{
$temp_nums[$i] = 0;
}
else
{
$new_nums[$j] = $temp_num;
$j++;
}
$i++;
}
return sort $new\_nums;
}
proc prefixNode(string $prefix, string $node) // from maya internal
{
string $isType[] = ls -type transform $node;
if (size($isType) > 0 )
{
string $nodeName = substitute ".*|" $node "";
string $newName = rename $node ( $prefix + $nodeName );
}
}