Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import maya.cmds as mc
- '''
- import maya.cmds as mc
- mc.scriptJob(kill=77, force=True)
- '''
- def selectionChanged():
- print 'Script Job Executed!'
- # Begin UI -----------------------------------------------------------
- def startScriptJob(*args):
- print 'StartJob'
- newJob = mc.scriptJob(event=['SelectionChanged',selectionChanged])
- print 'JOBNUMBER:', newJob
- def endScriptJob(*args):
- print 'EndJob'
- mc.scriptJob(kill=newJob, force=True)
- def loadHelp(*args):
- pass
- def ScriptJobUI():
- # Define new window name
- newWindow = 'SelectEdgeJob'
- # Check to see if the Window exists, Delete Window
- if mc.window(newWindow, query=True, exists=True):
- mc.deleteUI(newWindow)
- # Define window attributes
- mc.window(newWindow, title='SelectEdgeJob', sizeable=True)
- # Create menu bar with help
- menuBarLayout = mc.menuBarLayout()
- helpMenu = mc.menu( label='help', tearOff=False )
- howToHelp = mc.menuItem( label='How to use', command=loadHelp)
- # Main Layout of all menu is a form
- mainFormLayout = mc.formLayout()
- menuSeparator = mc.separator(style='in')
- bottomSeparator = mc.separator(style='in')
- # create button to launch function
- startSelectionButton = mc.button(label='Start Selection', command=startScriptJob)
- # create button to complete function
- endtSelectionButton = mc.button(label='End Selection', command=endScriptJob)
- # Position the controls MainForm
- mc.formLayout(mainFormLayout, edit=True, # attach to the form
- attachForm=[(menuSeparator, 'top',3),
- (menuSeparator, 'left',3),
- (menuSeparator, 'right',3),
- (startSelectionButton, 'left',3),
- (endtSelectionButton, 'right',3),
- (bottomSeparator, 'left',3),
- (bottomSeparator, 'right',3),
- (bottomSeparator, 'bottom',5),
- ],
- # Attach controls to positions
- attachPosition=[(startSelectionButton, 'right', 2, 50),
- (endtSelectionButton, 'left', 2, 50),
- ],
- # Attach controls to other controls
- attachControl=[(startSelectionButton, 'top',5,menuSeparator),
- (endtSelectionButton, 'top',5,menuSeparator),
- ],
- )
- mc.showWindow(newWindow)
- ScriptJobUI()
Advertisement
Add Comment
Please, Sign In to add comment