& Construction

Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
& Manufacturing

Professional CAD/CAM tools built on Inventor and AutoCAD
Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
Professional CAD/CAM tools built on Inventor and AutoCAD
Hey guys, i am trying to write a script for checking UVs which are really small. Basicaly i want to select all uv shells below for example 3px in 2048 map size.
Solved! Go to Solution.
This Python script should be able to do that. Just change the arguments passed into select_small_shells() to match what minimum size vs texture size you need, and have your meshes selected before you run it.
import maya.cmds as cmds import maya.mel as mel #This will select UV shells that are smaller than a minimum size in pixels, compared to a texture size in pixels #Any uv shell smaller than the minimum size in either the U or V direction will be selected after the operation. def select_small_shells(min_size, texture_size): sel = cmds.ls(sl=True) mel.eval('ConvertSelectionToUVs') mel.eval("global string $shells [];") shells = mel.eval("$shells =texGetShells();") min_size_normalized = float(min_size)/float(texture_size) small_shells = [] for shell in shells: bounding_box_points = cmds.polyEvaluate(shell,bc2=True) u_dist = abs(bounding_box_points[0][1] - bounding_box_points[0][0]) v_dist = abs(bounding_box_points[1][1] - bounding_box_points[1][0]) if u_dist < min_size_normalized or v_dist < min_size_normalized: small_shells.append(shell) cmds.select(small_shells,r=True) #change the arguments here to match min shell size, and texture size. select_small_shells(3,2048)
Update:
Found a bug with the previous script related to how the Maya command texGetShells sometimes returns UV shells as a long string. Use this script instead to account for that:
import maya.cmds as cmds import maya.mel as mel #This will select UV shells that are smaller than a minimum size in pixels, compared to a texture size in pixels #Any uv shell smaller than the minimum size in either the U or V direction will be selected after the operation. def select_small_shells(min_size, texture_size): sel = cmds.ls(sl=True) mel.eval('ConvertSelectionToUVs') mel.eval("global string $shells [];") shells = mel.eval("$shells =texGetShells();") min_size_normalized = float(min_size)/float(texture_size) small_shells = [] i = 0 while i < len(shells): tokenized_shell = shells[i].split(' ') bounding_box_points = cmds.polyEvaluate(tokenized_shell,bc2=True) u_dist = abs(bounding_box_points[0][1] - bounding_box_points[0][0]) v_dist = abs(bounding_box_points[1][1] - bounding_box_points[1][0]) if u_dist < min_size_normalized or v_dist < min_size_normalized: for sub_shell in tokenized_shell: small_shells.append(sub_shell) i += 1 cmds.select(small_shells,r=True) #change the arguments here to match min shell size, and texture size. select_small_shells(100,100)
I think a more definite answer to this question would be to,
Thanks a lot man! That works great!! ❤️ You rock 🤘
OMG! This is exactly what I was looking for! It will speed my work a lot!
Thanks a lot @osidedan ! 😄 😄 😄
Hi,
Even if UV shells have sufficient pixel distance, that is getting selected. And some if some uv shells are much closer, they are not getting detected. Any idea what could be the issue?
How to buy
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © 2025 Autodesk Inc. All rights reserved
Type a product name