Skip to content

Instantly share code, notes, and snippets.

@SEVEZ
Last active February 25, 2016 18:59
Show Gist options
  • Save SEVEZ/9d53476143c09590c5ba to your computer and use it in GitHub Desktop.
Save SEVEZ/9d53476143c09590c5ba to your computer and use it in GitHub Desktop.
Match selected object names by their symetrical position across X. If L_arm matches R_leg, L-arm -> L_leg.
import maya.cmds as mc
eps = 1E-5
sel = mc.ls( sl=1 )
while sel:
v = mc.xform( sel[0], q=1, rp=1, ws=1 )
for s in sel[1:]:
vo = mc.xform( s, q=1, rp=1, ws=1 )
if abs( v[0] + vo[0] ) < eps and abs( v[1] - vo[1] ) < eps and abs( v[2] - vo[2] ) < eps:
mc.rename( s, s[:2] + sel[0][2:] )
sel.remove( sel[0] )
sel.remove( s )
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment