Skip to content

Instantly share code, notes, and snippets.

@BigRoy
Created May 20, 2025 10:23
Show Gist options
  • Save BigRoy/d138197a13b167f3aa520a62032a27ba to your computer and use it in GitHub Desktop.
Save BigRoy/d138197a13b167f3aa520a62032a27ba to your computer and use it in GitHub Desktop.
Simple example script on how to set `USD_subdivisionScheme` attribute on Maya selected meshes with Python to override per-mesh Maya USD Export subdivision scheme
from typing import Literal
import maya.cmds as cmds
def set_usd_subdivision_scheme(
mesh: str,
scheme: Literal["catmullClark", "none", "loop", "bilinear", None] = "catmullClark"
):
"""Set mesh USD Subdivision Scheme for export
Sce
"""
# Delete the attribute if it exists
if cmds.attributeQuery('USD_subdivisionScheme', node=mesh, exists=True):
cmds.deleteAttr(f"{mesh}.USD_subdivisionScheme")
if scheme is not None:
cmds.addAttr(mesh, ln="USD_subdivisionScheme", dt="string")
cmds.setAttr(f"{mesh}.USD_subdivisionScheme", scheme, type="string")
meshes_under_selection = cmds.ls(selection=True, long=True, leaf=True, type="mesh", noIntermediate=True, dag=True)
for mesh in meshes_under_selection:
set_usd_subdivision_scheme(mesh, "none")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment