Created
January 31, 2024 19:28
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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