Python maya.cmds 模块,scriptJob() 实例源码

我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用maya.cmds.scriptJob()

项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def cleanup(self):
        '''
        Clean up the mess we made.
        '''
        try:
            mc.lockNode(self.pivotHandle, lock=False)
            mc.delete(self.pivotHandle)
        except: pass

        try:
            if mc.scriptJob(exists=self.scriptJob):
                mc.scriptJob(kill=self.scriptJob, force=True)
        except: pass

        pivotHandles = mc.ls('*.ml_pivot_handle', o=True)
        if pivotHandles:
            for each in pivotHandles:
                mc.lockNode(each, lock=False)
                mc.delete(each)
项目:pipeline    作者:liorbenhorin    | 项目源码 | 文件源码
def create_scriptjob(parent = None, event = None, script = None):
    if event and script:

        return cmds.scriptJob(e=[event,script], ro=False, p = parent)
项目:pipeline    作者:liorbenhorin    | 项目源码 | 文件源码
def kill_scriptjob(job = None):
    if job:

        return cmds.scriptJob(kill = job, f = True)
项目:Modular_Rigging_Thesis    作者:LoganKelly    | 项目源码 | 文件源码
def rigUpdate(self):
        #disable refresh until the rig update is complete
        cmds.refresh(su=True)
        rigNodeFound = False
        try:
            rigGuiNode = self.scene.sceneNodes["Rig"]
            rigNodeFound = True
        except KeyError:
            rigNodeFound = False
        if rigNodeFound:
            #kill all script jobs created by controllers to avoid
            #an update loop which the rig is updated
            for jobNum in self.scriptJobNumbers:
                if jobNum != globals.currentScriptJobNum:
                    cmds.scriptJob(k=jobNum)
            self.scriptJobNumbers = []
            rigGuiNode.updateVersion += 0.1
            rootElem = self.recursiveGetXML(rigGuiNode)
            self.indent(rootElem)
            tree = xml.ElementTree(rootElem)
            file = open(self.updateXmlPath, 'w')
            tree.write(file)
            file.close()
            self.recursiveZeroOutControllers(rigGuiNode)
            if rigGuiNode.metaNodeName is not None and rigGuiNode.metaNodeName != "":
                self.rootNodeName = mel.eval("updateMetaDataManager -n \""+rigGuiNode.metaNodeName+"\";")
            else:
                self.rootNodeName = mel.eval("loadRig -p \""+self.updateXmlPath+"\";")
            cmds.select(cl=True)
            self.recursiveUpdateMetaNodes(rigGuiNode,self.rootNodeName)
            self.recursiveSetupScriptJobs(rigGuiNode)
        cmds.refresh(su=False)
项目:Modular_Rigging_Thesis    作者:LoganKelly    | 项目源码 | 文件源码
def setupScriptJobs(self):
        if self.metaNodeName is not None and self.metaNodeName != "":
            self.controllerJobNums = []
            controllerName = mel.eval('getMetaNodeConnection -n "'+self.metaNodeName+'" -c "controller";')
            self.controllerJobNums.append( cmds.scriptJob( ro=True, ac=[controllerName+'.translate', self.controllerTranslateUpdate] ) )
            self.controllerJobNums.append( cmds.scriptJob( ro=True, ac=[controllerName+'.rotate', self.controllerRotateUpdate] ) )
            self.controllerJobNums.append( cmds.scriptJob( ro=True, ac=[controllerName+'.scale', self.controllerScaleUpdate] ) )
            return self.controllerJobNums
项目:Modular_Rigging_Thesis    作者:LoganKelly    | 项目源码 | 文件源码
def setupScriptJobs(self):
        if self.metaNodeName is not None and self.metaNodeName != "":
            self.controllerJobNums = []
            controllerName = mel.eval('getMetaNodeConnection -n "'+self.metaNodeName+'" -c "controller";')
            self.controllerJobNums.append( cmds.scriptJob( ro=True, ac=[controllerName+'.translate', self.controllerTranslateUpdate] ) )
            self.controllerJobNums.append( cmds.scriptJob( ro=True, ac=[controllerName+'.rotate', self.controllerRotateUpdate] ) )
            self.controllerJobNums.append( cmds.scriptJob( ro=True, ac=[controllerName+'.scale', self.controllerScaleUpdate] ) )
            return self.controllerJobNums
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_syncGraph(box, menuItem, key, *args):
    with sysCmd.Undo(0):
        state = channelBox_Checkbox_Update(box, key, menuItem)
        if not state and box.menu_jobs[key] > 0:
            # if user disabled the option, and ScriptJob is running, kill the ScriptJob
            cmds.scriptJob(k=box.menu_jobs[key])
            box.menu_jobs[key] = -1

        if state:
            mel.eval("GraphEditor;")  # open graph editor
            cmds.channelBox(box.channelbox, e=1, exe=(channelbox_command_animCurve(box, menuItem, key), 0))
            if box.menu_jobs[key] < 0:  # if ScriptJob is not running, start it
                box.menu_jobs[key] = cmds.scriptJob(
                    event=("ChannelBoxLabelSelected", partial(channelbox_command_syncGraph_scriptJob, box)),
                    parent=box.channelbox)
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def __init__(self):

        self.node = None
        self.pivotHandle = None
        self.scriptJob = None
        self.keypressFilter = PivotKeypressFilter(self.bakePivot, self.cleanup)
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def editPivotHandle(self):

        qt_maya_window.installEventFilter(self.keypressFilter)        

        #create transform
        self.pivotHandle = mc.group(em=True, name='Adjust_Pivot')
        mc.setAttr(self.pivotHandle+'.rotate', lock=True)
        mc.setAttr(self.pivotHandle+'.rx', keyable=False)
        mc.setAttr(self.pivotHandle+'.ry', keyable=False)
        mc.setAttr(self.pivotHandle+'.rz', keyable=False)
        mc.setAttr(self.pivotHandle+'.scale', lock=True)
        mc.setAttr(self.pivotHandle+'.sx', keyable=False)
        mc.setAttr(self.pivotHandle+'.sy', keyable=False)
        mc.setAttr(self.pivotHandle+'.sz', keyable=False)
        mc.setAttr(self.pivotHandle+'.visibility', lock=True, keyable=False)
        mc.setAttr(self.pivotHandle+'.displayHandle', True)

        self.pivotHandle = mc.parent(self.pivotHandle, self.node)[0]

        mc.addAttr(self.pivotHandle, ln='ml_pivot_handle', at='bool', keyable=False)

        #set initial position
        mc.setAttr(self.pivotHandle+'.translate', *mc.getAttr(self.node+'.rotatePivot')[0])

        #lock it so you don't delete it or something.
        mc.lockNode(self.pivotHandle, lock=True)

        self.scriptJob = mc.scriptJob(event=['SelectionChanged', self.cleanup], runOnce=True)

        mc.setToolTo('Move')

        mc.inViewMessage( amg='After moving the pivot, press <hl>Return</hl> to bake or <hl>Esc</hl> to cancel.', pos='midCenterTop', fade=True, fadeStayTime=4000, dragKill=True)
项目:mTasks    作者:theodox    | 项目源码 | 文件源码
def sj_indices():
    return set(int(i.partition(":")[0]) for i in scriptJob(lj=True))
项目:mTasks    作者:theodox    | 项目源码 | 文件源码
def start():
    if _state.get('job') in sj_indices():
        # scheduler is already running
        return
    scheduler_job = scriptJob(e=('idle', scheduler.tick))
    _state['job'] = scheduler_job
项目:mTasks    作者:theodox    | 项目源码 | 文件源码
def suspend():
    existing = _state.get('job')
    if existing in sj_indices():
        scriptJob(k=existing)
        _state['job'] = -1