Search code examples
pythonmayapymel

How to select geo when you have a component of that geo?


How do you get the name of a piece of geo when all you have is a component of that geo (uvs, faces, verts, edges)?

so for example I have:

MeshVertex(u'pCubeShape1.vtx[0]') #replace that with any of the following (uvs, faces, edges)

and what I would like to end up with is:

nt.Transform(u'pCube1')

How can I do this?


Solution

  • Say vtx = MeshVertex(u'pCubeShape1.vtx[0]')

    then the transform/geo can be found using:

    import pymel.core as pc
    transforms = pc.listTransforms(vtx.node())
    transform = transforms[0] #in case there is only one.