Skip to content

Instantly share code, notes, and snippets.

@BigRoy
Created January 31, 2024 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BigRoy/73af83a1312f20ae320263223b9b7759 to your computer and use it in GitHub Desktop.
Save BigRoy/73af83a1312f20ae320263223b9b7759 to your computer and use it in GitHub Desktop.
Maya get all hard edges (note that a mesh may still display smooth if e.g. it had locked normals)
from maya import cmds
import maya.api.OpenMaya as om
def get_fn_mesh(mesh):
sel = om.MSelectionList()
sel.add(mesh)
dag = sel.getDagPath(0)
return om.MFnMesh(dag)
hard_edged_meshes = []
for mesh in cmds.ls(type="mesh", noIntermediate=True, long=True):
fn_mesh = get_fn_mesh(mesh)
for i in range(fn_mesh.numEdges):
if not fn_mesh.isEdgeSmooth(i):
hard_edged_meshes.append(f"{mesh}.e[{i}]")
if hard_edged_meshes:
cmds.select(hard_edged_meshes, replace=True, noExpand=True)
else:
cmds.select(clear=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment