Search code examples
pythonmayapymel

Get Shape from selected Edges


Im using Maya to perform a certain task on selected edges.

Let's say I save these edges like this:

edges = pm.filterExpand(sm=32)

From here, I can just select the first edge, and get the object by splitting the unicode string:

'pSphere1.e[274]'

Here's how I split it, and it gave me pSphere1, however calling getShape() on that still doesn't work because it's a unicode object.

object = edges[0].split('.')[0].getShape()

Is there a better way to do this?


Solution

  • We can find the shape from the edge, by simply listing it's immediate connection with the use of node()

    PYMEL:

    pm.PyNode(selection[0].node().getParent())

    No need to split the string, or re map the array.