Пример #1
0
def apiVersion():
    """Returns maya's currently active maya api version ie. 201610

    :return: Maya api version
    :rtype: str
    """
    return MGlobal.apiVersion()
Пример #2
0
def parseVersionStr(versionStr, extension=False):
    # type: (str, bool) -> str
    """
    Parse a verbose version string (like the one displayed in the Maya title
    bar) and return the base version.

    Parameters
    ----------
    versionStr : str
    extension : bool
        if True, leave the -x64 tag

    Returns
    -------
    str

    Examples
    --------
    >>> from pymel.all import *
    >>> versions.parseVersionStr('2008 Service Pack1 x64')
    '2008'
    >>> versions.parseVersionStr('2008 Service Pack1 x64', extension=True)
    '2008-x64'
    >>> versions.parseVersionStr('2008x64', extension=True)
    '2008-x64'
    >>> versions.parseVersionStr('8.5', extension=True)
    '8.5'
    >>> versions.parseVersionStr('2008 Extension 2')
    '2008'
    >>> versions.parseVersionStr('/Applications/Autodesk/maya2009/Maya.app/Contents', extension=True)
    '2009'
    >>> versions.parseVersionStr('C:\Program Files (x86)\Autodesk\Maya2008', extension=True)
    '2008'

    """
    if 'Preview' in versionStr:
        # Beta versions of Maya may use the format 'Preview Release nn x64', which
        # doesn't contain the actual Maya version. If we have one of those, we'll
        # make up the version from the API version. Not foolproof, but should work
        # in most cases.
        version = str(_MGlobal.apiVersion())[0:4]
        if extension and bitness() == 64:
            version += '-x64'
    else:
        # problem with service packs addition, must be able to match things such as :
        # '2008 Service Pack 1 x64', '2008x64', '2008', '8.5'

        # NOTE: we're using the same regular expression (parseVersionStr) to parse both the crazy human readable
        # maya versions as returned by about, and the maya location directory.  to handle both of these i'm afraid
        # the regular expression might be getting unwieldy

        ma = re.search(
            "((?:maya)?(?P<base>[\d.]{3,})(?:(?:[ ].*[ ])|(?:-))?(?P<ext>x[\d.]+)?)",
            versionStr)
        version = ma.group('base')

        if extension and (ma.group('ext') is not None):
            version += "-" + ma.group('ext')
    return version
Пример #3
0
    def __init__(self, ui_state, parent, main_window):
        super(ModifierList, self).__init__()

        self.ui_state = ui_state
        self.main_window = main_window

        from qtpy import modifier_list
        self.ui = modifier_list.Ui_Form()
        self.ui.setupUi(parent)

        if MGlobal.apiVersion() >= 201700:
            # XXX 2017 crashes when we do this.
            pass
            #self.ui.treeView.header().setSectionResizeMode(0, Qt.QHeaderView.Stretch)
            #self.ui.treeView.header().setSectionResizeMode(1, Qt.QHeaderView.ResizeToContents)
            #self.ui.treeView.header().setSectionResizeMode(2, Qt.QHeaderView.Interactive)
        else:
            self.ui.treeView.header().setResizeMode(0, Qt.QHeaderView.Stretch)
            self.ui.treeView.header().setResizeMode(
                1, Qt.QHeaderView.ResizeToContents)
            self.ui.treeView.header().setResizeMode(2,
                                                    Qt.QHeaderView.Interactive)

        self.model = Qt.QStandardItemModel()
        self.model.setColumnCount(3)
        self.model.setHeaderData(0, Qt.Qt.Horizontal, 'Item',
                                 Qt.Qt.DisplayRole)
        self.model.setHeaderData(1, Qt.Qt.Horizontal, 'D', Qt.Qt.DisplayRole)
        self.model.setHeaderData(2, Qt.Qt.Horizontal, 'Group',
                                 Qt.Qt.DisplayRole)

        self.model_filter = Filter()
        self.model_filter.setSourceModel(self.model)
        self.ui.treeView.setModel(self.model_filter)
        self.ui.treeView.setSortingEnabled(True)

        self.model_filter.setFilterCaseSensitivity(Qt.Qt.CaseInsensitive)

        self.ui.searchBox.textChanged.connect(
            self.model_filter.setFilterFixedString)
        self.ui.searchBox.textChanged.connect(
            lambda text: self.ui.clearButton.setEnabled(len(text)))
        self.ui.clearButton.setEnabled(False)
        self.ui.clearButton.clicked.connect(lambda: self.ui.searchBox.clear())

        self.ui.treeView.setSelectionMode(
            Qt.QAbstractItemView.ExtendedSelection)
        self.ui.treeView.setContextMenuPolicy(Qt.Qt.CustomContextMenu)
        self.ui.treeView.customContextMenuRequested.connect(
            lambda position: self.open_menu(self.ui.treeView, position))
Пример #4
0
def parseVersionStr(versionStr, extension=False):
    """
    Parse a verbose version string (like the one displayed in the Maya title
    bar) and return the base version.

    :Parameters:
        extension : `bool`
            if True, leave the -x64 tag

    >>> from pymel.all import *
    >>> versions.parseVersionStr('2008 Service Pack1 x64')
    '2008'
    >>> versions.parseVersionStr('2008 Service Pack1 x64', extension=True)
    '2008-x64'
    >>> versions.parseVersionStr('2008x64', extension=True)
    '2008-x64'
    >>> versions.parseVersionStr('8.5', extension=True)
    '8.5'
    >>> versions.parseVersionStr('2008 Extension 2')
    '2008'
    >>> versions.parseVersionStr('/Applications/Autodesk/maya2009/Maya.app/Contents', extension=True)
    '2009'
    >>> versions.parseVersionStr('C:\Program Files (x86)\Autodesk\Maya2008', extension=True)
    '2008'

    """
    if 'Preview' in versionStr:
        # Beta versions of Maya may use the format 'Preview Release nn x64', which
        # doesn't contain the actual Maya version. If we have one of those, we'll
        # make up the version from the API version. Not foolproof, but should work
        # in most cases.
        version = str(_MGlobal.apiVersion())[0:4]
        if extension and bitness() == 64:
            version += '-x64'
    else:
        # problem with service packs addition, must be able to match things such as :
        # '2008 Service Pack 1 x64', '2008x64', '2008', '8.5'

        # NOTE: we're using the same regular expression (parseVersionStr) to parse both the crazy human readable
        # maya versions as returned by about, and the maya location directory.  to handle both of these i'm afraid
        # the regular expression might be getting unwieldy

        ma = re.search("((?:maya)?(?P<base>[\d.]{3,})(?:(?:[ ].*[ ])|(?:-))?(?P<ext>x[\d.]+)?)", versionStr)
        version = ma.group('base')

        if extension and (ma.group('ext') is not None):
            version += "-" + ma.group('ext')
    return version
Пример #5
0
    def _changed(self, items):
        # This is received when a source item changes.  If an item changes, all of its parent items
        # may change, so signal them too.
        parents = {}
        for item in items:
            checked = item.data(Qt.Qt.CheckStateRole)

            parent = item.parent()
            while parent is not None:
                if not (parent.flags() & Qt.Qt.ItemIsTristate):
                    break

                parents[id(parent)] = parent
                parent = parent.parent()

        for parent in parents.itervalues():
            # XXX: What's the third parameter that QT5 added?
            if MGlobal.apiVersion() >= 201700:
                self.dataChanged.emit(parent, parent, [])
            else:
                self.dataChanged.emit(parent, parent)
Пример #6
0
        if extension and (ma.group('ext') is not None):
            version += "-" + ma.group('ext')
    return version

def bitness():
    """
    The bitness of python running inside Maya as an int.
    """
    # NOTE: platform.architecture()[0] returns '64bit' on OSX 10.6 (Snow Leopard)
    # even when Maya is running in 32-bit mode. The struct technique
    # is more reliable.
    return struct.calcsize("P") * 8

_is64 = bitness() == 64
_current = _MGlobal.apiVersion()
_fullName = _MGlobal.mayaVersion()
_shortName = parseVersionStr(_fullName, extension=False)
_installName = _shortName + ('-x64' if (_is64 and _current < 201600) else '')


v85 = 200700
v85_SP1 = 200701
v2008 = 200800
v2008_SP1 = 200806
v2008_EXT2 = 200806
v2009 = 200900
v2009_EXT1 = 200904
v2009_SP1A = 200906
v2010 = 201000
v2011 = 201100
Пример #7
0
 def __init__(self, obj):
     args = [self, obj, zRigHandleDrawOverride.draw]
     if MGlobal.apiVersion() >= 201700:
         # This argument is only present in 2017, and improves performance substantially.
         args.append(False)
     omr.MPxDrawOverride.__init__(*args)
Пример #8
0
        version += "-" + ma.group('ext')
    return version


def bitness():
    """
    The bitness of python running inside Maya as an int.
    """
    # NOTE: platform.architecture()[0] returns '64bit' on OSX 10.6 (Snow Leopard)
    # even when Maya is running in 32-bit mode. The struct technique
    # is more reliable.
    return struct.calcsize("P") * 8


_is64 = bitness() == 64
_current = _MGlobal.apiVersion()
_fullName = _MGlobal.mayaVersion()
_shortName = parseVersionStr(_fullName, extension=False)
_installName = _shortName + ('-x64' if _is64 else '')

v85 = 200700
v85_SP1 = 200701
v2008 = 200800
v2008_SP1 = 200806
v2008_EXT2 = 200806
v2009 = 200900
v2009_EXT1 = 200904
v2009_SP1A = 200906
v2010 = 201000
v2011 = 201100
v2011_HOTFIX1 = 201101
Пример #9
0
import time
start =time.time()
from maya.utils import executeDeferred
from maya.cmds import pluginInfo,loadPlugin,warning,evalDeferred,unloadPlugin
import fantabox as fb
from fantabox.FantaBoxMenu import *
import  maya.mel as mel
from subprocess import Popen, PIPE

def documentsLocation():    
    handle = Popen('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"  /v personal', shell=True, stdout=PIPE)
    hostid = handle.communicate()[0]
    handle.kill
    return hostid.split( 'REG_SZ')[1].strip()
from maya.OpenMaya import MGlobal  as _MGlobal
mayaver = str(_MGlobal.apiVersion())[0:4]

def pluginload():
    if pluginInfo("mtoa",q=1,loaded=1,name=1)==0:
        try:
            loadPlugin("mtoa")
        except:
            warning("no arnold!!")
    try:  
        print "a"      
        #evalDeferred('''cmds.unloadPlugin("pgYetiMaya",f=1)''' )
        #evalDeferred('''cmds.loadPlugin("pgYetiMaya")''' )
    except:
        warning("no pgYetiMaya!!")
def mtoasetting():
    hostname = documentsLocation()
Пример #10
0
	def __init__(self, obj):
                args = [self, obj, zRigHandleDrawOverride.draw]
                if MGlobal.apiVersion() >= 201700:
                    # This argument is only present in 2017, and improves performance substantially.
                    args.append(False)
		omr.MPxDrawOverride.__init__(*args)
Пример #11
0
from metan.datatype.quaternion import Quaternion
from metan.datatype.vector import Vector


class TESTMObjectHandle(object):
    u"""これは仮のMObjectHandleです
    """
    def __init__(self, *args, **kws):
        pass

    def isValid(self):
        return True


# todo: バージョンで分けるような処理はここじゃなくてファイルを別にする
current_version = _api1_MGlobal.apiVersion()
_MFn_MFnSkinCluster = om.MFnDependencyNode
_MFn_MFnAnimCurve = om.MFnDependencyNode
_MFn_MObjectHandle = TESTMObjectHandle

if current_version >= 201600:
    _MFn_MFnSkinCluster = oma.MFnSkinCluster
    _MFn_MFnAnimCurve = oma.MFnAnimCurve
    _MFn_MObjectHandle = om.MObjectHandle


def to_string(args):
    _args = []
    for arg in args:
        if hasattr(arg, "metan_class"):
            _args.append(str(arg))
Пример #12
0
# QT5 moved a bunch of stuff around, moving some things from QtGui into QtWidgets.
# This means that in order to make their API slightly "prettier", QT created a ton
# of useless busywork for thousands of developers, and makes compatibility with Qt4
# and Qt5 painful.  I couldn't care less about which module these are in, so work
# around this by flattening everything into one module.
from maya.OpenMaya import MGlobal
if MGlobal.apiVersion() >= 201700:
    from PySide2.QtCore import *
    from PySide2.QtGui import *
    from PySide2.QtWidgets import *
    from shiboken2 import wrapInstance
    import pyside2uic as pysideuic
else:
    from PySide.QtCore import *
    from PySide.QtGui import *
    from shiboken import wrapInstance
    import pysideuic as pysideuic