Python maya.cmds.evalDeferred() Examples

The following are 11 code examples of maya.cmds.evalDeferred(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module maya.cmds , or try the search function .
Example #1
Source File: qt.py    From SISideBar with MIT License 6 votes vote down vote up
def eventFilter(self, obj, event):
        if event.type() == QEvent.FocusIn:
            self.sel_all_input()
            self.focused.emit()
        if event.type() == QEvent.Wheel:
            delta = event.delta()
            delta /= abs(delta)
            shift_mod = self.check_shift_modifiers()
            ctrl_mod = self.check_ctrl_modifiers()
            if shift_mod:
                self.setValue(self.value()+delta/10.0)
            elif ctrl_mod:
                self.setValue(self.value()+delta*10.0)
            else:
                self.setValue(self.value()+delta)
            cmds.evalDeferred(self.emit_wheel_event)
        if event.type() == QEvent.KeyPress:
            self.keypressed.emit()
        if event.type() == QEvent.MouseButtonPress:
            self.mousepressed.emit()
        return False 
Example #2
Source File: lib.py    From pyblish-maya with GNU Lesser General Public License v3.0 6 votes vote down vote up
def add_to_filemenu():
    """Add Pyblish to file-menu

    .. note:: We're going a bit hacky here, probably due to my lack
        of understanding for `evalDeferred` or `executeDeferred`,
        so if you can think of a better solution, feel free to edit.

    """

    if hasattr(cmds, 'about') and not cmds.about(batch=True):
        # As Maya builds its menus dynamically upon being accessed,
        # we force its build here prior to adding our entry using it's
        # native mel function call.
        mel.eval("evalDeferred buildFileMenu")

        # Serialise function into string
        script = inspect.getsource(_add_to_filemenu)
        script += "\n_add_to_filemenu()"

        # If cmds doesn't have any members, we're most likely in an
        # uninitialized batch-mode. It it does exists, ensure we
        # really aren't in batch mode.
        cmds.evalDeferred(script) 
Example #3
Source File: qt.py    From SIWeightEditor with MIT License 6 votes vote down vote up
def eventFilter(self, obj, event):
        if event.type() == QEvent.FocusIn:
            self.sel_all_input()
            self.focused.emit()
        if event.type() == QEvent.Wheel:
            delta = event.delta()
            delta /= abs(delta)
            shift_mod = self.check_shift_modifiers()
            ctrl_mod = self.check_ctrl_modifiers()
            if shift_mod:
                self.setValue(self.value()+delta/10.0)
            elif ctrl_mod:
                self.setValue(self.value()+delta*10.0)
            else:
                self.setValue(self.value()+delta)
            cmds.evalDeferred(self.emit_wheel_event)
        if event.type() == QEvent.KeyPress:
            self.keypressed.emit()
        if event.type() == QEvent.MouseButtonPress:
            self.mousepressed.emit()
        return False 
Example #4
Source File: dpAutoRig.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def jobReloadUI(self, *args):
        """ This scriptJob active when we got one new scene in order to reload the UI.
        """
        import maya.cmds as cmds
        cmds.select(clear=True)
        cmds.evalDeferred("import sys; sys.modules['dpAutoRigSystem.dpAutoRig'].DP_AutoRig_UI()", lowestPriority=True) 
Example #5
Source File: qt.py    From SISideBar with MIT License 5 votes vote down vote up
def sel_all_input(self):
        cmds.evalDeferred(self.select_box_all)
        
    #スピンボックスの数値を全選択する 
Example #6
Source File: userSetup.py    From SISideBar with MIT License 5 votes vote down vote up
def __register_sisidebar_startup():
    from textwrap import dedent
    cmds.evalDeferred(dedent(
        """
        import sisidebar.startup as s

        s.execute()
        """
    )) 
Example #7
Source File: lib.py    From pyblish-maya with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _add_to_filemenu():
    """Helper function for the above :func:add_to_filemenu()

    This function is serialised into a string and passed on
    to evalDeferred above.

    """

    import os
    import pyblish
    from maya import cmds

    # This must be duplicated here, due to this function
    # not being available through the above `evalDeferred`
    for item in ("pyblishOpeningDivider",
                 "pyblishScene",
                 "pyblishCloseDivider"):
        if cmds.menuItem(item, exists=True):
            cmds.deleteUI(item, menuItem=True)

    icon = os.path.dirname(pyblish.__file__)
    icon = os.path.join(icon, "icons", "logo-32x32.svg")

    cmds.menuItem("pyblishOpeningDivider",
                  divider=True,
                  insertAfter="saveAsOptions",
                  parent="mainFileMenu")

    cmds.menuItem("pyblishScene",
                  insertAfter="pyblishOpeningDivider",
                  label="Publish",
                  parent="mainFileMenu",
                  image=icon,
                  command="import pyblish_maya;pyblish_maya.show()")

    cmds.menuItem("pyblishCloseDivider",
                  insertAfter="pyblishScene",
                  parent="mainFileMenu",
                  divider=True) 
Example #8
Source File: userSetup.py    From SiShelf with MIT License 5 votes vote down vote up
def __register_sishelf_startup():
    from textwrap import dedent
    cmds.evalDeferred(dedent(
        """
        import sishelf.startup as s

        s.execute()
        """
    )) 
Example #9
Source File: ml_utilities.py    From ml_tools with MIT License 5 votes vote down vote up
def deselectChannels():
    '''
    Deselect selected channels in the channelBox
    by clearing selection and then re-selecting
    '''

    if not getSelectedChannels():
        return
    sel = mc.ls(sl=True)
    mc.select(clear=True)
    mc.evalDeferred(partial(mc.select,sel)) 
Example #10
Source File: qt.py    From SIWeightEditor with MIT License 5 votes vote down vote up
def sel_all_input(self):
        cmds.evalDeferred(self.select_box_all)
    #スピンボックスの数値を全選択する 
Example #11
Source File: userSetup.py    From SIWeightEditor with MIT License 5 votes vote down vote up
def __register_siweighteditor_startup():
    from textwrap import dedent
    cmds.evalDeferred(dedent(
        """
        import siweighteditor.startup as s

        s.execute()
        """
    ))