def on_btn_duplicate_clicked(self, clicked=None): if clicked == None: return if not mc.objExists(self.__blendShape): return self.__sculpmodel = mc.duplicate( self.__baseModel, n=nameTool.compileMayaObjectName( '%s_Sculp' % self.__baseModel.split(':')[-1]))[0] openCloseDeformer(self.__baseModel, 0) self.__tempmodel = mc.duplicate( self.__baseModel, n=nameTool.compileMayaObjectName( '%s_Temp' % self.__baseModel.split(':')[-1]))[0] openCloseDeformer(self.__baseModel, 1) for attr in ('tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'): mc.setAttr('%s.%s' % (self.__sculpmodel, attr), l=False, k=True, cb=True) mc.setAttr('%s.%s' % (self.__tempmodel, attr), l=False, k=True, cb=True) mc.move(mc.getAttr('%s.bbmx' % self.__baseModel)[0][0] - mc.getAttr('%s.bbmn' % self.__baseModel)[0][0], 0, 0, self.__sculpmodel, r=True) mc.move(mc.getAttr('%s.bbmx' % self.__sculpmodel)[0][0] - mc.getAttr('%s.bbmn' % self.__baseModel)[0][0], 0, 0, self.__tempmodel, r=True) #- add BlendShape tempBlend = mc.blendShape(self.__sculpmodel, self.__tempmodel)[0] tempBlendAttr = mc.aliasAttr(tempBlend, q=True)[0] #- set key mc.setKeyframe('%s.%s' % (tempBlend, tempBlendAttr), t=0, v=0) mc.setKeyframe('%s.%s' % (tempBlend, tempBlendAttr), t=24, v=1) keyName = mc.keyframe('%s.%s' % (tempBlend, tempBlendAttr), q=True, n=True) mc.keyTangent(keyName, e=True, itt="spline", ott="spline")
def on_btn_FixBsBsEnd_clicked(self, clicked=None): if clicked == None:return #- selectIndexes = self.listView_attributeList.selectedIndexes() if len(selectIndexes) == 0:return selectAttr = self.__AttributeModel.data(selectIndexes[0], QtCore.Qt.DisplayRole) if not uiTool.warning('BlendShape\'s shape on attribute "%s" will be changed,\nand it can\'t to undo, \ncontinue? ?'%selectAttr):return #- dup model openCloseDeformer(self.__baseModel, 0) midModel = mc.duplicate(self.__baseModel, n=nameTool.compileMayaObjectName('%s_mid'%self.__baseModel.split(':')[-1]))[0] openCloseDeformer(self.__baseModel, 1) #- add blendShape mc.blendShape(self.__sculpmodel, self.__baseModel, midModel, w=((0, 1), (1, -1))) mc.delete(midModel, ch=True) if mc.objExists(selectAttr): mc.blendShape(midModel, selectAttr, w=((0, 1))) mc.delete(selectAttr, ch=True) mc.delete(midModel) else: shape = mc.listRelatives(midModel, s=True, path=True)[0] weightID = self.__AttributeDT2.get(selectAttr, None) TGTattr = self.__IGTAttributeDT.get(weightID, None) mc.connectAttr('%s.worldMesh[0]'%shape, '%s.%s'%(self.__blendShape, TGTattr), f=True) mc.rename(midModel, selectAttr) mc.delete(self.__sculpmodel) mc.delete(self.__tempmodel)
def on_btn_duplicate_clicked(self, clicked=None): if clicked == None:return if not mc.objExists(self.__blendShape):return self.__sculpmodel = mc.duplicate(self.__baseModel, n=nameTool.compileMayaObjectName('%s_Sculp'%self.__baseModel.split(':')[-1]))[0] openCloseDeformer(self.__baseModel, 0) self.__tempmodel = mc.duplicate(self.__baseModel, n=nameTool.compileMayaObjectName('%s_Temp'%self.__baseModel.split(':')[-1]))[0] openCloseDeformer(self.__baseModel, 1) for attr in ('tx', 'ty', 'tz','rx', 'ry', 'rz','sx', 'sy', 'sz'): mc.setAttr('%s.%s'%(self.__sculpmodel, attr), l=False, k=True, cb=True) mc.setAttr('%s.%s'%(self.__tempmodel, attr), l=False, k=True, cb=True) mc.move(mc.getAttr('%s.bbmx'%self.__baseModel)[0][0] - mc.getAttr('%s.bbmn'%self.__baseModel)[0][0], 0, 0, self.__sculpmodel, r=True) mc.move(mc.getAttr('%s.bbmx'%self.__sculpmodel)[0][0] - mc.getAttr('%s.bbmn'%self.__baseModel)[0][0], 0, 0, self.__tempmodel, r=True) #- add BlendShape tempBlend = mc.blendShape(self.__sculpmodel, self.__tempmodel)[0] tempBlendAttr = mc.aliasAttr(tempBlend, q=True)[0] #- set key mc.setKeyframe('%s.%s'%(tempBlend, tempBlendAttr), t=0, v=0) mc.setKeyframe('%s.%s'%(tempBlend, tempBlendAttr), t=24, v=1) keyName = mc.keyframe('%s.%s'%(tempBlend, tempBlendAttr), q=True, n=True) mc.keyTangent(keyName, e=True, itt="spline", ott="spline")
def duplicateScupModel(self): self.__sculpmodel = mc.duplicate( self.__baseModel, n=nameTool.compileMayaObjectName( '%s_Sculp' % self.__baseModel.split(':')[-1]))[0] for attr in ('tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'): mc.setAttr('%s.%s' % (self.__sculpmodel, attr), l=False, k=True, cb=True) mc.move(mc.getAttr('%s.bbmx' % self.__baseModel)[0][0] - mc.getAttr('%s.bbmn' % self.__baseModel)[0][0], 0, 0, self.__sculpmodel, r=True)
def on_btn_FixBsBsEnd_clicked(self, clicked=None): if clicked == None: return #- selectIndexes = self.listView_attributeList.selectedIndexes() if len(selectIndexes) == 0: return selectAttr = self.__AttributeModel.data(selectIndexes[0], QtCore.Qt.DisplayRole) if not uiTool.warning( 'BlendShape\'s shape on attribute "%s" will be changed,\nand it can\'t to undo, \ncontinue? ?' % selectAttr): return #- dup model openCloseDeformer(self.__baseModel, 0) midModel = mc.duplicate( self.__baseModel, n=nameTool.compileMayaObjectName( '%s_mid' % self.__baseModel.split(':')[-1]))[0] openCloseDeformer(self.__baseModel, 1) #- add blendShape mc.blendShape(self.__sculpmodel, self.__baseModel, midModel, w=((0, 1), (1, -1))) mc.delete(midModel, ch=True) if mc.objExists(selectAttr): mc.blendShape(midModel, selectAttr, w=((0, 1))) mc.delete(selectAttr, ch=True) mc.delete(midModel) else: shape = mc.listRelatives(midModel, s=True, path=True)[0] weightID = self.__AttributeDT2.get(selectAttr, None) TGTattr = self.__IGTAttributeDT.get(weightID, None) mc.connectAttr('%s.worldMesh[0]' % shape, '%s.%s' % (self.__blendShape, TGTattr), f=True) mc.rename(midModel, selectAttr) mc.delete(self.__sculpmodel) mc.delete(self.__tempmodel)
def dupliacteTempModel(self): openCloseDeformer(self.__baseModel, 0) self.__tempmodel = mc.duplicate( self.__baseModel, n=nameTool.compileMayaObjectName( '%s_Temp' % self.__baseModel.split(':')[-1]))[0] openCloseDeformer(self.__baseModel, 1) for attr in ('tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'): mc.setAttr('%s.%s' % (self.__tempmodel, attr), l=False, k=True, cb=True) mc.move((mc.getAttr('%s.bbmx' % self.__baseModel)[0][0] - mc.getAttr('%s.bbmn' % self.__baseModel)[0][0]) * 2, 0, 0, self.__tempmodel, r=True) #- add BlendShape tempBlend = mc.blendShape(self.__sculpmodel, self.__tempmodel)[0] tempBlendAttr = mc.aliasAttr(tempBlend, q=True)[0] #- set key startFrame = mc.playbackOptions(q=True, min=True) endFrame = mc.playbackOptions(q=True, max=True) mc.setKeyframe('%s.%s' % (tempBlend, tempBlendAttr), t=startFrame, v=0.0) mc.setKeyframe('%s.%s' % (tempBlend, tempBlendAttr), t=endFrame, v=1.0) #- edit Key Type keyName = mc.keyframe('%s.%s' % (tempBlend, tempBlendAttr), q=True, n=True) mc.keyTangent(keyName, e=True, itt="spline", ott="spline")
def dupliacteTempModel(self): openCloseDeformer(self.__baseModel, 0) self.__tempmodel = mc.duplicate(self.__baseModel, n=nameTool.compileMayaObjectName('%s_Temp'%self.__baseModel.split(':')[-1]))[0] openCloseDeformer(self.__baseModel, 1) for attr in ('tx', 'ty', 'tz','rx', 'ry', 'rz','sx', 'sy', 'sz'): mc.setAttr('%s.%s'%(self.__tempmodel, attr), l=False, k=True, cb=True) mc.move((mc.getAttr('%s.bbmx'%self.__baseModel)[0][0] - mc.getAttr('%s.bbmn'%self.__baseModel)[0][0])*2, 0, 0, self.__tempmodel, r=True) #- add BlendShape tempBlend = mc.blendShape(self.__sculpmodel, self.__tempmodel)[0] tempBlendAttr = mc.aliasAttr(tempBlend, q=True)[0] #- set key startFrame = mc.playbackOptions(q=True, min=True) endFrame = mc.playbackOptions(q=True, max=True) mc.setKeyframe('%s.%s'%(tempBlend, tempBlendAttr), t=startFrame, v=0.0) mc.setKeyframe('%s.%s'%(tempBlend, tempBlendAttr), t=endFrame, v=1.0) #- edit Key Type keyName = mc.keyframe('%s.%s'%(tempBlend, tempBlendAttr), q=True, n=True) mc.keyTangent(keyName, e=True, itt="spline", ott="spline")
def duplicateScupModel(self): self.__sculpmodel = mc.duplicate(self.__baseModel, n=nameTool.compileMayaObjectName('%s_Sculp'%self.__baseModel.split(':')[-1]))[0] for attr in ('tx', 'ty', 'tz','rx', 'ry', 'rz','sx', 'sy', 'sz'): mc.setAttr('%s.%s'%(self.__sculpmodel, attr), l=False, k=True, cb=True) mc.move(mc.getAttr('%s.bbmx'%self.__baseModel)[0][0] - mc.getAttr('%s.bbmn'%self.__baseModel)[0][0], 0, 0, self.__sculpmodel, r=True)
def _mayaRename(self): baseNameList, resultNameList = self.__listModel.result() baseNameList = [pymel.core.PyNode(x) for x in baseNameList] for node, newName in zip(baseNameList, resultNameList): mc.rename(node.name(), nameTool.compileMayaObjectName(newName))