def doIt(self, args): dagPath = mt.selected_dagPath(); meshFn = om.MFnMesh(dagPath); (nFV, F) = mt.getTopology(meshFn); mU = om.MFloatArray(len(F),0.5); mV = om.MFloatArray(len(F),0.5); mI = om.MIntArray(len(F),0); TU = [0.5, 0.5, 0, 0]; TV = [0.5, 0, 0, 0.5]; idx=0; vp1 = om.MPoint(); vp2 = om.MPoint(); vp3 = om.MPoint(); for kF in range(len(nFV)): V = mt.face_vertices(dagPath, kF); FC = 0; maxV = 0; for kV in range(4): if V[kV]>maxV: FC=kV; maxV=V[kV]; for kFV in range(4): mU[idx] = TU[(kFV-FC)%4]; mV[idx] = TV[(kFV-FC)%4]; mI[idx] = idx; idx = idx + 1; continue; meshFn.clearUVs(); meshFn.setUVs(mU, mV); meshFn.assignUVs(nFV, mI);
def doIt(self, args): dagPath = mt.selected_dagPath(); meshFn = om.MFnMesh(dagPath); mel.eval("SelectVertexFaceMask"); cmds.select(cl=True); vp1 = om.MPoint(); vp2 = om.MPoint(); vp3 = om.MPoint(); (nFV, F) = mt.getTopology(meshFn); for kF in range(len(nFV)): if nFV[kF]==5: V = mt.face_vertices(dagPath, kF); maxAngle = 0.0; for kV in range(5): meshFn.getPoint(V[(kV-1)%5], vp1) meshFn.getPoint(V[kV],vp2); meshFn.getPoint(V[(kV+1)%5], vp3); a=vp1 - vp2; if a*a>0: a=a/a.length(); b=vp3 - vp2; if b*b>0: b=b/b.length(); angle = math.acos(a*b); if angle>maxAngle: T=V[kV]; maxAngle = angle; cmds.select(dagPath.fullPathName()+".vtxFace["+str(T)+"]["+str(kF)+"]", tgl=True);
def remove_knot(): dagPath = mt.selected_dagPath(); meshFn = om.MFnMesh(dagPath); for d in knot_modifier(KnotModifier.Remove): (v, p) = d; meshFn.setPoint(v, om.MPoint(p.x, p.y, p.z));
def doIt(self, args): dagPath = mt.selected_dagPath(); meshFn = om.MFnMesh(dagPath); mel.eval("SelectVertexMask"); cmds.select(cl=True); tccNode = mt.get_TCC_DGnode(dagPath); T = om.MIntArray(meshFn.numVertices(), 0); if tccNode is not None: Tb = cmds.getAttr(tccNode.name()+".T"); (nFV, F) = mt.getTopology(meshFn); for k in range(len(F)): T[F[k]] += Tb[k]; polesArray = []; connectedEdges = om.MIntArray() vertexIter=om.MItMeshVertex(dagPath) while not vertexIter.isDone(): vertexIter.getConnectedEdges(connectedEdges); valence = len(connectedEdges) + T[vertexIter.index()]; if (not vertexIter.onBoundary()) and (valence!=4): polesArray.append(vertexIter.index()); vertexIter.next() for k in polesArray: cmds.select(dagPath.fullPathName()+".vtx["+str(k)+"]", tgl=True);
def doIt(self, args): dagPath = mt.selected_dagPath() meshFn = om.MFnMesh(dagPath) mel.eval("SelectVertexFaceMask") cmds.select(cl=True) vp1 = om.MPoint() vp2 = om.MPoint() vp3 = om.MPoint() (nFV, F) = mt.getTopology(meshFn) for kF in range(len(nFV)): if nFV[kF] == 5: V = mt.face_vertices(dagPath, kF) maxAngle = 0.0 for kV in range(5): meshFn.getPoint(V[(kV - 1) % 5], vp1) meshFn.getPoint(V[kV], vp2) meshFn.getPoint(V[(kV + 1) % 5], vp3) a = vp1 - vp2 if a * a > 0: a = a / a.length() b = vp3 - vp2 if b * b > 0: b = b / b.length() angle = math.acos(a * b) if angle > maxAngle: T = V[kV] maxAngle = angle cmds.select(dagPath.fullPathName() + ".vtxFace[" + str(T) + "][" + str(kF) + "]", tgl=True)
def doIt(self, args): dagPath = mt.selected_dagPath() meshFn = om.MFnMesh(dagPath) mel.eval("SelectVertexMask") cmds.select(cl=True) tccNode = mt.get_TCC_DGnode(dagPath) T = om.MIntArray(meshFn.numVertices(), 0) if tccNode is not None: Tb = cmds.getAttr(tccNode.name() + ".T") (nFV, F) = mt.getTopology(meshFn) for k in range(len(F)): T[F[k]] += Tb[k] polesArray = [] connectedEdges = om.MIntArray() vertexIter = om.MItMeshVertex(dagPath) while not vertexIter.isDone(): vertexIter.getConnectedEdges(connectedEdges) valence = len(connectedEdges) + T[vertexIter.index()] if (not vertexIter.onBoundary()) and (valence != 4): polesArray.append(vertexIter.index()) vertexIter.next() for k in polesArray: cmds.select(dagPath.fullPathName() + ".vtx[" + str(k) + "]", tgl=True)
def remove_knot(): dagPath = mt.selected_dagPath() meshFn = om.MFnMesh(dagPath) for d in knot_modifier(KnotModifier.Remove): (v, p) = d meshFn.setPoint(v, om.MPoint(p.x, p.y, p.z))
def doIt(self, args): dagPath = mt.selected_dagPath(); meshFn = om.MFnMesh(dagPath); mel.eval("SelectVertexMask"); cmds.select(cl=True); for k in range(meshFn.numVertices()): ve = mt.vertex_edges(dagPath, k); vf = mt.vertex_faces(dagPath, k); if len(ve)==2 and len(vf)>1: cmds.select(dagPath.fullPathName()+".vtx["+str(k)+"]", tgl=True);
def doIt(self, args): dagPath = mt.selected_dagPath() meshFn = om.MFnMesh(dagPath) mel.eval("SelectVertexMask") cmds.select(cl=True) for k in range(meshFn.numVertices()): ve = mt.vertex_edges(dagPath, k) vf = mt.vertex_faces(dagPath, k) if len(ve) == 2 and len(vf) > 1: cmds.select(dagPath.fullPathName() + ".vtx[" + str(k) + "]", tgl=True)
def doIt(self, args): if args.length()<1: raise RuntimeError("have to specify 'insert'/'remove'!"); if args.asString(0)=="insert": data = km.knot_modifier( km.KnotModifier.Insert ); elif args.asString(0)=="remove": data = km.knot_modifier( km.KnotModifier.Remove ); else: raise RuntimeError("have to specify 'insert'/'remove'!"); dagPath = mt.selected_dagPath(); dagPath.extendToShape(); nameStr = dagPath.fullPathName(); for vp in data: (v, p) = vp; cmds.move(p.x, p.y, p.z, nameStr+".vtx["+str(v)+"]", absolute=True, objectSpace=True);
def doIt(self, args): dagPath = mt.selected_dagPath() meshFn = om.MFnMesh(dagPath) mel.eval("SelectVertexMask") cmds.select(cl=True) tccNode = mt.get_TCC_DGnode(dagPath) T = om.MIntArray(meshFn.numVertices(), 0) if tccNode is not None: Tb = cmds.getAttr(tccNode.name() + ".T") (nFV, F) = mt.getTopology(meshFn) for k in range(len(F)): T[F[k]] += Tb[k] vertexIter = om.MItMeshVertex(dagPath) while not vertexIter.isDone(): idx = vertexIter.index() if T[idx] > 0: cmds.select(dagPath.fullPathName() + ".vtx[" + str(idx) + "]", tgl=True) vertexIter.next()
def doIt(self, args): v = mt.selected_vertices(); dagPath = mt.selected_dagPath(); TCC = mt.get_TCC_DGnode(dagPath); corner = cmds.getAttr(TCC.name()+".corner"); # check if all elements in selection have same value val = corner[v[0]]; allEqual = True; for cv in v: if corner[cv] != val: allEqual = False; break; if allEqual: val = (val+1) % 3; else: val = 0; for cv in v: corner[cv] = val; cornerType = ["off", "on", "auto"]; print "All vertices set to corner="+cornerType[val]; cmds.setAttr(TCC.name()+".corner", corner, type="Int32Array");
def doIt(self, args): if args.length() < 1: raise RuntimeError("have to specify 'insert'/'remove'!") if args.asString(0) == "insert": data = km.knot_modifier(km.KnotModifier.Insert) elif args.asString(0) == "remove": data = km.knot_modifier(km.KnotModifier.Remove) else: raise RuntimeError("have to specify 'insert'/'remove'!") dagPath = mt.selected_dagPath() dagPath.extendToShape() nameStr = dagPath.fullPathName() for vp in data: (v, p) = vp cmds.move(p.x, p.y, p.z, nameStr + ".vtx[" + str(v) + "]", absolute=True, objectSpace=True)