Script to create Face Sets from all materials?

Script to create Face Sets from all materials?

mattock
Contributor Contributor
2,101 Views
1 Reply
Message 1 of 2

Script to create Face Sets from all materials?

mattock
Contributor
Contributor

Hi,  does anyone know of a mel or python script that will create Face Sets in Maya from different materials or their shading groups already applied to my characters geometry?

 

I need to create face sets so that when I export my animated character as an Alembic file with "Write face sets" option checked to Unreal Engine,  it creates material slots in Unreal where I can add new materials

If I have to do this manually by right clicking each part, then selecting faces, then going > create set  for each part of my character... this is going to take a long time for all characters and all shots

I'm not a mel or python programmer so really appreciate any help
Many thanks

0 Likes
2,102 Views
1 Reply
Reply (1)
Message 2 of 2

olarn
Advocate
Advocate

The most straightforward way would be to:

Get all material nodes. (specify "lambert" type to get all kinds of build-in materials (all derived from lambert))

http://help.autodesk.com/cloudhelp/2018/ENU/Maya-Tech-Docs/CommandsPython/ls.html#flagtype

For each, select applied faces/ object using this command.

cmds.hyperShade(object=<shader name>)

And then finally use

cmds.sets()

to create sets.

0 Likes