Something like this should have you covered.
for mesh in cmds.ls(selection=True, type="mesh"):
cmds.select("%s.f[0:]" % mesh)
cmds.sets(name="%s_set" % mesh)
The .f[]
syntax is for selecting faces, it’s what you see echoed in the Script Editor as you select a face interactively via the viewport.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/24a2b1e9-f975-4461-97a1-e1155b235973n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/66b60eee-81c2-4ea5-9f77-effe7565d39an%40googlegroups.com.
Cool. :) It should be fast, you’re more or less passing the burden of actually iterating over the scene to those two commands which are already implemented in C++. So it’s likely that trying to replicate this via the Python API would be more expensive.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5e7dd6e7-ff12-4c8c-b5c2-aaaaafee720bn%40googlegroups.com.
print(faces)
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBZ10508id9V4yM9MrePJSRitKqqLefz4XvqFt0y2eVNw%40mail.gmail.com.