maya python get internal edges

Solutions on MaxInterview for maya python get internal edges by the best coders in the world

showing results for - "maya python get internal edges"
Matthew
11 Mar 2020
1from maya import cmds
2
3
4def find_edges_between(input_edges=None, summery_axis='x'):
5    '''
6    Given an list of edges on one side of a mesh this function finds the edges on the same loop that are between
7    the input edge(s) and a symetrical set of edges. This function is not dependant on edge indices
8    :param input_edges A lsit of at least one edge on one side of a mesh.
9    :param summery_axis The symmerty axsis in object space NOT world space.
10    :returns List of the edges in between
11    '''
12    if not input_edges:  # Get selection if no list is passed
13        edge_set_1 = cmds.ls(sl=True, fl=True)
14    else:
15        cmds.select(input_edges, r=True)  # Select the list
16        edge_set_1 = cmds.ls(sl=True, fl=True)  # Make sure the edge list is flat (every edge name listed)
17    cmds.symmetricModelling(about='object', axis=summery_axis, s=1)  # Turn on object symmetry around the axis passed
18    cmds.select(edge_set_1, symmetry=True, r=True)  # Replace the selection with a symmetrical selection
19    # Loop selection and keep a list of new edges aka symmetrical edges
20    edge_set_2 = [e for e in cmds.ls(sl=True, fl=True) if e not in edge_set_1]
21    cmds.symmetricModelling(s=0)  # Turn off object symmetry
22    # Get the index of the first edge in the lists of edges and cast to int
23    edge_1 = int(edge_set_1[0].split('[')[-1].split(']')[0])
24    edge_2 = int(edge_set_2[0].split('[')[-1].split(']')[0])
25    # Find the shortest edge loop path between the above two indices
26    between_edges = [e for e in cmds.polySelect(edgeLoopPath=(edge_1, edge_2), ass=True, ns=True)
27                     if e not in edge_set_1 and e not in edge_set_2]
28    print(between_edges)  # Print the between edges for easy copy and paste
29    return between_edges
30
similar questions
queries leading to this page
maya python get internal edges