Python maya.cmds.about() Examples

The following are 30 code examples of maya.cmds.about(). 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: setup.py    From DeformationLearningSolver with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def loadSSDSolverPlugin():
    """"""    
    os = cmds.about(os=1)

    if os == 'win64':
        pluginName = '%s.mll' % (SSD_SOLVER_PLUGIN_BASE_NAME)
    elif os == 'mac':
        pluginName = '%s.bundle' % (SSD_SOLVER_PLUGIN_BASE_NAME)
    elif os == 'linux64':
        pluginName = '%s.so' % (SSD_SOLVER_PLUGIN_BASE_NAME)

    if not cmds.pluginInfo(pluginName, q=True, l=True ):
        try:
            cmds.loadPlugin(pluginName)
            pluginVers = cmds.pluginInfo(pluginName, q=1, v=1)
            log.info('Plug-in: %s v%s loaded success!' % (pluginName, pluginVers))
        except: 
            log.info('Plug-in: %s, was not found on MAYA_PLUG_IN_PATH.' % (pluginName))
    else:
        pluginVers = cmds.pluginInfo(pluginName, q=1, v=1)
        log.info('Plug-in: %s v%s has been loaded!' % (pluginName, pluginVers))

#---------------------------------------------------------------------- 
Example #2
Source File: setup.py    From DeformationLearningSolver with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def loadDeltaMushPlugin():
    """"""   
    os = cmds.about(os=1)

    if os == 'win64':
        pluginName = '%s.mll' % (DELTA_MUSH_PLUGIN_BASE_NAME)
    elif os == 'mac':
        pluginName = '%s.bundle' % (DELTA_MUSH_PLUGIN_BASE_NAME)
    elif os == 'linux64':
        pluginName = '%s.so' % (DELTA_MUSH_PLUGIN_BASE_NAME)

    if not cmds.pluginInfo(pluginName, q=True, l=True ):
        try:
            cmds.loadPlugin(pluginName)
            pluginVers = cmds.pluginInfo(pluginName, q=1, v=1)
            log.info('Plug-in: %s v%s loaded success!' % (pluginName, pluginVers))
        except:
            log.info('Plug-in: %s, was not found on MAYA_PLUG_IN_PATH.' % (pluginName))
    else:
        pluginVers = cmds.pluginInfo(pluginName, q=1, v=1)
        log.info('Plug-in: %s v%s has been loaded!' % (pluginName, pluginVers))

#---------------------------------------------------------------------- 
Example #3
Source File: dpAutoRig.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def info(self, title, description, text, align, width, height, *args):
        """ Create a window showing the text info with the description about any module.
        """
        # declaring variables:
        self.info_title       = title
        self.info_description = description
        self.info_text        = text
        self.info_winWidth    = width
        self.info_winHeight   = height
        self.info_align       = align
        # creating Info Window:
        if cmds.window('dpInfoWindow', query=True, exists=True):
            cmds.deleteUI('dpInfoWindow', window=True)
        dpInfoWin = cmds.window('dpInfoWindow', title='dpAutoRig - v'+DPAR_VERSION+' - '+self.langDic[self.langName]['i013_info']+' - '+self.langDic[self.langName][self.info_title], iconName='dpInfo', widthHeight=(self.info_winWidth, self.info_winHeight), menuBar=False, sizeable=True, minimizeButton=False, maximizeButton=False)
        # creating text layout:
        infoColumnLayout = cmds.columnLayout('infoColumnLayout', adjustableColumn=True, columnOffset=['both', 20], parent=dpInfoWin)
        cmds.separator(style='none', height=10, parent=infoColumnLayout)
        infoLayout = cmds.scrollLayout('infoLayout', parent=infoColumnLayout)
        if self.info_description:
            infoDesc = cmds.text(self.langDic[self.langName][self.info_description], align=self.info_align, parent=infoLayout)
        if self.info_text:
            infoText = cmds.text(self.info_text, align=self.info_align, parent=infoLayout)
        # call Info Window:
        cmds.showWindow(dpInfoWin) 
Example #4
Source File: mayaunittest.py    From cmt with MIT License 6 votes vote down vote up
def run_tests_from_commandline():
    """Runs the tests in Maya standalone mode.

    This is called when running cmt/bin/runmayatests.py from the commandline.
    """
    import maya.standalone

    maya.standalone.initialize()

    # Make sure all paths in PYTHONPATH are also in sys.path
    # When a maya module is loaded, the scripts folder is added to PYTHONPATH, but it doesn't seem
    # to be added to sys.path. So we are unable to import any of the python files that are in the
    # module/scripts folder. To workaround this, we simply add the paths to sys ourselves.
    realsyspath = [os.path.realpath(p) for p in sys.path]
    pythonpath = os.environ.get("PYTHONPATH", "")
    for p in pythonpath.split(os.pathsep):
        p = os.path.realpath(p)  # Make sure symbolic links are resolved
        if p not in realsyspath:
            sys.path.insert(0, p)

    run_tests()

    # Starting Maya 2016, we have to call uninitialize
    if float(cmds.about(v=True)) >= 2016.0:
        maya.standalone.uninitialize() 
Example #5
Source File: progress.py    From maya-skinning-tools with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, total, message=None):
        # set numeration variables
        self._value = 0
        self._total = total
        self._message = message

        # get progress bar
        self._bar = None
        self._batch = cmds.about(batch=True)

        if not self._batch:
            self._bar = mel.eval("$tmp = $gMainProgressBar")
            cmds.progressBar(
                self._bar,
                edit=True,
                isInterruptable=False,
                status=self.message,
                minValue=0,
                maxValue=total
            ) 
Example #6
Source File: dpFoot.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def integratingInfo(self, *args):
        Base.StartClass.integratingInfo(self)
        """ This method will create a dictionary with informations about integrations system between modules.
        """
        self.integratedActionsDic = {
            "module": {
                "revFootCtrlList": self.footCtrlList,
                "revFootCtrlGrpList": self.revFootCtrlGrpFinalList,
                "revFootCtrlShapeList": self.revFootCtrlShapeList,
                "toLimbIkHandleGrpList": self.toLimbIkHandleGrpList,
                "parentConstList": self.parentConstList,
                "scaleConstList": self.scaleConstList,
                "footJntList": self.footJntList,
                "ballRFList": self.ballRFList,
                "middleFootCtrlList": self.middleFootCtrlList,
                "reverseFootAttrList": self.reverseFootAttrList,
                "scalableGrp": self.aScalableGrp,
            }
        } 
Example #7
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 #8
Source File: logging_util.py    From spore with MIT License 6 votes vote down vote up
def except_hook(self, typ, value, traceback, detail):
        """ custom except hook
        when the exception is caused by a spore module forward it to the
        logger and run the bug reporter """

        err = utils._formatGuiException(typ, value, traceback, detail)
        if not cmds.about(batch=True) and 'spore' in err.splitlines()[0]:
            self.logger.critical('Uncaught exception:\n', exc_info=(typ, value, traceback))

            spore_globals = sys._global_spore_dispatcher.spore_globals
            if spore_globals['REPORT']:
                error_info = (typ, value, traceback, detail)
                if spore_globals['AUTOMATIC_REPORT']:
                    rep = reporter.get_reporter()
                    rep.direct_submit()
                else:
                    reporter.show(error_info)

            return

        return utils._formatGuiException(typ, value, traceback, detail) 
Example #9
Source File: lib.py    From SiShelf with MIT License 5 votes vote down vote up
def maya_api_version():
    return int(cmds.about(api=True)) 
Example #10
Source File: mayaapplication.py    From cross3d with MIT License 5 votes vote down vote up
def version(self):
		v = cmds.about(version=True).replace(' x64', '')
		return int(v) 
Example #11
Source File: capture.py    From maya-capture with MIT License 5 votes vote down vote up
def _in_standalone():
    return not hasattr(cmds, "about") or cmds.about(batch=True)


# --------------------------------
#
# Apply version specific settings
#
# -------------------------------- 
Example #12
Source File: cmdx.py    From cmdx with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def listRelatives(node,
                  type=None,
                  children=False,
                  allDescendents=False,
                  parent=False,
                  shapes=False):
    """List relatives of `node`

    Arguments:
        node (DagNode): Node to enquire about
        type (int, optional): Only return nodes of this type
        children (bool, optional): Return children of `node`
        parent (bool, optional): Return parent of `node`
        shapes (bool, optional): Return only children that are shapes
        allDescendents (bool, optional): Return descendents of `node`
        fullPath (bool, optional): Unused; nodes are always exact
        path (bool, optional): Unused; nodes are always exact

    Example:
        >>> parent = createNode("transform")
        >>> child = createNode("transform", parent=parent)
        >>> listRelatives(child, parent=True) == [parent]
        True

    """

    if not isinstance(node, DagNode):
        return None

    elif allDescendents:
        return list(node.descendents(type=type))

    elif shapes:
        return list(node.shapes(type=type))

    elif parent:
        return [node.parent(type=type)]

    elif children:
        return list(node.children(type=type)) 
Example #13
Source File: capture.py    From pyblish-bumpybox with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _in_standalone():
    return not hasattr(cmds, "about") or cmds.about(batch=True)


# --------------------------------
#
# Apply version specific settings
#
# -------------------------------- 
Example #14
Source File: lib.py    From SiShelf with MIT License 5 votes vote down vote up
def maya_version():
    return int(cmds.about(v=True)[:4]) 
Example #15
Source File: common.py    From cmt with MIT License 5 votes vote down vote up
def freeze_to_parent_offset(node=None):
    """Transfer the local matrix of the specified node into the offsetParentMatrix

    :param node: Node name or list of node names
    """
    if node is None:
        node = cmds.ls(sl=True)
    if node is None:
        return

    if not isinstance(node, string_types):
        for n in node:
            freeze_to_parent_offset(n)
        return

    if cmds.about(api=True) < 20200000:
        raise RuntimeError("offsetParentMatrix is only available starting in Maya 2020")

    offset = local_offset(node)
    cmds.setAttr("{}.offsetParentMatrix".format(node), list(offset), type="matrix")
    for attr in ["jo", "ra"]:
        if cmds.objExists("{}.{}".format(node, attr)):
            cmds.setAttr("{}.{}".format(node, attr), 0, 0, 0)

    for attr in ["{}{}".format(x, y) for x in "trs" for y in "xyz"]:
        is_locked = cmds.getAttr("{}.{}".format(node, attr), lock=True)
        if is_locked:
            cmds.setAttr("{}.{}".format(node, attr), lock=False)
        value = 1.0 if attr.startswith("s") else 0.0
        cmds.setAttr("{}.{}".format(node, attr), value)
        if is_locked:
            cmds.setAttr("{}.{}".format(node, attr), lock=True) 
Example #16
Source File: startup.py    From SIWeightEditor with MIT License 5 votes vote down vote up
def execute():
    menu_setup()
    #今のところコマンド登録しない
    register_siwieighteditor_runtime_command()
    # 2017以降ではworkspaceControlがあるので記録と復元は必要ない
    #if int(cmds.about(v=True)[:4]) < 2017:
        #maya.utils.executeDeferred(sisidebar_main.load_with_start_up) 
Example #17
Source File: host.py    From pyblish-qml with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _install_maya(use_threaded_wrapper):
    """Helper function to Autodesk Maya support"""
    from maya import utils, cmds

    def threaded_wrapper(func, *args, **kwargs):
        return utils.executeInMainThreadWithResult(
            func, *args, **kwargs)

    sys.stdout.write("Setting up Pyblish QML in Maya\n")

    if cmds.about(version=True) == "2018":
        _remove_googleapiclient()

    _common_setup("Maya", threaded_wrapper, use_threaded_wrapper) 
Example #18
Source File: compat.py    From core with MIT License 5 votes vote down vote up
def install():
    """Run all compatibility functions"""
    if cmds.about(version=True) == "2018":
        remove_googleapiclient() 
Example #19
Source File: maya_warpper.py    From pipeline with MIT License 5 votes vote down vote up
def maya_version():
    return cmds.about(version=True) 
Example #20
Source File: maya_warpper.py    From pipeline with MIT License 5 votes vote down vote up
def maya_api_version():
    return int(cmds.about(api=True)) 
Example #21
Source File: startup.py    From SISideBar with MIT License 5 votes vote down vote up
def execute():
    menu_setup()
    register_sishelf_runtime_command()
    # 2017以降ではworkspaceControlがあるので記録と復元は必要ない
    if int(cmds.about(v=True)[:4]) < 2017:
        maya.utils.executeDeferred(sisidebar_main.load_with_start_up) 
Example #22
Source File: dpFinger.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def integratingInfo(self, *args):
        Base.StartClass.integratingInfo(self)
        """ This method will create a dictionary with informations about integrations system between modules.
        """
        self.integratedActionsDic = {
            "module": {
                "scalableGrpList": self.scalableGrpList,
                "ikCtrlZeroList": self.ikCtrlZeroList,
            }
        } 
Example #23
Source File: dpLimb.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def integratingInfo(self, *args):
        Base.StartClass.integratingInfo(self)
        """ This method will create a dictionary with informations about integrations system between modules.
        """
        self.integratedActionsDic = {
            "module": {
                "ikCtrlList": self.ikExtremCtrlList,
                "ikCtrlZeroList": self.ikExtremCtrlZeroList,
                "ikPoleVectorZeroList": self.ikPoleVectorCtrlZeroList,
                "ikHandleGrpList": self.ikHandleToRFGrpList,
                "ikHandlePointConstList": self.ikHandlePointConstList,
                "ikFkBlendGrpToRevFootList": self.ikFkBlendGrpToRevFootList,
                "worldRefList": self.worldRefList,
                "worldRefShapeList": self.worldRefShapeList,
                "limbTypeName": self.limbTypeName,
                "extremJntList": self.extremJntList,
                "parentConstToRFOffsetList": self.parentConstToRFOffsetList,
                "fixIkSpringSolverGrpList": self.fixIkSpringSolverGrpList,
                "limbStyle": self.limbStyle,
                "quadFrontLegList": self.quadFrontLegList,
                "integrateOrigFromList": self.integrateOrigFromList,
                "ikStretchExtremLoc": self.ikStretchExtremLocList,
                "ikFkNetworkList": self.ikFkNetworkList,
                "limbManualVolume": "limbManualVolume",
                "fkIsolateConst": self.afkIsolateConst,
                "scalableGrp": self.aScalableGrps,
            }
        } 
Example #24
Source File: dpAutoRig.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def autoCheckUpdate(self, *args):
        """ Store user choose about automatically check for update in an optionVar.
            If active, try to check for update once a day.
        """
        firstTimeOpenDPAR = False
        # verify if there is an optionVar of last autoCheckUpdate checkBox choose value by user in the maya system:
        autoCheckUpdateExists = cmds.optionVar(exists='dpAutoRigAutoCheckUpdate')
        if not autoCheckUpdateExists:
            cmds.optionVar(intValue=('dpAutoRigAutoCheckUpdate', 1))
            firstTimeOpenDPAR = True
        
        # get its value puting in a variable userDefAutoCheckUpdate:
        self.userDefAutoCheckUpdate = cmds.optionVar(query='dpAutoRigAutoCheckUpdate')
        if self.userDefAutoCheckUpdate == 1:
            # verify if there is an optionVar for store the date of the lastest autoCheckUpdate ran in order to avoid many hits in the GitHub server:
            todayDate = str(datetime.datetime.now().date())
            lastAutoCheckUpdateExists = cmds.optionVar(exists='dpAutoRigLastDateAutoCheckUpdate')
            if not lastAutoCheckUpdateExists:
                cmds.optionVar(stringValue=('dpAutoRigLastDateAutoCheckUpdate', todayDate))
            # get its value puting in a variable userDefAutoCheckUpdate:
            lastDateAutoCheckUpdate = cmds.optionVar(query='dpAutoRigLastDateAutoCheckUpdate')
            if not lastDateAutoCheckUpdate == todayDate:
                # then check for update:
                self.checkForUpdate(verbose=False)
                cmds.optionVar(stringValue=('dpAutoRigLastDateAutoCheckUpdate', todayDate))
        
        # force checkForUpdate if it's the first time openning the dpAutoRigSystem in this computer:
        if firstTimeOpenDPAR:
            self.checkForUpdate(verbose=True)
        
        
    
    
    ###################### End: UI
    
    
    ###################### Start: Rigging Modules Instances 
Example #25
Source File: dpAutoRig.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def updateWin(self, rawResult, text, *args):
        """ Create a window showing the text info with the description about any module.
        """
        # declaring variables:
        self.update_checkedNumber = rawResult[0]
        self.update_remoteVersion = rawResult[1]
        self.update_remoteLog     = rawResult[2]
        self.update_text          = text
        self.update_winWidth      = 305
        self.update_winHeight     = 300
        # creating Update Window:
        if cmds.window('dpUpdateWindow', query=True, exists=True):
            cmds.deleteUI('dpUpdateWindow', window=True)
        dpUpdateWin = cmds.window('dpUpdateWindow', title='dpAutoRigSystem - '+self.langDic[self.langName]['i089_update'], iconName='dpInfo', widthHeight=(self.update_winWidth, self.update_winHeight), menuBar=False, sizeable=True, minimizeButton=False, maximizeButton=False)
        # creating text layout:
        updateLayout = cmds.columnLayout('updateLayout', adjustableColumn=True, columnOffset=['both', 20], rowSpacing=5, parent=dpUpdateWin)
        if self.update_text:
            updateDesc = cmds.text("\n"+self.langDic[self.langName][self.update_text], align="center", parent=updateLayout)
            cmds.text("\n"+DPAR_VERSION+self.langDic[self.langName]['i090_currentVersion'], align="left", parent=updateLayout)
        if self.update_remoteVersion:
            cmds.text(self.update_remoteVersion+self.langDic[self.langName]['i091_onlineVersion'], align="left", parent=updateLayout)
            cmds.separator(height=30)
            if self.update_remoteLog:
                remoteLog = self.update_remoteLog.replace("\\n", "\n")
                cmds.text(self.langDic[self.langName]['i171_updateLog']+":\n", align="center", parent=updateLayout)
                cmds.text(remoteLog, align="left", parent=updateLayout)
                cmds.separator(height=30)
            whatsChangedButton = cmds.button('whatsChangedButton', label=self.langDic[self.langName]['i117_whatsChanged'], align="center", command=partial(utils.visitWebSite, DPAR_WHATSCHANGED), parent=updateLayout)
            visiteGitHubButton = cmds.button('visiteGitHubButton', label=self.langDic[self.langName]['i093_gotoWebSite'], align="center", command=partial(utils.visitWebSite, DPAR_GITHUB), parent=updateLayout)
            if (int(cmds.about(version=True)[:4]) < 2019) and platform.system() == "Darwin": #Maya 2018 or older on macOS
                upgradeSSLmacOSButton = cmds.button('upgradeSSLmacOSButton', label=self.langDic[self.langName]['i164_sslMacOS'], align="center", backgroundColor=(0.8, 0.4, 0.4), command=partial(utils.visitWebSite, SSL_MACOS), parent=updateLayout)
            downloadButton = cmds.button('downloadButton', label=self.langDic[self.langName]['i094_downloadUpdate'], align="center", command=partial(self.downloadUpdate, DPAR_MASTERURL, "zip"), parent=updateLayout)
            installButton = cmds.button('installButton', label=self.langDic[self.langName]['i095_installUpdate'], align="center", command=partial(self.installUpdate, DPAR_MASTERURL, self.update_remoteVersion), parent=updateLayout)
        # automatically check for updates:
        cmds.separator(height=30)
        self.autoCheckUpdateCB = cmds.checkBox('autoCheckUpdateCB', label=self.langDic[self.langName]['i092_autoCheckUpdate'], align="left", value=self.userDefAutoCheckUpdate, changeCommand=self.setAutoCheckUpdatePref, parent=updateLayout)
        cmds.separator(height=30)
        # call Update Window:
        cmds.showWindow(dpUpdateWin)
        print self.langDic[self.langName][self.update_text] 
Example #26
Source File: dpAutoRig.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def checkForUpdate(self, verbose=True, *args):
        """ Check if there's an update for this current script version.
            Output the result in a window.
        """
        print "\n", self.langDic[self.langName]['i084_checkUpdate']
        
        # compare current version with GitHub master
        rawResult = utils.checkRawURLForUpdate(DPAR_VERSION, DPAR_RAWURL)
        
        # call Update Window about rawRsult:
        if rawResult[0] == 0:
            if verbose:
                self.updateWin(rawResult, 'i085_updated')
        elif rawResult[0] == 1:
            self.updateWin(rawResult, 'i086_newVersion')
        elif rawResult[0] == 2:
            if verbose:
                self.updateWin(rawResult, 'i087_rawURLFail')
        elif rawResult[0] == 3:
            if verbose:
                self.updateWin(rawResult, 'i088_internetFail')
        elif rawResult[0] == 4:
            if verbose:
                self.updateWin(rawResult, 'e008_failCheckUpdate')
    
    
    # Start working with Guide Modules: 
Example #27
Source File: pipeline.py    From core with MIT License 5 votes vote down vote up
def _on_maya_initialized(*args):
    api.emit("init", args)

    if cmds.about(batch=True):
        logger.warning("Running batch mode ...")
        return

    # Keep reference to the main Window, once a main window exists.
    get_main_window() 
Example #28
Source File: capture.py    From pyblish-bumpybox with GNU Lesser General Public License v3.0 4 votes vote down vote up
def _independent_panel(width, height, off_screen=False):
    """Create capture-window context without decorations

    Arguments:
        width (int): Width of panel
        height (int): Height of panel

    Example:
        >>> with _independent_panel(800, 600):
        ...   cmds.capture()

    """

    # center panel on screen
    screen_width, screen_height = _get_screen_size()
    topLeft = [int((screen_height-height)/2.0),
               int((screen_width-width)/2.0)]

    window = cmds.window(width=width,
                         height=height,
                         topLeftCorner=topLeft,
                         menuBarVisible=False,
                         titleBar=False,
                         visible=not off_screen)
    cmds.paneLayout()
    panel = cmds.modelPanel(menuBarVisible=False,
                            label='CapturePanel')

    # Hide icons under panel menus
    bar_layout = cmds.modelPanel(panel, q=True, barLayout=True)
    cmds.frameLayout(bar_layout, edit=True, collapse=True)

    if not off_screen:
        cmds.showWindow(window)

    # Set the modelEditor of the modelPanel as the active view so it takes
    # the playback focus. Does seem redundant with the `refresh` added in.
    editor = cmds.modelPanel(panel, query=True, modelEditor=True)
    cmds.modelEditor(editor, edit=True, activeView=True)

    # Force a draw refresh of Maya so it keeps focus on the new panel
    # This focus is required to force preview playback in the independent panel
    cmds.refresh(force=True)

    try:
        yield panel
    finally:
        # Delete the panel to fix memory leak (about 5 mb per capture)
        cmds.deleteUI(panel, panel=True)
        cmds.deleteUI(window) 
Example #29
Source File: capture.py    From maya-capture with MIT License 4 votes vote down vote up
def _independent_panel(width, height, off_screen=False):
    """Create capture-window context without decorations

    Arguments:
        width (int): Width of panel
        height (int): Height of panel

    Example:
        >>> with _independent_panel(800, 600):
        ...   cmds.capture()

    """

    # center panel on screen
    screen_width, screen_height = _get_screen_size()
    topLeft = [int((screen_height-height)/2.0),
               int((screen_width-width)/2.0)]

    window = cmds.window(width=width,
                         height=height,
                         topLeftCorner=topLeft,
                         menuBarVisible=False,
                         titleBar=False,
                         visible=not off_screen)
    cmds.paneLayout()
    panel = cmds.modelPanel(menuBarVisible=False,
                            label='CapturePanel')

    # Hide icons under panel menus
    bar_layout = cmds.modelPanel(panel, q=True, barLayout=True)
    cmds.frameLayout(bar_layout, edit=True, collapse=True)

    if not off_screen:
        cmds.showWindow(window)

    # Set the modelEditor of the modelPanel as the active view so it takes
    # the playback focus. Does seem redundant with the `refresh` added in.
    editor = cmds.modelPanel(panel, query=True, modelEditor=True)
    cmds.modelEditor(editor, edit=True, activeView=True)

    # Force a draw refresh of Maya so it keeps focus on the new panel
    # This focus is required to force preview playback in the independent panel
    cmds.refresh(force=True)

    try:
        yield panel
    finally:
        # Delete the panel to fix memory leak (about 5 mb per capture)
        cmds.deleteUI(panel, panel=True)
        cmds.deleteUI(window) 
Example #30
Source File: dpControls.py    From dpAutoRigSystem with GNU General Public License v2.0 4 votes vote down vote up
def cvBaseGuide(self, ctrlName, r=1, *args):
        """Create a control to be used as a Base Guide control.
            Returns the main control (circle) and the radius control in a list.
        """
        # get radius by checking linear unit
        r = self.dpCheckLinearUnit(r)
        # create a simple circle curve:
        circle = cmds.circle(n=ctrlName, ch=True, o=True, nr=(0, 0, 1), d=3, s=8, radius=r)[0]
        radiusCtrl = cmds.circle(n=ctrlName+"_RadiusCtrl", ch=True, o=True, nr=(0, 1, 0), d=3, s=8, radius=(r/4.0))[0]
        # rename curveShape:
        self.renameShape([circle, radiusCtrl])
        # configure system of limits and radius:
        cmds.setAttr(radiusCtrl+".translateX", r)
        cmds.parent(radiusCtrl, circle, relative=True)
        cmds.transformLimits(radiusCtrl, tx=(0.01, 1), etx=(True, False))
        self.setLockHide([radiusCtrl], ['ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'])
        # find makeNurbCircle history of the circles:
        historyList = self.findHistory([circle, radiusCtrl], 'makeNurbCircle')
        circleHistory     = historyList[0]
        radiusCtrlHistory = historyList[1]
        # rename and make a connection for circle:
        circleHistory = cmds.rename(circleHistory, circle+"_makeNurbCircle")
        cmds.connectAttr(radiusCtrl+".tx", circleHistory+".radius", force=True)
        radiusCtrlHistory = cmds.rename(radiusCtrlHistory, radiusCtrl+"_makeNurbCircle")
        # create a mutiplyDivide in order to automatisation the radius of the radiusCtrl:
        radiusCtrlMD = cmds.createNode('multiplyDivide', name=radiusCtrl+'_MD')
        cmds.connectAttr(radiusCtrl+'.translateX', radiusCtrlMD+'.input1X', force=True)
        cmds.setAttr(radiusCtrlMD+'.input2X', 0.15)
        cmds.connectAttr(radiusCtrlMD+".outputX", radiusCtrlHistory+".radius", force=True)
        # colorize curveShapes:
        self.colorShape([circle], 'yellow')
        self.colorShape([radiusCtrl], 'cyan')
        if (int(cmds.about(version=True)[:4]) > 2016):
            cmds.setAttr(circle+"Shape.lineWidth", 2)
        cmds.select(clear=True)
        return [circle, radiusCtrl]