Hope this is helpful. The image below shows what the procedure does, before and after.
I'm still new to python programming so there probably are more efficient ways to write the python code.
/**put one cluster per each selected vertex or cv @pre components exist on scene */ global proc na_clusterOnSelected() { string $selected[] = `ls -sl`; //only considers poly vertices or cvs string $components[] = {}; $components = `filterExpand -sm 28 -sm 31`; for($obj in $components) { select -r $obj; //names default cluster -relative -envelope 1; } select -r $selected; }
import maya.cmds as cmds ## @package face rigging # # ##put one cluster per each selected vertex or cv # #@pre components exist on scene # # def na_clusterOnSelected(): print('hello') selected = cmds.ls(sl = True) #only considers poly vertices or cvs component = cmds.filterExpand( sm=(28,31) ) for obj in component: cmds.select(obj, replace = True) cmds.cluster(relative = True, envelope = 1) cmds.select(selected, replace = True)
Cheers,
Nate