Question

Is there's a way to get the indices properly from a Pymel/Maya API function?

I know Pymel has a function called getEdges() however according to their docs this get's them from the selected face, however I just need them from the selected edges.

Is this possible?

Was it helpful?

Solution

While your answer will work theodox, I did find a much simpler resolution, after some serious digging!

Turns out, hiding and not very well documented, was a function ironically called indices(), I did search for this but nothing came up in the docs.

Pymel

selection[0].indices()[0]

The above will give us the integer of the selected edge. Simple and elegant!

OTHER TIPS

Do you mean you just the expanded list of selected edges? That's just FilterExpand -sm 32 or cmds.filterExpand(sm=32) or pm.filterExpand(sm=32) on an edge selection. Those commands are always strings, you grab the indices out them with a regular expression:

# where objs is a list of edges, for example cmds.ls(sl=True) on an edge selection
cList = "".join(cmds.filterExpand( *objs, sm=32))
outList = set(map ( int, re.findall('\[([0-9]+)\]', cList ) ) ) 

which will give you a set containing the integer indices of the edges (I use sets so its easy to do things like find edges common to two groups without for loops or if tests)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top