Skip to content

Instantly share code, notes, and snippets.

@Muream
Last active May 6, 2019 07:30
Show Gist options
  • Save Muream/c7c1e88f92e1be8239f99394dd65a6a4 to your computer and use it in GitHub Desktop.
Save Muream/c7c1e88f92e1be8239f99394dd65a6a4 to your computer and use it in GitHub Desktop.
Maya Re-order Deformers
import pymel.core as _pymel
expectedOrder = ['cube_dmh', 'cube_ffd', 'cube_skn', 'cube00_twk']
mesh = _pymel.PyNode('cube_geo')
currentIteration = 0
indexToMatch = 0
currentOrder = [x.name() for x in mesh.listHistory(type='geometryFilter')]
deformersInOrder = False
while expectedOrder != currentOrder:
if expectedOrder[indexToMatch] != currentOrder[indexToMatch]:
_pymel.reorderDeformers(expectedOrder[indexToMatch], currentOrder[indexToMatch], mesh)
else:
indexToMatch += 1
currentOrder = [x.name() for x in mesh.listHistory(type='geometryFilter')]
currentIteration += 1
if currentIteration > maxIteration:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment