Question

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?

Was it helpful?

Solution 2

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.

OTHER TIPS

EFilterExpand always returns strings (whether called from cmds or pm). Use PyNode to convert:

mesh_edges = map(pm.PyNode, pm.filterExpand(sm=32))
for item in mesh_edges: 
        print item.node(), item.indices()[0]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top