Skip to content

Instantly share code, notes, and snippets.

@taikomatsu
Last active March 12, 2021 09:21
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 taikomatsu/f1021a0d01a22309e67f9ef928040e8c to your computer and use it in GitHub Desktop.
Save taikomatsu/f1021a0d01a22309e67f9ef928040e8c to your computer and use it in GitHub Desktop.
Add shading group info to object for export Alembic
# transformではなくshapeにアトリビュートを持たせないとHoudiniに持っていけないところがミソ
from pymel.core import *
sgs = ls(type='shadingEngine')
for sg in sgs:
shapes = listConnections(sg.dagSetMembers, s=True, d=False, p=False)
for sh in shapes:
shs = sh.getShapes() if objectType(sh, i='transform') else [sh]
for o in shs:
attrname = 'sg'
addAttr(o, ln=attrname, dt='string')
o.attr(attrname).set(sg.name())
print('# Done')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment