Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Find edges on a loop between two symmetrical sets of edges
from maya import cmds
def find_edges_between(input_edges=None, summery_axis='x'):
Given an list of edges on one side of a mesh this function finds the edges on the same loop that are between
the input edge(s) and a symetrical set of edges. This function is not dependant on edge indices
:param input_edges A lsit of at least one edge on one side of a mesh.
:param summery_axis The symmerty axsis in object space NOT world space.
:returns List of the edges in between
if not input_edges: # Get selection if no list is passed
edge_set_1 =, fl=True)
else:, r=True) # Select the list
edge_set_1 =, fl=True) # Make sure the edge list is flat (every edge name listed)
cmds.symmetricModelling(about='object', axis=summery_axis, s=1) # Turn on object symmetry around the axis passed, symmetry=True, r=True) # Replace the selection with a symmetrical selection
# Loop selection and keep a list of new edges aka symmetrical edges
edge_set_2 = [e for e in, fl=True) if e not in edge_set_1]
cmds.symmetricModelling(s=0) # Turn off object symmetry
# Get the index of the first edge in the lists of edges and cast to int
edge_1 = int(edge_set_1[0].split('[')[-1].split(']')[0])
edge_2 = int(edge_set_2[0].split('[')[-1].split(']')[0])
# Find the shortest edge loop path between the above two indices
between_edges = [e for e in cmds.polySelect(edgeLoopPath=(edge_1, edge_2), ass=True, ns=True)
if e not in edge_set_1 and e not in edge_set_2]
print(between_edges) # Print the between edges for easy copy and paste
return between_edges
in_between_edges = find_edges_between(['pSphere1.e[47]', 'pSphere1.e[93]', 'pSphere1.e[155]'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.