Created
September 26, 2018 19:45
-
-
Save Onefabis/0491a7f0582e0d76315d385e6ce7f470 to your computer and use it in GitHub Desktop.
Add label to selected joints
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import maya.cmds as mc | |
| sl=mc.ls( sl=1 ) | |
| nLabel = None | |
| side = None | |
| for s in sl: | |
| if s.startswith( 'L_' ) or s.startswith( 'Left_' ): | |
| try: | |
| nLabel = s.replace( 'L_', '' ) | |
| side = 1 | |
| except: | |
| nLabel = s.replace( 'Left_', '' ) | |
| side = 1 | |
| finally: pass | |
| elif s.startswith( 'R_' ) or s.startswith( 'Right_' ): | |
| try: | |
| nLabel = s.replace( 'R_', '' ) | |
| side = 2 | |
| except: | |
| nLabel = s.replace( 'Right_', '' ) | |
| side = 2 | |
| finally: pass | |
| elif s.startswith( 'C_' ) or s.startswith( 'Center_' ): | |
| try: | |
| nLabel = s.replace( 'C_', '' ) | |
| except: | |
| nLabel = s.replace( 'Center_', '' ) | |
| finally: pass | |
| elif s.endswith( '_L' ) or s.endswith( '_Left' ): | |
| try: | |
| nLabel = s.replace( '_L', '' ) | |
| side = 1 | |
| except: | |
| nLabel = s.replace( '_Left', '' ) | |
| side = 1 | |
| finally: pass | |
| elif s.endswith( '_R' ) or s.endswith( '_Right' ): | |
| try: | |
| nLabel = s.replace( '_R', '' ) | |
| side = 2 | |
| except: | |
| nLabel = s.replace( '_Right', '' ) | |
| side = 2 | |
| finally: pass | |
| elif s.endswith( '_C' ) or s.endswith( '_Center' ): | |
| try: | |
| nLabel = s.replace( '_C', '' ) | |
| except: | |
| nLabel = s.replace( '_Center', '' ) | |
| finally: pass | |
| elif '_L_' in s or '_Left_' in s: | |
| try: | |
| nLabel = s.replace( '_L_', '_' ) | |
| side = 1 | |
| except: | |
| nLabel = s.replace( '_Left_', '_' ) | |
| side = 1 | |
| finally: pass | |
| elif '_R_' in s or '_Right_' in s: | |
| try: | |
| nLabel = s.replace( '_R_', '_' ) | |
| side = 2 | |
| except: | |
| nLabel = s.replace( '_Right_', '_' ) | |
| side = 2 | |
| finally: pass | |
| elif '_C_' in s or '_Center_' in s: | |
| try: | |
| nLabel = s.replace( '_C_', '_' ) | |
| except: | |
| nLabel = s.replace( '_Center_', '_' ) | |
| finally: pass | |
| if nLabel: | |
| mc.setAttr( s + '.side', side ) | |
| mc.setAttr( s + '.type', 18 ) | |
| mc.setAttr( s + '.otherType', nLabel, type='string' ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment