Cluster tool

I wrote a bit of code that will create a cluster on polygon geometry regardless of selection type, eg face, edge or vertex. Speeds things up a little.

import maya.cmds as cmds
def makeCluster():
	selection = cmds.ls(sl=True)
	for i in selection:
		string = str(i)
		try:
			object,selected = string.split('.')
			sel,CVnum = selected.split('[')
			if sel == 'e':
				verts = cmds.polyListComponentConversion(selection,fromEdge=True,toVertex=True)
				cmds.select(verts, r=True)
			print 'passed edge'
			if sel == 'f':
				verts = cmds.polyListComponentConversion(selection,fromFace=True,toVertex=True)
				cmds.select(verts, r=True)
			print 'passed face'
			if sel == 'vtx':
				print ' no conversion needed'
			print 'passed vtx'
		except:
			print 'object selected'

	cmds.cluster()
makeCluster()

 

Welcome

Hi!
My name is Alastair Richardson and welcome to my site.
Recently revamped from a dusty oldĀ self-built HTML site, I’m now using WordPress and blogging until my heart is content.
On this site you will find the tools I find useful and the ones I make myself.
Plus links to finished work, personal projects and inspiring work by others.

Enjoy!