This script essentially does a Maya extract to selected faces. But it also cleans the history and puts the new geo in a new group.
To Run: Select faces you wish to extract then run the script.
#Clean Extract Maya Version 1.0.0 #Bryanna London #!/usr/bin/env python import maya.cmds as cmds def cleanExtract(): #define selected objects objectShapes = cmds.ls(selection = True, objectsOnly = True) objects = cmds.listRelatives(objectShapes, parent = True) #Only get selected faces selected = cmds.ls(selection = True, flatten = True) #extract the faces cmds.polyChipOff(selected, kft = True, ch = True, off = False, dup = False) sepGeo = cmds.polySeparate(objects, rs = True, ch = True, n = objects[0] + "_old") #Combine new pieces into one mesh if len(sepGeo) > 3: newGeo = cmds.polyUnite(sepGeo[1:], n = objects[0] + "_new") cmds.bakePartialHistory(newGeo, ppt = True) if len(sepGeo) <= 3: cmds.rename(sepGeo[1], objects[0] + "_new") #delete non deformer history cmds.bakePartialHistory(objects, ppt = True) cmds.ungroup(objects) cleanExtract()
© 2016 Bryanna London