agudmund

tmp

Jan 14th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. from maya import cmds
  2.  
  3. def main():
  4.     input = cmds.promptDialog(
  5.             title='MEL >>> Python',
  6.             message='Insert MEL command:',
  7.             button=['Print', 'Cancel'],
  8.             defaultButton='Print',
  9.             cancelButton='Cancel',
  10.             dismissString='Cancel')
  11.  
  12.     if input == 'Print':
  13.         cmd = cmds.promptDialog(query=True, text=True)
  14.            
  15.     components = cmd.split('-')[1:]
  16.     formatted=[]
  17.  
  18.     for n in components:
  19.         thing = n.split()[0]
  20.         value = n.split()[1:]
  21.         if len(value)>1:
  22.             value = '(%s)' % ','.join(value)
  23.         else:
  24.             value = value[0]
  25.         if value == 'none':
  26.             value = None
  27.             continue
  28.         if value.isalpha():
  29.             value = '"%s"' % value
  30.         formatted.append('%s=%s' %(thing,value))
  31.  
  32.     print "cmds.%s(%s)"%(cmd.split('-')[0].strip(),', '.join(formatted))
  33.  
  34. main()
Advertisement
Add Comment
Please, Sign In to add comment