1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| for shape in check_list: parents=shape.split("|") parents=list(filter(None,parents)) check_shape=parents[0] isFreReturn=False isPiviotReturn=False for i in range(1,len(parents)): tempFloat=cmds.getAttr(check_shape+'.t')[0] if tempFloat[0] != 0 or tempFloat[1] != 0 or tempFloat[2] != 0: isFreReturn=True tempFloat=cmds.getAttr(check_shape+'.r')[0] if tempFloat[0] != 0 or tempFloat[1] != 0 or tempFloat[2] != 0: isFreReturn=True tempFloat=cmds.getAttr(check_shape+'.s')[0] if tempFloat[0] != 1 or tempFloat[1] != 1 or tempFloat[2] != 1: isFreReturn=True tempFloat=cmds.getAttr(check_shape+'.rp')[0] if tempFloat[0] != 0 or tempFloat[1] != 0 or tempFloat[2] != 0: isPiviotReturn=True tempFloat=cmds.getAttr(check_shape+'.sp')[0] if tempFloat[0] != 0 or tempFloat[1] != 0 or tempFloat[2] != 0: isPiviotReturn=True check_shape+="|{}".format(parents[i]) if isFreReturn: return {"state":False, "info": u"{}-请先冻结全部物体!!!".format(en_name)} if isPiviotReturn: return {"state":False, "info": u"{}-请先将物体中心放置在原点!!!".format(en_name)} for shape in check_list: if cmds.objExists('closestSampler'): cmds.delete('closestSampler') cmds.createNode('closestPointOnMesh',n='closestSampler') cmds.connectAttr("{}.outMesh".format(shape),'closestSampler.inMesh',f=True) numVtxs=cmds.polyEvaluate(shape,v=True) cmds.select(cl=True) for i in range(numVtxs): posA=cmds.xform("{}.vtx[{}]".format(shape,i),q=True,ws=True,t=True) if posA[0]>0.001: continue cmds.setAttr('closestSampler.inPosition',posA[0]*(-1),posA[1],posA[2]) mirrorVtx_num=cmds.getAttr('closestSampler.closestVertexIndex') posB=cmds.xform("{}.vtx[{}]".format(shape,mirrorVtx_num),q=True,ws=True,t=True) mag=math.sqrt(math.pow(posA[0]-posB[0]*(-1),2)+math.pow(posA[1]-posB[1],2)+math.pow(posA[2]-posB[2],2)) if mag>0.001: self.error_list.append("{}.vtx[{}]".format(shape,i)) self.error_list.append("{}.vtx[{}]".format(shape,mirrorVtx_num)) cmds.delete('closestSampler') cmds.refresh()
|