예제 #1
0
def setupDagProcMenu():
    '''
	sets up the modifications to the dagProcMenu script
	'''
    try:
        dagMenuScriptpath = findFirstInEnv('dagMenuProc.mel',
                                           'MAYA_SCRIPT_PATH')
    except:
        MGlobal.displayWarning(
            "Cannot find the dagMenuProc.mel script - aborting auto-override!")
        return

    tmpScriptpath = Path(
        cmd.internalVar(usd=True)) / 'zoo_dagMenuProc_override.mel'

    def writeZooLines(fStream, parentVarStr, objectVarStr):
        fStream.write('\n/// ZOO TOOLBOX MODS ########################\n')
        fStream.write('\tsetParent -m $parent;\n')
        fStream.write('\tmenuItem -d 1;\n')
        fStream.write('\tpython( "from zooPyMaya import triggeredUI" );\n')
        fStream.write(
            """\tint $killState = python( "triggeredUI.buildMenuItems( '"+ %s +"', '"+ %s +"' )" );\n"""
            % (parentVarStr, objectVarStr))
        fStream.write('\tif( $killState ) return;\n')
        fStream.write('/// END ZOO TOOLBOX MODS ####################\n\n')

    globalProcDefRex = re.compile(
        "^global +proc +dagMenuProc *\( *string *(\$[a-zA-Z0-9_]+), *string *(\$[a-zA-Z0-9_]+) *\)"
    )
    with open(dagMenuScriptpath) as f:
        dagMenuScriptLineIter = iter(f)
        with open(tmpScriptpath, 'w') as f2:
            hasDagMenuProcBeenSetup = False
            for line in dagMenuScriptLineIter:
                f2.write(line)

                globalProcDefSearch = globalProcDefRex.search(line)
                if globalProcDefSearch:
                    parentVarStr, objectVarStr = globalProcDefSearch.groups()
                    selHierarchyRex = re.compile(
                        'uiRes *\( *"m_dagMenuProc.kSelectHierarchy" *\)')

                    if '{' in line:
                        writeZooLines(f2, parentVarStr, objectVarStr)
                        hasDagMenuProcBeenSetup = True

                    if not hasDagMenuProcBeenSetup:
                        for line in dagMenuScriptLineIter:
                            f2.write(line)
                            if '{' in line:
                                writeZooLines(f2, parentVarStr, objectVarStr)
                                hasDagMenuProcBeenSetup = True
                                break

        if not hasDagMenuProcBeenSetup:
            printErrorStr("Couldn't auto setup dagMenuProc!  AWOOGA!")
            return

        evalMel('source "%s";' % tmpScriptpath)
        evalMel('source "%s";' % tmpScriptpath)
예제 #2
0
def setupDagProcMenu():
    """
	sets up the modifications to the dagProcMenu script
	"""
    try:
        dagMenuScriptpath = findFirstInEnv("dagMenuProc.mel", "MAYA_SCRIPT_PATH")
    except:
        MGlobal.displayWarning("Cannot find the dagMenuProc.mel script - aborting auto-override!")
        return

    tmpScriptpath = Path(cmd.internalVar(usd=True)) / "zoo_dagMenuProc_override.mel"

    def writeZooLines(fStream, parentVarStr, objectVarStr):
        fStream.write("\n/// ZOO TOOLBOX MODS ########################\n")
        fStream.write("\tsetParent -m $parent;\n")
        fStream.write("\tmenuItem -d 1;\n")
        fStream.write('\tpython( "from zooPyMaya import triggeredUI" );\n')
        fStream.write(
            """\tint $killState = python( "triggeredUI.buildMenuItems( '"+ %s +"', '"+ %s +"' )" );\n"""
            % (parentVarStr, objectVarStr)
        )
        fStream.write("\tif( $killState ) return;\n")
        fStream.write("/// END ZOO TOOLBOX MODS ####################\n\n")

    globalProcDefRex = re.compile(
        "^global +proc +dagMenuProc *\( *string *(\$[a-zA-Z0-9_]+), *string *(\$[a-zA-Z0-9_]+) *\)"
    )
    with open(dagMenuScriptpath) as f:
        dagMenuScriptLineIter = iter(f)
        with open(tmpScriptpath, "w") as f2:
            hasDagMenuProcBeenSetup = False
            for line in dagMenuScriptLineIter:
                f2.write(line)

                globalProcDefSearch = globalProcDefRex.search(line)
                if globalProcDefSearch:
                    parentVarStr, objectVarStr = globalProcDefSearch.groups()
                    selHierarchyRex = re.compile('uiRes *\( *"m_dagMenuProc.kSelectHierarchy" *\)')

                    if "{" in line:
                        writeZooLines(f2, parentVarStr, objectVarStr)
                        hasDagMenuProcBeenSetup = True

                    if not hasDagMenuProcBeenSetup:
                        for line in dagMenuScriptLineIter:
                            f2.write(line)
                            if "{" in line:
                                writeZooLines(f2, parentVarStr, objectVarStr)
                                hasDagMenuProcBeenSetup = True
                                break

        if not hasDagMenuProcBeenSetup:
            printErrorStr("Couldn't auto setup dagMenuProc!  AWOOGA!")
            return

        evalMel('source "%s";' % tmpScriptpath)
        evalMel('source "%s";' % tmpScriptpath)
예제 #3
0
def setupDagProcMenu():
    '''
	sets up the modifications to the dagProcMenu script
	'''
    dagMenuScript = r'C:\Program Files\Autodesk\Maya2011\scripts\others\dagMenuProc.mel'
    globalProcDefRex = re.compile(
        "^global +proc +dagMenuProc *\( *string *(\$[a-zA-Z0-9_]+), *string *(\$[a-zA-Z0-9_]+) *\)"
    )

    dagMenuScriptLines = Path(dagMenuScript).read()
    dagMenuScriptLineIter = iter(dagMenuScriptLines)

    newLines = []
    hasDagMenuProcBeenSetup = False
    for line in dagMenuScriptLineIter:
        newLines.append(line)

        globalProcDefSearch = globalProcDefRex.search(line)
        if globalProcDefSearch:
            parentVarStr, objectVarStr = globalProcDefSearch.groups()
            selHierarchyRex = re.compile(
                'uiRes *\( *"m_dagMenuProc.kSelectHierarchy" *\)')
            #menuItem -label (uiRes("m_dagMenuProc.kDagMenuSelectHierarchy"))  -c ("select -hierarchy " + $object);

            #if we're past the global proc definition for dagMenuProc start looking for the menu item to
            for line in dagMenuScriptLineIter:
                newLines.append(line)
                if 'menuItem' in line and selHierarchyRex.search(line):
                    newLines.append('\t\t\tmenuItem -d 1;')
                    newLines.append('\t\t\tpython( "import triggeredUI" );')
                    newLines.append(
                        """\t\t\tint $killState = python( "triggeredUI.buildMenuItems( '"+ %s +"', '"+ %s +"' )" );"""
                        % (parentVarStr, objectVarStr))
                    newLines.append('\t\t\tif( $killState ) return;')
                    hasDagMenuProcBeenSetup = True
                    break

    if not hasDagMenuProcBeenSetup:
        printErrorStr("Couldn't auto setup dagMenuProc!  AWOOGA!")
        return

    newScript = '\n'.join(newLines)
    evalMel(newScript)
예제 #4
0
def setupDagProcMenu():
	'''
	sets up the modifications to the dagProcMenu script
	'''
	dagMenuScript = r'C:\Program Files\Autodesk\Maya2011\scripts\others\dagMenuProc.mel'
	globalProcDefRex = re.compile( "^global +proc +dagMenuProc *\( *string *(\$[a-zA-Z0-9_]+), *string *(\$[a-zA-Z0-9_]+) *\)" )

	dagMenuScriptLines = Path( dagMenuScript ).read()
	dagMenuScriptLineIter = iter( dagMenuScriptLines )

	newLines = []
	hasDagMenuProcBeenSetup = False
	for line in dagMenuScriptLineIter:
		newLines.append( line )

		globalProcDefSearch = globalProcDefRex.search( line )
		if globalProcDefSearch:
			parentVarStr, objectVarStr = globalProcDefSearch.groups()
			selHierarchyRex = re.compile( 'uiRes *\( *"m_dagMenuProc.kSelectHierarchy" *\)' )
			#menuItem -label (uiRes("m_dagMenuProc.kDagMenuSelectHierarchy"))  -c ("select -hierarchy " + $object);

			#if we're past the global proc definition for dagMenuProc start looking for the menu item to
			for line in dagMenuScriptLineIter:
				newLines.append( line )
				if 'menuItem' in line and selHierarchyRex.search( line ):
					newLines.append( '\t\t\tmenuItem -d 1;' )
					newLines.append( '\t\t\tpython( "import triggeredUI" );' )
					newLines.append( """\t\t\tint $killState = python( "triggeredUI.buildMenuItems( '"+ %s +"', '"+ %s +"' )" );""" % (parentVarStr, objectVarStr) )
					newLines.append( '\t\t\tif( $killState ) return;' )
					hasDagMenuProcBeenSetup = True
					break

	if not hasDagMenuProcBeenSetup:
		printErrorStr( "Couldn't auto setup dagMenuProc!  AWOOGA!" )
		return

	newScript = '\n'.join( newLines )
	evalMel( newScript )
예제 #5
0
 def __call__(self, *a):
     evalMel(self.cmdStr)
예제 #6
0
 def __call__( self, *a ):
     evalMel( self.cmdStr )
예제 #7
0
def loadLocalCGMPythonSetup( *a ):
    evalMel('python("from cgm.core import cgm_Meta as cgmMeta;from cgm.core import cgm_General as cgmGeneral;from cgm.core.rigger import RigFactory as Rig;from cgm.core import cgm_PuppetMeta as cgmPM;import Red9.core.Red9_Meta as r9Meta;import cgm.core;cgm.core._reload();import maya.cmds as mc;")')
예제 #8
0
def loadLocalCGMPythonSetup( *a ):
    evalMel('python("from cgm.core import cgm_Meta as cgmMeta;from cgm.core import cgm_Deformers as cgmDeformers;from cgm.core import cgm_General as cgmGeneral;from cgm.core.rigger import RigFactory as Rig;from cgm.core import cgm_PuppetMeta as cgmPM;from cgm.core import cgm_RigMeta as cgmRigMeta;import Red9.core.Red9_Meta as r9Meta;import cgm.core;cgm.core._reload();import maya.cmds as mc;import cgm.core.cgmPy.validateArgs as cgmValid")')