Even though I've put a 'catch' around the call itself,
I think you missunderstand the purpose of catching. All computer langauge catching works by relying on gracefull failure. Crashes are not gracefull failures, no amount of decorating the code around a runtime violation will help, short of not calling that code at all. Theres really nothing you can do about situations like this, except report bug and hope that tey will fix it in a point relaease.
anyway your code makes little sense! Dont write that code like that, your actually wasting the speedadvantage you get form the -nun flag by going around doing select -r $vt! The selection still goes to the undo stack! 90% of maya commands can pass a selsection list as last thing, so its infintely better to write following code snipet:
select -r $vt;
float $v[] = polyColorPerVertex -nun -q -r -g -b;
as:
float $v[] = polyColorPerVertex -nun -q -r -g -b $vt;;
it really IS a lot faster because updating global selection list is a VERY costly operation.
if(++$tick >= 400)
Dont do this! Either the history got deleted or it did NOT in step 1. Doing it more times is not smart, it stil wont get done any more properly. jut do it proper in step 1. Your crash is actually probably just a memory overflow because you make so many history nodes because yoy fail to clear the history.
Anyway theres a aeasier way to do this in ONE operation with no loops, an thats to flood with color! since thsi only creates one node you dont need to be so adamant of clearing history up front! Or you can actually use setattr!
{ // entire shebang in one go
setToolTo artAttrColorPerVertexContext;
artAttrPaintVertexCtx -e
-selectedattroper "scale"
-clamp "both"
-clamplower 0.0
-clampupper 1.0
-op 1.0
-colorRGBValue 2.0 2.0 2.0 // or 0.5 if you want to scale down
artAttrColorPerVertexContext;
artAttrPaintVertexCtx -e -clear artAttrColorPerVertexContext;
}
See mel is NOT a programming language dont treat it as such.