View Full Version : delete one element from array, - how?

12 December 2003, 09:53 PM
I have an array for particle IDs that picks up particle IDs when they fill certain conditions.
But I need them kick out from the array, when they donīt fill these conditions any more.

I guess itīs simple, but I didnīt find any clue in Maya Help. Does anybody know how to do it?

12 December 2003, 11:20 PM
Well, there's the stringArrayRemove, but if you want a more generalized index removal, you could do something like this (assuming float numbers):

// declared array
float $origArray[] = {12.2,15.6,1.3,8.0,9.1};

$origArray = remFloatArrayIndex($origArray,2);

// to confirm returned array
float $eachIdx;
for ($eachIdx in $origArray)
print($eachIdx + "\n");

// remFloatArrayIndex procedure follows
global proc float[] remFloatArrayIndex(float $origArray[], int $index)
int $idx;
float $tmpArray[];
if (0 < $index < (size($origArray)-1))
for ($idx=0;$idx<size($origArray);$idx++)
if ($idx != $index)
$tmpArray[size($tmpArray)] = $origArray[$idx];
return $tmpArray;

That'll work for floats, which is what you'll need for particles. It's not very generalized, but it'll work.


12 December 2003, 11:26 PM
Just to be a bit clearer about the script above, it returns the array with the requested index removed.
You could easily convert it to accept an array of indices instead.


12 December 2003, 06:02 PM
thanks very much ALEC! this is more advanced stuff obviously, Iīm learning new things from this.

now I have a little problem with caching particleīs rgbPP atribute. I have lava streaming particles, changing colors from age based ramp. Than I used dynExport command, but after caching the color were wrong.

I used these atributes to cache:


am I missing something? :-)

CGTalk Moderation
01 January 2006, 10:00 PM
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.