Guest User

Untitled

a guest
Feb 10th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.25 KB | None | 0 0
  1. import maya.cmds as mc
  2.  
  3. '''
  4. import maya.cmds as mc
  5. mc.scriptJob(kill=77, force=True)
  6.  
  7. '''
  8.  
  9. def selectionChanged():
  10.     print 'Script Job Executed!'
  11.  
  12.  
  13. # Begin UI -----------------------------------------------------------
  14.  
  15. def startScriptJob(*args):
  16.     print 'StartJob'
  17.     newJob = mc.scriptJob(event=['SelectionChanged',selectionChanged])
  18.     print 'JOBNUMBER:', newJob
  19.  
  20. def endScriptJob(*args):
  21.     print 'EndJob'
  22.     mc.scriptJob(kill=newJob, force=True)
  23.  
  24. def loadHelp(*args):
  25.     pass    
  26.  
  27. def ScriptJobUI():
  28.    
  29.     # Define new window name
  30.     newWindow = 'SelectEdgeJob'    
  31.  
  32.     # Check to see if the Window exists, Delete Window
  33.     if mc.window(newWindow, query=True, exists=True):
  34.         mc.deleteUI(newWindow)
  35.  
  36.     # Define window attributes
  37.     mc.window(newWindow, title='SelectEdgeJob', sizeable=True)
  38.  
  39.     # Create menu bar with help    
  40.     menuBarLayout = mc.menuBarLayout()
  41.     helpMenu = mc.menu( label='help', tearOff=False )
  42.     howToHelp = mc.menuItem( label='How to use', command=loadHelp)
  43.  
  44.     # Main Layout of all menu is a form
  45.     mainFormLayout = mc.formLayout()
  46.     menuSeparator = mc.separator(style='in')
  47.     bottomSeparator = mc.separator(style='in')
  48.  
  49.     # create button to launch function
  50.     startSelectionButton = mc.button(label='Start Selection', command=startScriptJob)
  51.  
  52.     # create button to complete function
  53.     endtSelectionButton = mc.button(label='End Selection', command=endScriptJob)
  54.  
  55.     # Position the controls MainForm
  56.     mc.formLayout(mainFormLayout, edit=True, # attach to the form
  57.                                            attachForm=[(menuSeparator, 'top',3),
  58.                                                        (menuSeparator, 'left',3),
  59.                                                        (menuSeparator, 'right',3),
  60.                                                        
  61.                                                        (startSelectionButton, 'left',3),                                                      
  62.                                                        (endtSelectionButton, 'right',3),
  63.                                                        
  64.                                                        (bottomSeparator, 'left',3),
  65.                                                        (bottomSeparator, 'right',3),
  66.                                                        (bottomSeparator, 'bottom',5),
  67.                                             ],
  68.                                            
  69.                                            # Attach controls to positions
  70.                                            attachPosition=[(startSelectionButton, 'right', 2, 50),
  71.                                                            (endtSelectionButton, 'left', 2, 50),
  72.                
  73.                                             ],
  74.                
  75.                                             # Attach controls to other controls
  76.                                             attachControl=[(startSelectionButton, 'top',5,menuSeparator),
  77.                                                            (endtSelectionButton, 'top',5,menuSeparator),
  78.  
  79.                                             ],
  80.                   )
  81.    
  82.  
  83.     mc.showWindow(newWindow)
  84.  
  85.    
  86.  
  87. ScriptJobUI()
Advertisement
Add Comment
Please, Sign In to add comment