import maya.cmds as cmds
import re
# List all meshes in the scene
meshes = cmds.ls(type="mesh")
# Define the naming convention regex pattern
# Use capture groups and wildcard patterns to match the material name and mesh name
# Append "Shape" to the end of the regex pattern to only match mesh objects with "Shape" in their name
naming_convention = "(.+)_(.+)_####_GEOShape"
# Check if the "NamingConventionFail" selection set already exists
if cmds.objExists("NamingConventionFail"):
# Delete the "NamingConventionFail" selection set
cmds.delete("NamingConventionFail")
# Create the "NamingConventionFail" selection set
cmds.sets(name="NamingConventionFail")
# Loop through the meshes
for mesh in meshes:
# Use re.search to check if the mesh name matches the naming convention
match = re.search(naming_convention, mesh)
if not match:
# Add the mesh to the "NamingConventionFail" selection set
cmds.sets(mesh, add="NamingConventionFail")
# Get the list of meshes in the "NamingConventionFail" selection set
mesh_list = cmds.sets("NamingConventionFail", query=True)
# Create a GUI window
window = cmds.window(title="Naming Convention Check")
# Create a column layout in the GUI window
layout = cmds.columnLayout()
# Create a label that displays the text "List of meshes that don't follow the correct naming convention"
cmds.text(label="List of meshes that don't follow the correct naming convention")
# Create a text scroll list in the column layout
cmds.textScrollList(append=mesh_list)
# Show the GUI window
cmds.showWindow(window)