This script was originally written by Hiroyuki Haga on C++. Source you can find with Maya C++ API examples.
I have done not only "translation" to Maya Python, also some bugs was fixed by me and Script was modified in "my way".
DESCRIPTION:
1. It traces material connections
2. If multiple conections to one material is found, it reassign all materials
USAGE:
1. Make sure the PYTHONPATH environment variable is set properly in the maya.env file or the script may not run properly.
2. Select mesh with multiple connections to one material
3. Run from MEL or add to Shelf:
python("import cleanPerFaceAssignment; cleanPerFaceAssignment.cleanPerFaceAssignment()");For debug purpose you can run:
python("import cleanPerFaceAssignment; cleanPerFaceAssignment.printObjectSGInfo()");