When doing face assignments or other component members into a set and then query cmds.sets(my_set, query=True)
you get the members like:
pCube1.f[0:4]
Instead of
pCubeShape1.f[0:4]
For whatever reason someone thought it would be nice to make it look as if the components are on the transform instead of shape. Does anyone know a maya command to expand that to the shape?
I could of course do:
from maya import cmds
def expand(member: str) -> str:
if "." in member:
node, components = member.split(".", 1)
if not cmds.objectType(node, isAType="shape"):
shape = cmds.listRelatives(node, shapes=True)[0]
node = f"{node}|{shape}"
member = f"{node}.{components}"
return member
That is assuming only shapes can have components
For example:
# Example
cube = cmds.polyCube()[0]
s = cmds.sets(f"{cube}.f[0:4]")
members = cmds.sets(s, query=True)
print(members)
['pCube1.f[0:4]']
print([expand(member) for member in members])
['pCube1|pCubeShape1.f[0:4]']
But I wonder if there's a better way. Do note that maya does 'auto-expand' to the shape as soon as there is more than one shape underneath the transform:
cube = cmds.polyCube()[0]
s = cmds.sets(f"{cube}.f[0:4]")
cmds.createNode("lattice", parent=cube)
members = cmds.sets(s, query=True)
print(members)
# ['pCubeShape1.f[0:4]']
There must be a simple maya command for this that I'm missing?