示例#1
0
 def enableBordersHighlight(self, *args):
     '''
     
     '''       
     if cmds.objExists(self._IScontextTool._mVoroObject):
         
         bEnabled = cmds.checkBox(self._ISborderEdgesCbx, query = True, value = True)
         if bEnabled:
             
             if int(cmds.about(version = True).split()[0]) < 2016:
                 mDisplay = cmds.listRelatives(self._IScontextTool._mVoroDisplay[0], fullPath = True)[1] 
                 cmds.setAttr(mDisplay + '.overrideEnabled', False)
             
             aShapes = cmds.listRelatives(self._IScontextTool._mVoroObject, children = True, shapes = True, type = 'mesh', f = True)
             if aShapes:                                           
                 self._IScontextTool._mDisplayType = cmds.attributeQuery('displayEdges', node = aShapes[0], max = True)[0] # Depending on Maya Version Max Number can be 2 or 3                
             else:
                 self._IScontextTool._mDisplayType = 2
         
         else:                
             if int(cmds.about(version = True).split()[0]) < 2016:
                 mDisplay = cmds.listRelatives(self._IScontextTool._mVoroDisplay[0], fullPath = True)[1]
                 cmds.setAttr(mDisplay + '.overrideEnabled', True)
                 
             self._IScontextTool._mDisplayType = 1
         
         try:
             if cmds.objExists(self._IScontextTool._mVoroDisplay[0]):
                 mVoroDisplayShape = cmds.listRelatives(self._IScontextTool._mVoroDisplay[0], fullPath = True)[1]
                 cmds.setAttr(mVoroDisplayShape + '.displayEdges', self._IScontextTool._mDisplayType)                
         except:
             pass                 
def enableaPlugin(filename):
    extDict = {'win64':'mll','mac':'bundle','linux':'so','linux64':'so'}
    os = cmds.about(os=True)
    ext = extDict[os]
    version = cmds.about(v=True)[:4]
    pluginName = 'deltaMushToSkinCluster_%s' % version
    fileFullName = '%s.%s' % (pluginName,ext)
    rootPath = getParentPath(currentFileDirectory())
    pluginsPath = rootPath+'/plug-ins/'
    pluginFilePath = pluginsPath+fileFullName
    pluginStr = mel.eval('getenv "MAYA_PLUG_IN_PATH";')+';'+pluginsPath
    mel.eval('putenv "MAYA_PLUG_IN_PATH" "%s";' % pluginStr)
    with open(filename,'a+') as f:
        state = True
        for line in f.readlines():
            if re.findall(fileFullName,line):
                state = False
        if state:
            f.write(r'evalDeferred("autoLoadPlugin(\"\", \"%s\", \"%s\")");' % (fileFullName,pluginName))

    if not cmds.pluginInfo( pluginFilePath, query=True, autoload=True):
        cmds.pluginInfo( pluginFilePath, edit=True, autoload=True)

    if not cmds.pluginInfo(pluginFilePath,query=True,loaded=True):
        cmds.loadPlugin(pluginFilePath)
示例#3
0
def printTopExceptionForDebug(error_stack_frames):
    '''
    Prints top-down unhandled exception info generated by MRT. To be used for debugging.
    '''
    # Collect maya/os info.
    debugInfoTxt = '\n\n{0} MRT ERROR/EXCEPTION OCCURRED {0}'.format('*'*40)
    debugInfoTxt += '\n%s(Please use the text below for sending error messages)\n' % ('\t'*7)
    debugInfoTxt += '\nMRT VERSION:     %s' % _mrt_version
    debugInfoTxt += '\nMAYA VERSION:    %sx%s' % (cmds.about(version=True), 64 if cmds.about(is64=True) else 32)
    debugInfoTxt += '\nOS:              %s' % cmds.about(os=True)
    debugInfoTxt += '\nPY VERSION:      %s' % platform.python_version()
    debugInfoTxt += '\n\nEXCEPTION DATA (SOURCE TOP DOWN):-\n'
    
    # Collect info for each error stack trace, from top down.
    for e_frame in error_stack_frames[-1::-1]:
        
        e_frame_info = traceback.extract_stack(e_frame, 1)[0]

        debugInfoTxt += '\nSOURCE: %s\nLINE: %s\nFRAME: "%s"\nAT: "%s"\nLOCALS:' % (e_frame_info[0], e_frame_info[1], e_frame_info[2], e_frame_info[3])
        
        local_items = e_frame.f_locals.items()
        
        if local_items:
            for key, value in local_items:
                debugInfoTxt += '\n%30s = %s' % (key, value)
        else:
            debugInfoTxt += 'None'
            
        debugInfoTxt += '\n'
        
    return debugInfoTxt
	def fileDialog2_openDirInExplorer(self, *args):

		ctrlName = long(self.MQtUtil.findControl('QFileDialog'))
		qObj = self.wrapInstance(ctrlName, self.QtGui.QFileDialog)
		dirPath = qObj.directory().path()

		if cmds.about(macOS= 1):
		    subprocess.Popen(['open', '--', dirPath])
		if cmds.about(linux= 1):
		    subprocess.Popen(['xdg-open', '--', dirPath])
		if cmds.about(windows= 1):
		    os.startfile(dirPath)
示例#5
0
文件: utils.py 项目: NicoMaya/pymel
def loadStringResourcesForModule( moduleName ):
    """
    Load the string resources associated with the given module

    Note that the argument must be a string containing the full name of the
    module (eg "maya.app.utils").  The module of that name must have been
    previously imported.

    The base resource file is assumed to be in the same location as the file
    defining the module and will have the same name as the module except with
    _res.py appended to it.  So, for the module foo, the resource file should
    be foo_res.py.

    If Maya is running in localized mode, then the standard location for
    localized scripts will also be searched (the location given by the
    command cmds.about( localizedResourceLocation=True ))

    Failure to find the base resources for the given module will trigger an
    exception. Failure to find localized resources is not an error.
    """
    try:
        module = sys.modules[moduleName]
    except:
        raise RuntimeError( 'Failed to load base string resources for module %s because it has not been imported' % moduleName )

    modulePath, moduleFileName = os.path.split( module.__file__ )
    moduleName, extension = os.path.splitext( moduleFileName )

    resourceFileName = moduleName + '_res.py'

    # Try to find the base version of the file next to the module
    try:
        baseVersionPath = os.path.join( modulePath, resourceFileName )
        execfile( baseVersionPath, {} )
    except:
        raise RuntimeError( 'Failed to load base string resources for module %s' % moduleName )

    if cmds.about( uiLanguageIsLocalized=True ):
        scriptPath = cmds.about( localizedResourceLocation=True )
        if scriptPath != '':
            localizedPath = os.path.join( scriptPath, 'scripts', resourceFileName )
            try:
                execfile( localizedPath, {} )
            # We don't generate any warnings or errors if localized
            # file is not there
            # TODO: we could consider issuing a warning in debug mode
            except IOError:
                pass
            except Exception, err:
                raise RuntimeError( 'Unexpected error encountered when attempting to load localized string resources for module %s: %s' % (moduleName,err) )
示例#6
0
def env_from_sql(table_location,initial_vars):    
    print "\n============================================================\n"    
    print   "                GLOBAL VARIABLE SETTING INITIALIZED           \n\nRunning SQL ENV Var Settings from '%s'\n"%(table_location)
    
    # Retrieve Version String
    version = mc.about(v=1)
    # Retrieve Mode 
    batch = mc.about(b=1)

    print "\n Maya Version Detected as %s"%(version)
    if batch ==1:
        mode = 'BATCH'
        print " Maya Running in Batch Mode"
    else:
        mode = 'GUI'
        print " Maya is Running in GUI Mode"

    # Pass Vars to SQL and retrieve Vals    
    print "\n  Retrieving variables for Version = '",version,"'","\n                           Mode    = '",mode,"'"

    # Get Strings from SQL Table for version of Maya
    returned_new_envs = sql_handle(version,mode,table_location)
    print "\n        ....Variables Retrieved"

    # Conglomerate Strings from existing Envs
    vars_to_set = conglomerate_vars(returned_new_envs)
    print "        ....Variables Conglomerated Setting "
    
    # Print Vars
    print_vars(vars_to_set)

    # Set Vars
    set_env_vars(vars_to_set)

    print "\n         Completed ENV Setting"
    
    print "\n=============================================================="
    
    print   "                LOADING APPROPRIATE PLUG-INS           \n\nRunning SQL Plugin Var Settings from '%s'\n"%(table_location)
    
    # Pass Vars to SQL and retrieve Vals    
    print "\n Retrieving Loadable Plug-ins for Version = '",version,"'","\n                                   Mode    = '",mode,"'"

    plugins_loadable = sql_plugin_handle(version,mode,table_location)
    print "\n        ...Retrieved Loadable Plug-ins "
    
    load_plugins_status = load_plugins(plugins_loadable)   
    
    print "\n=============================================================="
示例#7
0
def returnMayaInfo():
    mayaInfoDict = {}
    mayaInfoDict['year'] =  mc.about(file=True)
    mayaInfoDict['qtVersion'] =  mc.about(qtVersion=True)
    mayaInfoDict['version'] =  mc.about(version=True)
    mayaInfoDict['apiVersion'] =  mc.about(apiVersion=True)
    mayaInfoDict['product'] =  mc.about(product=True)
    mayaInfoDict['qtVersion'] =  mc.about(qtVersion=True)
    mayaInfoDict['environmentFile'] =  mc.about(environmentFile=True)
    mayaInfoDict['operatingSystem'] =  mc.about(operatingSystem=True)
    mayaInfoDict['operatingSystemVersion'] =  mc.about(operatingSystemVersion=True)
    mayaInfoDict['currentTime'] =  mc.about(currentTime=True)
    mayaInfoDict['currentUnit'] =  mc.currentUnit(q=True,linear=True)

    return mayaInfoDict
示例#8
0
        def renderLogCallback(line):
            if "Writing image" in line:
                imageName = line.split("\"")[-2]

                # Display the render
                if not cmds.about(batch=True):
                    MitsubaRendererUI.showRender(imageName)
示例#9
0
def initPlugin(invert=False):
	pluginFolder = cmds.about(preferences=True) + "/modules/<pluginName>"

	if not invert:
		if not pluginFolder in sys.path: sys.path.append(pluginFolder)
	else:
		if pluginFolder in sys.path: sys.path.remove(pluginFolder)
示例#10
0
    def __init__(self):
        self.dGlobals = {}
        self.dMasterRenderGlobals = {}
        self.lstLayers = []
        self.sCurrentLayer = ""
        self.oCurrentLayer = None
        self.sMasterLayer = "masterLayer"
        self.bIsFirstRun = False
        self.lstSelection = []

        # Get the Maya version as a integer
        self.iMayaVersion = int(re.search("\d+", mc.about(v=True)).group())

        self.reloadEngines()

        self.out = libOutput.Output(self)
        self.utils = libUtils.Utils()
        self.node = libNode.Node()

        self.reIsLight = re.compile("Light$")

        self.reload()

        # Post actions that have to take place after the initialization of above classes
        self.selectLayer(self.node.selected())
示例#11
0
文件: utils.py 项目: leandropim/Tapp
    def getMayaVersion():
        '''
        returns maya version (use Utils.MAYA* constants for comparision of a returned result)
        currently uses "about -v" string parsing
        '''
        
        if Utils.CURRENT_MAYA_VERSION is None:
            version = cmds.about(v=True)
            
            Utils.CURRENT_MAYA_VERSION = Utils.MAYA_UNKNOWN_VERSION
            
            
            def testVersion(search,result):
                if search in version:
                    Utils.CURRENT_MAYA_VERSION = result
                    return True
                return False

                        
            testVersion('2011', Utils.MAYA2011) or \
            testVersion('2012', Utils.MAYA2012) or \
            testVersion('2013', Utils.MAYA2013) or \
            testVersion('2014', Utils.MAYA2014) or \
            testVersion('2015', Utils.MAYA2015) or \
            testVersion('2016', Utils.MAYA2016)
            
        return Utils.CURRENT_MAYA_VERSION
示例#12
0
def clearCallbacks():
    if cmds.about(batch=True):
        return
    try:
        cmds.callbacks(clearAllCallbacks=True, owner="arnold")
    except:
        pass
示例#13
0
 def __init__(self, title, *args, **kwargs ):
     
     QWidget.__init__( self, *args )
     
     self.infoPath = cmds.about(pd=True) + "/sg/fingerWeightCopy/Widget_loadJoints_%s.txt" % title
     sgCmds.makeFile( self.infoPath )
     
     layout = QVBoxLayout( self ); layout.setContentsMargins(0,0,0,0)
     
     groupBox = QGroupBox( title )
     layout.addWidget( groupBox )
     
     baseLayout = QVBoxLayout()
     groupBox.setLayout( baseLayout )
     
     listWidget = QListWidget()
     
     hl_buttons = QHBoxLayout(); hl_buttons.setSpacing( 5 )
     b_addSelected = QPushButton( "Add Selected" )
     b_clear = QPushButton( "Clear" )
     
     hl_buttons.addWidget( b_addSelected )
     hl_buttons.addWidget( b_clear )
     
     baseLayout.addWidget( listWidget )
     baseLayout.addLayout( hl_buttons )
     
     self.listWidget = listWidget
     
     QtCore.QObject.connect( listWidget, QtCore.SIGNAL( "itemClicked(QListWidgetItem*)" ), self.selectJointFromItem )
     QtCore.QObject.connect( b_addSelected, QtCore.SIGNAL("clicked()"), self.addSelected )
     QtCore.QObject.connect( b_clear, QtCore.SIGNAL( "clicked()" ), self.clearSelected )
     
     self.otherWidget = None        
     self.loadInfo()
示例#14
0
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 use_threaded_wrapper:
        register_dispatch_wrapper(threaded_wrapper)

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

    app = QtWidgets.QApplication.instance()

    if not _is_headless():
        # mayapy would have a QtGui.QGuiApplication
        app.aboutToQuit.connect(_on_application_quit)

        # acquire Maya's main window
        _state["hostMainWindow"] = {
            widget.objectName(): widget
            for widget in QtWidgets.QApplication.topLevelWidgets()
        }["MayaWindow"]

    _set_host_label("Maya")
示例#15
0
def arnoldBatchRenderOptionsString():
    origFileName = cmds.file(q=True, sn=True)

    if not cmds.about(batch=True):
        silentMode = 0
        try:
            silentMode = int(os.environ["MTOA_SILENT_MODE"])
        except:
            pass
        if silentMode != 1:
            dialogMessage = "Are you sure you want to start a potentially long task?"
            if platform.system().lower() == "linux":
                dialogMessage += " (batch render on linux cannot be stopped)"
            ret = cmds.confirmDialog(
                title="Confirm",
                message=dialogMessage,
                button=["Yes", "No"],
                defaultButton="Yes",
                cancelButton="No",
                dismissString="No",
            )
            if ret != "Yes":
                raise Exception("Stopping batch render.")
    try:
        port = core.MTOA_GLOBALS["COMMAND_PORT"]
        return ' -r arnold -ai:ofn \\"' + origFileName + '\\" -ai:port %i ' % port
    except:
        return ' -r arnold -ai:ofn \\"' + origFileName + '\\" '
示例#16
0
 def __init__(self, *args, **kwargs ):
     
     QWidget.__init__( self, *args )
     
     title = ""
     if kwargs.has_key( 'title' ):
         title = kwargs['title']
         
     self.infoPath = cmds.about(pd=True) + "/sg/fingerWeightCopy/Widget_LoadVertex_%s.txt" % title
     sgCmds.makeFile( self.infoPath )
     
     vLayout = QVBoxLayout( self ); vLayout.setContentsMargins(0,0,0,0)
     
     groupBox = QGroupBox( title )
     groupBox.setAlignment( QtCore.Qt.AlignCenter )
     vLayout.addWidget( groupBox )
     
     hLayout = QHBoxLayout()
     lineEdit = QLineEdit()
     button   = QPushButton("Load"); button.setFixedWidth( 50 )
     hLayout.addWidget( lineEdit )
     hLayout.addWidget( button )
     
     groupBox.setLayout( hLayout )
     
     self.lineEdit = lineEdit
     
     QtCore.QObject.connect( button, QtCore.SIGNAL( "clicked()" ), self.loadVertex )
     self.loadInfo()
示例#17
0
def SGMPlugMod01Command_markingMenu_defaultMenu( parentName ):

    modeFilePath = uiInfoPath = cmds.about(pd=True) + "/sg/sg_toolInfo/SGMPlugMod01.txt"
    SGMPlugMod01_file.makeFile( modeFilePath )
    
    f = open( modeFilePath, 'r' )
    data = f.read()
    f.close()
    
    if not data:
        mel.eval( "SGMPlugMod01Command -sym 0" )
        f = open( modeFilePath, 'w' )
        f.write( 'False' )
        f.close()
        SGMPlugMod01_markingMenuCmd.mirrorValue = 0
    else:
        if data == 'True':
            mel.eval( "SGMPlugMod01Command -sym 1" )
            SGMPlugMod01_markingMenuCmd.mirrorValue = 1
        else:
            mel.eval( "SGMPlugMod01Command -sym 0" )
            SGMPlugMod01_markingMenuCmd.mirrorValue = 0

    cmds.menuItem( "Symmetry X", cb=SGMPlugMod01_markingMenuCmd.mirrorValue, rp="N", c=SGMPlugMod01_markingMenuCmd.symmetryXOn, p=parentName  )
    cmds.menuItem( l="Average", p=parentName, sm=1, rp='NW' )
    cmds.menuItem( l="Average Normal", rp="NW", c = SGMPlugMod01_markingMenuCmd.averageNormal )
    cmds.menuItem( l="Average Vertex", rp="W",  c = SGMPlugMod01_markingMenuCmd.averageVertex )
    cmds.menuItem( l="Delete History", p = parentName, c = SGMPlugMod01_markingMenuCmd.deleteHistory )
示例#18
0
    def isAnimation(self):
        animation = cmds.getAttr("defaultRenderGlobals.animation")
        if not cmds.about(batch=True) and animation:
            print( "Animation isn't currently supported outside of Batch mode. Rendering current frame." )
            animation = False

        mayaReleasePythonGIL = os.environ.get('MAYA_RELEASE_PYTHON_GIL')
        mayaVersion = float(cmds.about(version=True))
        if mayaVersion >= 2016 and not mayaReleasePythonGIL:
            print( "\n\n\n\n")
            print( "For versions of Maya 2016 and greater, you must set the environment variable MAYA_RELEASE_PYTHON_GIL"
                " to 1 to render animations. Rendering current frame only." )
            print( "\n\n\n\n")
            animation = False

        return animation
示例#19
0
 def getRefFiles(self,file,*args):
     """
     Scan .ma file for reference file names.
     Prompt the user to browse to them if their path is invalid.
     """
     version = cmds.about(v=True)
     rootFile = open(file,'r')
     
     refLines = []
     refFiles = []
     
     for line in rootFile:
         if line.strip().startswith('file -rdi'):
             refLines.append(line)
     
     count = 0
     refPath = ""
     for each in refLines:        
         temp1 = refLines[count].split()
         #No spaces in path name
         if len(temp1) == 7:
             refPath = temp1[7][1:-2]
         #Spaces in path name
         if len(temp1) > 7:
             refPath = self.buildRefPath(temp1)
         refFiles.append(refPath)
         count = count + 1
         
     for each in refFiles:
         print each
         self.editRef(each)
示例#20
0
	def createPreviewMayaFile(self):
		"""docstring for createPreviewMayaFile"""
		createPrevScript = os.path.dirname(os.path.abspath(__file__)) + '/createPreview.py'
		cmd = 'C:/"Program Files"/Autodesk/Maya' + mc.about(v = True)  + '/bin/' + 'mayapy.exe ' + createPrevScript + ' ' + self.path + self.name + '.ma'
		print cmd
		#create preview scene
		os.popen( cmd )
示例#21
0
def zipManyFiles(files):
	fileName = maya.cmds.file(q=True, sceneName=True)
	# If the scene has not been saved
	if (fileName==""):
		pyError( maya.stringTable['y_zipScene.kSceneNotSavedError']   )
		return

	# If the scene has been created, saved and then erased from the disk 
	elif (maya.cmds.file(q=True, exists=True)==0):
		msg = maya.stringTable['y_zipScene.kNonexistentFileError']  % fileName
		pyError(msg) 
		return

	# get the default character encoding of the system
	theLocale = cmds.about(codeset=True)

	# get a list of all the files associated with the scene
	# files = maya.cmds.file(query=1, list=1, withoutCopyNumber=1)
	
	# create a zip file named the same as the scene by appending .zip 
	# to the name
	zipFileName = (files[0])+'.zip'
	zip=zipfile.ZipFile(zipFileName, 'w', zipfile.ZIP_DEFLATED)

	# add each file associated with the scene, including the scene
	# to the .zip file
	for file in files:
		name = file.encode(theLocale)
		zip.write(name)		
	zip.close()

	# output a message whose result is the name of the zip file newly created
	pyResult(zipFileName)
示例#22
0
def convert(*args):
	'''
	Convert chosen files into xpm.
	'''	
	# Grab the path from the ScrollField
	targetPath = cmds.scrollField( "mecCVTDir", q=True, text=True)
	
	# Grabbing the selected elements from the textScrollList
	tslSel = cmds.textScrollList("mecCVTTSL", q=True, si=True)
	
	# - Checking to see if anything is selcted in the textScrollList
	#   if nothing is selected grab everything.
	if( not(tslSel) ):
		print("Nothing selected in textScrollList Selected.\n Converting everything.")
		tslSel = cmds.textScrollList("mecCVTTSL", q=True, ai=True)

	
	for tsl in tslSel:
		# Creating the proper path to the files.
		# split file up to get the file name with out the extension.
		baseFile = tsl.split(".")[0]
		destFile = '"' + targetPath + "/""" + baseFile + '.xpm"'
		
		sourceFile = '"' + targetPath + "/" + tsl + '"'
		
		# Switching from front slashes to backslashes if on a windows machine.
		if(cmds.about(os=True) == "nt"):
			destFile = convertSlashes( destFile )
			sourceFile = convertSlashes( sourceFile )
			
		# Compiling the command line to convert the images.
		runLine = 'imconvert ' + sourceFile + " " + destFile
		print(runLine)
		# Executing the imconvert program from the command prompt (DOS)
		os.popen2(runLine)
示例#23
0
def appendPluginPath():

    putenvStr = mel.eval( 'getenv "MAYA_PLUG_IN_PATH"' )
    
    if os.name == 'posix':
        sepChar = ':'
    else:
        sepChar = ';'
    
    pythonPathName = sepChar + os.path.dirname( __file__.replace( '\\', '/' ) ) + '/pluginRoot'
    
    version = cmds.about(version=True)[:4]
    cppPathName = sepChar + os.path.dirname( __file__.replace( '\\', '/' ) ) + '/pluginRoot/' + version
    
    putenvStr = putenvStr.replace( pythonPathName, '' )
    putenvStr += pythonPathName
    putenvStr = putenvStr.replace( cppPathName, '' )
    putenvStr += cppPathName
    
    mel.eval( 'putenv "MAYA_PLUG_IN_PATH" "%s"' % putenvStr )
    putenvStr = mel.eval( 'getenv "MAYA_PLUG_IN_PATH"' )
    
    print "MAYA_PLUG_IN_PATH : "
    for path in putenvStr.split( sepChar ):
        print "    ", path
示例#24
0
def loadPlugin():
    """
    load softSelectionQuery plugin
    """
    
    mayaVers = int(mayaVersion())
    os = cmds.about(os=1)
    
    if os == 'win64':
        pluginName = 'softSelectionQuery_%s-x64.mll' % mayaVers
    elif os == 'mac':
        pluginName = 'softSelectionQuery_%s.bundle' % mayaVers
    elif os == 'linux64':
        pluginName = 'softSelectionQuery_%s.so' % mayaVers
    else:
        cmds.error('Soft Cluster EX is available for 64bit version of Autodesk Maya 2011 '
                  'or above under Windows 64bit, Mac OS X and Linux 64bit!')
    
    if not cmds.pluginInfo(pluginName, q=True, l=True ):
        cmds.loadPlugin(pluginName)
        version = cmds.pluginInfo(pluginName, q=1, v=1)
        log.info('Plug-in: %s v%s loaded success!' % (pluginName, version))
    else:
        version = cmds.pluginInfo(pluginName, q=1, v=1)
        log.info('Plug-in: %s v%s has been loaded!' % (pluginName, version))
示例#25
0
文件: dialog.py 项目: adamcobabe/mrv
	def prompt( self ):
		"""Aquire the information using a prompt dialog
		
		:return: prompted value if input was confirmed using confirmToken, or the cancelValue
			if cancelToken was pressed
		:note: tokens correspond to buttons
		:note: handles batch mode correctly"""
		if cmds.about( batch = 1 ):
			return super( Prompt, self ).prompt( )

		default_text = ( self.confirmDefault is not None and self.confirmDefault ) or ""

		tokens = [ self.confirmToken ]
		token_kwargs = { "db" : self.confirmToken }
		if self.cancelToken is not None:
			tokens.append( self.cancelToken )
			token_kwargs[ "cb" ] = self.cancelToken
		# END token preparation
		token_kwargs.update( self._kwargs )

		ret = cmds.promptDialog( t="Prompt", m = self.msg, b = tokens, text = default_text, **token_kwargs )

		if ret == self.cancelToken:
			return self.cancelDefault

		if ret == self.confirmToken:
			return cmds.promptDialog( q=1, text = 1 )

		return self.confirmDefault
示例#26
0
def run(*args, **kwargs):
    """ prepare the scene for the tests
    converts scene to use centimeters
    set the grid to the default
    
    """
    valid_kwargs = ['verbose']
    for k, v in kwargs.iteritems():
        if k not in valid_kwargs:
            raise TypeError("Invalid keyword argument %s" % k)
    # verbose defaults to False if verbose option not set in menu or set 
    # as cmdline argument
     
    try:
        verbose = kwargs['verbose']
    except KeyError:
        verbose = False 
    	if cmds.optionVar(exists='checkmateVerbosity'):
    		verbose = cmds.optionVar(query='checkmateVerbosity')
    else:
        verbose = False       
    batch = cmds.about(batch=True)    
    # get the name of the script Editor's output control
    from maya import mel as mel
    # Turn off Echo All Commands in the Script Editor  
    # Disable Stack Tracevin the Script Editor  
    # Turn off Line Numbers in errors in the Script Editor  
    # Reset the grid
    # Set the background color
    # Turn off the heads-up displays
    # Switch to wrireframe mode
    # Close all windows (except main)
    # Close ChannelBox, Attribute Editor and Outliner ()
    
    if not batch:
        try:
            gCommandReporter = mel.eval("proc string f(string $g){return $g;}f($gCommandReporter);")
        except RuntimeError:
            gCommandReporter = ''
            pass
        try:
            cmds.cmdScrollFieldReporter(gCommandReporter, 
                edit=True, 
                echoAllCommands=False,
                lineNumbers=True,
                stackTrace=True,
                suppressResults=False,
                suppressInfo=False,
                suppressWarnings=False,
                suppressErrors=False,
                suppressStackTrace=False,
                )
        except RuntimeError:
            if verbose:
                print 'No Script Editor'
            pass
    
    # convert scene to cm to fix crashes in nearestnormal
    cmds.currentUnit(linear='cm')
示例#27
0
def _getTimelineWinSize():
    '''Dimensione finestra timeline a seconda se sono su qt o no.'''

    mayaVersion = cmds.about(version=True).split()[0]
    if _isQt:
        return (cmds.layout('MainTimeSliderLayout|formLayout9|frameLayout2', q=True, w=True)-17, 38)
    else:
        return ((cmds.control('MayaWindow|mayaMainWindowForm', q=True, w=True)-311), 70)
示例#28
0
 def __init__(self):
     """
     Base init function for maya convert.write Class.
     """
     self.supported_tan_types = ["spline", "linear", "clamped", "step", "fixed"]
     rodin_logger.info("kip maya writing class initialized")
     self.maya_version = "maya,%s" % cmds.about(v=True)
     self.kip_maya_version = "kipMaya%s" % os.getenv("DRD_KIPMAYA_VERSION")
示例#29
0
def get_maya_version():
    version = 2015
    try:
        import maya.cmds as mc
        version = int(mc.about(v=1))
    except:
        pass
    return version
示例#30
-1
 def __init__(self, *args, **kwargs ):
     
     QWidget.__init__( self, *args )
     
     self.infoPath = cmds.about(pd=True) + "/sg/fingerWeightCopy/Widget_SelectionGrow.txt"
     sgCmds.makeFile( self.infoPath )
     
     validator = QIntValidator()
     
     layout = QHBoxLayout( self ); layout.setContentsMargins(0,0,0,0)
     groupBox = QGroupBox()
     layout.addWidget( groupBox )
     
     hLayout = QHBoxLayout()
     labelTitle = QLabel( "Grow Selection : " )
     buttonGrow = QPushButton( "Grow" ); buttonGrow.setFixedWidth( 50 )
     buttonShrink = QPushButton( "Shrink" ); buttonShrink.setFixedWidth( 50 )        
     lineEdit = QLineEdit(); lineEdit.setValidator( validator );lineEdit.setText( '0' )
     
     hLayout.addWidget( labelTitle )
     hLayout.addWidget( buttonGrow )
     hLayout.addWidget( buttonShrink )
     hLayout.addWidget( lineEdit )
     
     groupBox.setLayout( hLayout )
     
     self.lineEdit = lineEdit
     
     QtCore.QObject.connect( buttonGrow, QtCore.SIGNAL("clicked()"), self.growNum )
     QtCore.QObject.connect( buttonShrink, QtCore.SIGNAL("clicked()"), self.shrinkNum )
     
     self.vtxLineEditList = []
     self.loadInfo()