Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Quick and dirty script to select the mesh shapes from your current selection that have UV shells that are ON the border.
- or outside (or on) the range given by the parameters in the script.
- Written by Roy Nieterau at Colorbleed Animation Studios (www.colorbleed.nl)
- For our 'never spoke with this guy before' friend @cgbeige (Dave Girard).
- Consider this released under the GNU GENERAL PUBLIC LICENSE, use it whenever you like.
- """
- import maya.api.OpenMaya as om2
- import maya.cmds as mc
- def getMeshWithUVsOutRange(meshShapes, minU=0.0, maxU=1.0, minV=0.0, maxV=1.0):
- # Get a list of all meshes that have UVs out of range
- outsideOfRange = []
- for mesh in meshShapes:
- uvs = om2.MFnMesh(om2.MGlobal.getSelectionListByName(mesh).getDependNode(0)).getUVs()
- if any((u, v) for (u, v) in zip(uvs[0], uvs[1]) if u <= minU or u >= maxU or v <= minV or v >= maxV):
- outsideOfRange.append(mesh)
- return outsideOfRange
- if __name__ == "__main__":
- # Get all mesh shapes nodes from the selection (note: gets any in the children hierarchy as well)
- shapes = mc.ls(sl=1, dag=1, leaf=1, shapes=1, long=1)
- meshes = mc.ls(shapes, long=1, type="mesh")
- outsideOfRange = getMeshWithUVsOutRange(meshes)
- # Do something with our filtered result
- if not outsideOfRange:
- print "You're safe. Everything in range!"
- else:
- mc.select(outsideOfRange, r=1)
- print "Darn dude, fix this shit! Check these: {0}".format(outsideOfRange)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement