NX does offer a "random color display" that will show bodies (or faces) with random colors. This option requires no code to be written, it can be found at menu -> preferences -> visualization -> color/font -> random color. Perhaps it will meet your requirement.