def main(): sceneName = pm.sceneName().basename() part = sceneName.split("_") if part[0].endswith('.ma') or part[0].endswith('.mb'): scene = part[0][:-3] elif part[0] == '': scene = 'scene' else: scene = part[0] num = '1'.zfill(3) selFace = pm.selected() shape = pm.listRelatives(selFace, p=True) obj = pm.listRelatives(shape, p=True) part = obj[0].split("_") pm.polyChipOff(selFace, dup=False) pm.polySeparate(obj) pm.delete(ch=True) childs = pm.listRelatives(obj, c=True) for child in childs: print len(part) if len(part) == 1: pm.rename(child, '_'.join(['geo', part[0], scene, num])) else: pm.rename(child, '_'.join(['geo', part[1], scene, num])) if pm.objExists('_'.join(['grp', 'geo', scene])): pm.parent(child, '_'.join(['grp', 'geo', scene])) else: pm.parent(child, w=True) pm.delete(obj)
def smartExtract(): transforms = pm.ls(selection=True) if 0 == len(transforms): print("You need to select an object first.") return for node in transforms: node_type = repr(node) if 'nt.Transform' in node_type: pm.polyChipOff(node)[0].setKeepFacesTogether(val=False) pieces = pm.polySeparate(node) pm.delete(pieces[0]) pm.delete(ch=True)
def ec_face_mirror(self, **kwargs): attr = kwargs.setdefault('axis', 'sx') if self.gui is True: obj = py.textField('nameText', q=True, tx=True) else: obj = kwargs.setdefault('obj') sel = py.ls(sl=True) py.polyChipOff(sel, dup=True) temp_obj = py.polySeparate(obj, n='tempObj') py.setAttr('%s.%s' % (temp_obj[1], attr), -1) py.select(temp_obj) temp_obj[0] = py.polyUnite(temp_obj, ch=False) py.rename(temp_obj[0], obj) mel.eval('ConvertSelectionToVertices;') py.polyMergeVertex()
def setSplit(): sel = pm.ls(sl=True) for obj in sel: chipNames=[] if obj.getShape(): sets=obj.getShape().listConnections(d=False,s=True,type='objectSet') print sets for setM in sets: faces=[face for face in pm.ls (setM.members(), flatten=True) if pm.objectType(face) == 'mesh'] chip=pm.polyChipOff(faces,dup=False, ch=True, n=setM+'_CO', xft=True) chipNames.append(setM) print chipNames #chipNames.reverse() #separated= '''
# Copyright (c) 2015 Cesar A. Rodriguez #from pymel.core import * import pymel.core as pm #pm.createNode('transform', name='ecoliTransform') #pm.createNode('mesh', name='ecoliMesh', parent='ecoliTransform') #pm.createNode('Ecoli', name='ecoliNode') # #pm.connectAttr('time1.outTime', 'ecoliNode.time') #pm.connectAttr('ecoliNode.outputMesh', 'ecoliMesh.inMesh') # #sets -add initialShadingGroup ecoliMesh; #pm.sets('ecoliMesh', add='initialShadingGroup') pm.polyExtrudeFacet('ecoliTransform.f[2]', ch=True, pvz=3, ltz=3.0, twist=0, taper=1, tk=0) pm.polyChipOff('ecoliTransform.f[2]', 'ecoliTransform.f[6:9]', dup=False, tz=1) pm.polySeparate('ecoliMesh') pm.select(clear=True)