Sort by Polygon or Triangle Count

Sort by Polygon or Triangle Count

dulaney
Enthusiast Enthusiast
1,362 Views
1 Reply
Message 1 of 2

Sort by Polygon or Triangle Count

dulaney
Enthusiast
Enthusiast

I'm wondering if anybody knows how, or is familiar with a script that will sort objects by polygon count in the outliner. I'm extremely rusty with maya scripting, but I'd appreciate any commands that would be useful as well in case I'd have to write my own. 

0 Likes
1,363 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

Hi,

 

Here's a code snippet I wrote to sort a list containing objects depending on polycount. It returns a sorted list.

Hope it can be of any use to you:

 

#Function to return Sorted Dictionary
def MakeSortedPolyCountDictionary( a_List ):
	t_dict = {}
	cmds.select( clear=True )

	for child in a_List:
		cmds.select( child[0] )
		t_triCount = cmds.polyEvaluate( t=True )
		t_dict.update( {child[0]:t_triCount} )

	return OrderedDict( sorted( t_dict.items(), key=itemgetter(1),reverse=True ) )
0 Likes