Exemplo n.º 1
0
def performance_test_foot_geom(count=100):
    """


    """

    # unload
    cmds.file(new=True, force=True)
    cmds.flushUndo()
    cmds.unloadPlugin("footPrintNode_GeometryOverride")

#     # copy new build
#     src = r"D:\Repos\brenmy\sandbox\cpp\testLocatorGeom\testLocatorGeom\Release\testLocatorGeom.mll"
#     dst = r"D:\Repos\brenmy\sandbox\testBuilds\testLocatorGeom.mll"
#
#     status = subprocess.call(
#         ["copy", src, dst],
#         shell=True
#     )
#
#     print status

    # test
    cmds.loadPlugin(r"footPrintNode_GeometryOverride")

    loc = create_driver_locator()

    for i in range(count):
        test = cmds.createNode(
            "footPrint_GeometryOverride", name="test{}".format(i))
        test_prnt = cmds.listRelatives(test, parent=True)[0]

        cmds.setAttr(test_prnt + ".translateX", i)
        cmds.connectAttr(loc + ".translateY", test + ".size")
def run():
    mc.file(newFile=True, force=True)
    mc.unloadPlugin(SETTINGS['plugin_name'])
    mc.loadPlugin(SETTINGS['plugin_path'])
    mc.file(SETTINGS['file'], open=True, force=True)
    mc.file(rename='asdf')
    mc.file(renameToSave=True)

    mc.createNode('prRemapValue')
    mc.setAttr("prRemapValue1.value[1].value_Position", 1)
    mc.setAttr("prRemapValue1.value[1].value_FloatValue", 1)
    mc.setAttr("prRemapValue1.color[1].color_Position", 1)
    mc.setAttr("prRemapValue1.color[1].color_Color", 0, 1, 0)
    mc.connectAttr('inputMin_locator.ty', 'prRemapValue1.inputMin')
    mc.connectAttr('inputMax_locator.ty', 'prRemapValue1.inputMax')
    mc.connectAttr('outputMin_locator.ty', 'prRemapValue1.outputMin')
    mc.connectAttr('outputMax_locator.ty', 'prRemapValue1.outputMax')

    for x in range(6):
        mc.setAttr('prRemapValue1.inputValue[{}]'.format(x), 1.0 / 5 * x)
        mc.connectAttr('prRemapValue1.outValue[{}]'.format(x),
                       'pCube{}.ty'.format(x + 1))
        mc.connectAttr('prRemapValue1.outColor[{}]'.format(x),
                       'blinn{}.color'.format(x + 1))

    outColor = pm.PyNode('prRemapValue1.outColor')
    outColorValues = []
    for x in range(outColor.numChildren()):
        outColorValues.append(outColor[x].get())
    for panel in mc.getPanel(type='modelPanel'):
        mc.modelEditor(panel, e=True, displayTextures=True)

    print(mc.getAttr('prRemapValue1.outValue'))
    print(outColorValues)
Exemplo n.º 3
0
    def elevatorNode_Create(self):
        cmds.flushUndo()
        cmds.file(force=True, new=True)

        cmds.unloadPlugin('elevatorNode', force=True)

        # Force is important because of the undo stack
        cmds.loadPlugin(elevatorNode.__file__)

        #list shape
        transformNode01 = cmds.polyCube(w=8.465834, h=0.584901, d=8.465834)[0]
        transformNode02 = cmds.polyCube(w=8.465834, h=0.584901, d=8.465834)[0]
        stick = cmds.polyCube(w=8.465834, h=0.584901, d=0.507098)[0]
        cmds.xform(transformNode01, rp=(-3.891191, 0, 0), sp=(-3.891191, 0, 0))
        cmds.xform(transformNode02, rp=(-3.891191, 0, 0), sp=(-3.891191, 0, 0))
        cmds.xform(stick, rp=(-3.891191, 0, 0), sp=(-3.891191, 0, 0))
        cmds.xform(transformNode02, ws=True, t=(0.0, 15, 0.0))
        pluginNode = cmds.createNode('elevatorLocator')

        #decomposeMatrixNode=cmds.createNode('decomposeMatrix', name='decomposeMatrix')
        cmds.connectAttr('%s.worldMatrix' % transformNode01,
                         '%s.Matrix01' % pluginNode)
        cmds.connectAttr('%s.worldMatrix' % transformNode02,
                         '%s.Matrix02' % pluginNode)
        cmds.connectAttr('%s.message' % stick, '%s.Object' % pluginNode)
Exemplo n.º 4
0
 def unloadPlugin(self):
     "unload plugin"
     fileName = self.plugin.split("/")[-1]
     if cmds.pluginInfo(fileName, q=True, l=True):
         cmds.file(f=True, new=True)
         cmds.unloadPlugin(fileName)
         logger.info(fileName + " is unloaded")
Exemplo n.º 5
0
def nuke():
    ilrNodeTypes = [
        u"ilrAshikhminShader",
        u"ilrBakeLayer",
        u"ilrBakeLayerManager",
        u"ilrBasicPhotonShader",
        u"ilrBssrdfShader",
        u"ilrDielectricPhotonShader",
        u"ilrDielectricShader",
        u"ilrHwBakeVisualizer",
        u"ilrLuaNode",
        u"ilrNormalMap",
        u"ilrOccData",
        u"ilrOccSampler",
        u"ilrOptionsNode",
        u"ilrOrenNayarShader",
        u"ilrOutputShaderBackendNode",
        u"ilrPhysicPhotonShader",
        u"ilrPointCloudShape",
        u"ilrPolyColorPerVertex",
        u"ilrRaySampler",
        u"ilrShadowMask",
        u"ilrSurfaceThickness",
        u"ilrUIOptionsNode",
        u"ilrUVMappingVisualizer",
    ]
    nodes = mc.ls(type=ilrNodeTypes)
    if nodes:
        mc.lockNode(nodes, l=False)
        mc.delete(nodes)
        mc.flushUndo()
        mc.unloadPlugin("Turtle.mll")
    else:
        mc.warning("No Turtle nodes found.")
Exemplo n.º 6
0
def performance_test_py_1(count=100):
    """

    x100 ~23fps (full value bar setup)

    """

    # unload
    cmds.file(new=True, force=True)
    cmds.flushUndo()
    cmds.unloadPlugin("valueBarLocatorPy")

    # test
    cmds.loadPlugin(r"valueBarLocatorPy")

    loc = create_driver_locator()

    for i in range(count):
        test = cmds.createNode(
            "valueBarLocator", name="valueBarTest{}".format(i)
        )

        test_prnt = cmds.listRelatives(test, parent=True)[0]

        cmds.setAttr(test_prnt + ".translateX", i)
        cmds.connectAttr(loc + ".translateY", test + ".inputValue")
Exemplo n.º 7
0
 def unloadPlugins(cls):
     """Unload all the currently loaded plugins
     """
     for plugin in cls.loadedPlugins:
         cmds.unloadPlugin(plugin)
         logger.debug("unLoaded Plugin %s" % plugin)
     cls.loadedPlugins.clear()
Exemplo n.º 8
0
def remove_unknown_nodes():
    removed_count = 0

    unknown_nodes = cmds.ls(type="unknown")
    for node in unknown_nodes:
        if cmds.objExists(node):
            sys.stdout.write("Remove unknown node '{}'.\n".format(node))
            cmds.lockNode(node, lock=False)
            cmds.delete(node)
            removed_count += 1

    if cmds.pluginInfo("Turtle.mll", q=True, loaded=True):
        cmds.pluginInfo("Turtle.mll", e=True, autoload=False)
        cmds.unloadPlugin("Turtle.mll", force=True)
    turtle_nodes = ["TurtleDefaultBakeLayer",
                    "TurtleBakeLayerManager",
                    "TurtleRenderOptions",
                    "TurtleUIOptions"]
    for node in turtle_nodes:
        if cmds.objExists(node):
            sys.stdout.write("Remove Turtle node '{}'.\n".format(node))
            cmds.lockNode(node, lock=False)
            cmds.delete(node)
            removed_count += 1

    sys.stdout.write(str(removed_count) + " unknown nodes removed.\n")
Exemplo n.º 9
0
 def reloadAndReopen( self, *args ):
     
     codePath = cmds.textField( self.fld_codePath, q=1, tx=1 )
     plugPath = cmds.textField( self.fld_plugPath, q=1, tx=1 )
     srcName  = cmds.textField( self.fld_srcName,  q=1, tx=1 )
     dstName  = cmds.textField( self.fld_dstName,  q=1, tx=1 )
     
     srcPath = ( codePath + '/' + srcName ).replace( '\\', '/' )
     dstPath = ( plugPath + '/' + dstName ).replace( '\\', '/' )
     
     currentSceneName = cmds.file( q=1, sceneName=1 )
     cmds.file( new=1, f=1 )
     cmds.unloadPlugin( dstName )
     
     shutil.copy2( srcPath, dstPath )
     
     print "Copy From : ", srcPath
     print "Past To   : ", dstPath
     
     if not currentSceneName: currentSceneName = tempPluginTestPath
     try:cmds.file( currentSceneName, f=1, options="v=0;", o=1 )
     except:cmds.file( rename = currentSceneName )
     
     cmds.loadPlugin( dstName )
     
     self.textFieldSaveCommand()
Exemplo n.º 10
0
 def unload_normal(self):
     if self.__pluginName:
         mc.unloadPlugin(self.__pluginName, f=True)
         try:
             self.setAutoLoad()
         except:
             pass
Exemplo n.º 11
0
def reinitializeMaya(*args, **kwargs):
    """reload plugin and mel script"""
    initializeMaya(*args, **kwargs)
    mc.unloadPlugin('prMovePointsCmd')
    mm.eval('rehash;')
    mm.eval('source prDeformPaintBrush;')
    initializeMaya(*args, **kwargs)
Exemplo n.º 12
0
    def reloadPlug( *args ):
        
        codePath = cmds.textField( UI_Global.txf_codePath, q=1, tx=1 )
        plugPath = cmds.textField( UI_Global.txf_pluginPath, q=1, tx=1 )
        srcName  = cmds.textField( UI_Global.txf_sourceName, q=1, tx=1 )
        dstName  = cmds.textField( UI_Global.txf_destName, q=1, tx=1 )
        
        reloadPlug_cmd.setPath( codePath, plugPath, srcName, dstName )
        
        currentScene = cmds.file( q=1, sn=1 )
        cmds.file( f=1, new=1 )
        cmds.unloadPlugin( dstName )
        
        codePath += '\\'+srcName
        plugPath += '\\'+dstName

        print codePath
        print plugPath
        
        shutil.copy2( codePath, plugPath )
        
        cmds.loadPlugin( '%s' % plugPath )
        
        extension = currentScene.split( '.' )[-1]
        
        if extension == 'mb':
            cmds.file( currentScene, f=1, options = "v=0;",  typ = "mayaBinary", o=1 )
            mel.eval( 'addRecentFile("%s", "mayaBinary");' % currentScene )
        elif extension == "ma":
            cmds.file( currentScene, f=1, options = "v=0;",  typ = "mayaAscii", o=1 )
            mel.eval( 'addRecentFile("%s", "mayaBinary");' % currentScene )
Exemplo n.º 13
0
    def reloadPlug(*args):

        codePath = cmds.textField(UI_Global.txf_codePath, q=1, tx=1)
        plugPath = cmds.textField(UI_Global.txf_pluginPath, q=1, tx=1)
        srcName = cmds.textField(UI_Global.txf_sourceName, q=1, tx=1)
        dstName = cmds.textField(UI_Global.txf_destName, q=1, tx=1)

        reloadPlug_cmd.setPath(codePath, plugPath, srcName, dstName)

        currentScene = cmds.file(q=1, sn=1)
        cmds.file(f=1, new=1)
        cmds.unloadPlugin(dstName)

        codePath += '\\' + srcName
        plugPath += '\\' + dstName

        print codePath
        print plugPath

        shutil.copy2(codePath, plugPath)

        cmds.loadPlugin('%s' % plugPath)

        extension = currentScene.split('.')[-1]

        if extension == 'mb':
            cmds.file(currentScene, f=1, options="v=0;", typ="mayaBinary", o=1)
            mel.eval('addRecentFile("%s", "mayaBinary");' % currentScene)
        elif extension == "ma":
            cmds.file(currentScene, f=1, options="v=0;", typ="mayaAscii", o=1)
            mel.eval('addRecentFile("%s", "mayaBinary");' % currentScene)
Exemplo n.º 14
0
    def reloadAndReopen(self, *args):

        codePath = cmds.textField(self.fld_codePath, q=1, tx=1)
        plugPath = cmds.textField(self.fld_plugPath, q=1, tx=1)
        srcName = cmds.textField(self.fld_srcName, q=1, tx=1)
        dstName = cmds.textField(self.fld_dstName, q=1, tx=1)

        srcPath = (codePath + '/' + srcName).replace('\\', '/')
        dstPath = (plugPath + '/' + dstName).replace('\\', '/')

        currentSceneName = cmds.file(q=1, sceneName=1)
        cmds.file(new=1, f=1)
        cmds.unloadPlugin(dstName)

        shutil.copy2(srcPath, dstPath)

        print "Copy From : ", srcPath
        print "Past To   : ", dstPath

        if not currentSceneName: currentSceneName = tempPluginTestPath
        try:
            cmds.file(currentSceneName, f=1, options="v=0;", o=1)
        except:
            cmds.file(rename=currentSceneName)

        cmds.loadPlugin(dstName)

        self.textFieldSaveCommand()
Exemplo n.º 15
0
def unload(plugin):
    '''Unload plugin'''

    if not loaded(plugin):
        return

    cmds.unloadPlugin(plugin, force=False)
Exemplo n.º 16
0
def unload(plugin):
    '''Unload plugin'''

    if not loaded(plugin):
        return

    cmds.unloadPlugin(plugin, force=False)
Exemplo n.º 17
0
def run():
    mc.file(newFile=True, force=True)
    mc.unloadPlugin(SETTINGS['plugin_name'])
    mc.loadPlugin(SETTINGS['plugin_path'])
    mc.file(SETTINGS['file'], open=True, force=True)
    createTempFile()
    loc = 'locator'
    driverValue = mc.getAttr(loc + '.ty')
    for value, operation in enumerate([
            'noOperation', 'sum', 'subtract', 'average', 'multiply', 'divide',
            'power', 'root', 'floorDivision', 'modulo'
    ]):
        prNode = mc.createNode('prScalarMath',
                               name=operation + '_prScalarMath')
        mc.setAttr(prNode + '.operation', value)
        mc.setAttr(prNode + '.input[1].input1', driverValue)
        mc.setAttr(prNode + '.input[1].input2', driverValue)
        mc.setAttr(prNode + '.input[2].input2', driverValue)

        prCube = operation + '_pr'
        if mc.objExists(prCube):
            mc.connectAttr(loc + '.ty', prNode + '.input[2].input1')
            mc.connectAttr(prNode + '.output[2]', prCube + '.ty')
        else:
            print('missing: {}'.format(prCube))

        prCubeStatic = prCube + '_static'
        if mc.objExists(prCubeStatic):
            mc.connectAttr(prNode + '.output[1]', prCubeStatic + '.ty')
        else:
            print('missing: {}'.format(prCubeStatic))
    mc.select(loc)
def reload(source, destination):
    '''
    reloads plugin: 
    * close file
    * unload plugin
    * copy new compiled version 
    * load plugin
    * load file
    
    '''

    currFile = cmds.file(sceneName=True, q=True)

    # close file for a while
    if currFile:
        cmds.file(f=True, new=True)

    try:

        cmds.unloadPlugin(os.path.basename(destination), force=True)
        print("plugin unloaded: %s" % destination)

        shutil.copy(source, destination)
        print("plugin copied: %s" % source)
        cmds.loadPlugin(destination)
        print "plugin loaded: " + destination
    finally:
        if currFile:
            cmds.file(currFile, open=True)
Exemplo n.º 19
0
def setup():
    joints = []
    vals = [0, 4, 2]
    for i in range(3):

        jnt = cmds.joint()
        cmds.xform(jnt, t=[vals[i], 0, 0])
        joints.append(jnt)

    loc1 = cmds.spaceLocator(n="target")[0]
    loc2 = cmds.spaceLocator(n="pole")[0]

    cmds.xform(loc1, t=[6, 0, 0])
    cmds.xform(loc2, t=[6, 1, 0])

    cmds.flushUndo()
    cmds.unloadPlugin('simpleik')
    cmds.loadPlugin('simpleik.so')

    tbik = cmds.createNode('sik_twoBoneIK', n='tbik1')

    cmds.setAttr(tbik + ".staticEdgeA", vals[1])
    cmds.setAttr(tbik + ".staticEdgeB", vals[2])
    cmds.connectAttr(loc1 + ".t", tbik + ".targetLocation")
    cmds.connectAttr(loc2 + ".t", tbik + ".poleVector")
    cmds.connectAttr(tbik + ".orientation", joints[0] + ".r")
    cmds.connectAttr(tbik + ".bendAngle", joints[1] + ".rz")
    cmds.connectAttr(tbik + ".stretchedEdgeA", joints[1] + ".tx")
    cmds.connectAttr(tbik + ".stretchedEdgeB", joints[2] + ".tx")
Exemplo n.º 20
0
def reload(source,destination):
    '''
    reloads plugin: 
    * close file
    * unload plugin
    * copy new compiled version 
    * load plugin
    * load file
    
    '''
    
    currFile = cmds.file( sceneName=True,q=True)
    
    # close file for a while
    if currFile:
        cmds.file( f=True, new=True )
     
    try:
            
        cmds.unloadPlugin(os.path.basename(destination),force=True)
        print ("plugin unloaded: %s" % destination)
        
        
                
            
        shutil.copy(source,destination)
        print ("plugin copied: %s" % source)
        cmds.loadPlugin(destination)
        print "plugin loaded: "+destination
    finally:
        if currFile:
            cmds.file(currFile, open=True)
Exemplo n.º 21
0
 def unloadPlugin(self):
     "unload plugin"
     fileName = self.plugin.split("/")[-1]    
     if cmds.pluginInfo(fileName, q=True, l=True):
         cmds.file(f=True, new=True)
         cmds.unloadPlugin(fileName)
         logger.info(fileName + " is unloaded")
Exemplo n.º 22
0
def load(plugin_path):
    if os.name == 'nt':
        env_path = ';%s' % plugin_path
    else:
        env_path = ':%s' % plugin_path

    maya_plugin_path = mel.eval('getenv "MAYA_PLUG_IN_PATH"')

    if plugin_path not in maya_plugin_path:
        mel.eval('putenv "MAYA_PLUG_IN_PATH" "' + maya_plugin_path + env_path +
                 '"')

    if cmds.pluginInfo(plugin_name, q=True, r=True):
        try:
            cmds.unloadPlugin(plugin_name, force=True)
        except Exception as e:
            logging.exception(e)

    sys.path.append(plugin_path)

    try:
        import tweener
        reload(tweener)
        tweener.reload_mods()
    except Exception as e:
        logging.exception(e)

    try:
        cmds.loadPlugin(plugin_name)
        if cmds.pluginInfo(plugin_name, q=True, r=True):
            cmds.pluginInfo(plugin_name, e=True, autoload=True)
    except Exception as e:
        logging.exception(e)

    try:
        cmds.tweener()
    except Exception as e:
        cmds.warning('Could not execute tweener command: %s' % str(e))

    answer = cmds.confirmDialog(
        t='Tweener Installed!',
        m='Tweener was installed at:\n'
        '%s\n\n'
        'Would you like to add a shelf button to the current shelf?' %
        plugin_path,
        button=['Yes', 'No'],
        db='Yes',
        cb='No',
        ds='No')

    if answer == 'Yes':
        try:
            tweener.ui.add_shelf_button(path=plugin_path)
        except Exception as e:
            logging.exception(e)

    sys.stdout.write(
        '# Tweener install completed! See the Script Editor for more information.\n'
    )
Exemplo n.º 23
0
 def saveWeights(self, *args):
     import maya.mel as mel
     cmds.unloadPlugin('tbLoadSaveWeights.py')
     cmds.loadPlugin('tbLoadSaveWeights.py')
     mel.eval('tbLoadSaveWeights -a "export" -f "%s" -m "%s" -p %r' %
              (self.directoryLineEdit.text(),
               self.skinClusterTransformLineEdit.text(),
               self.saveCheckBox.isChecked()))
Exemplo n.º 24
0
def run(
    plugin_path='C:/Users/paz/Documents/git/prmaya/prmaya/plugins/prPyMath.py'
):
    mc.file(newFile=True, force=True)
    mc.unloadPlugin('prPyMath.py')
    mc.loadPlugin(plugin_path)
    manual_node_test()
    full_node_test()
Exemplo n.º 25
0
def __load_plugin(plugin_name, init_script_path):
    if not mc.pluginInfo(plugin_name, q=True, loaded=True):
        plugin_path = os.path.join(os.environ['TATOOL'],
                                   init_script_path).replace('\\', '/')
        mc.loadPlugin(plugin_path)
        mc.pluginInfo(plugin_path, e=True, autoload=True)
    else:
        mc.unloadPlugin(plugin_name, f=True)
Exemplo n.º 26
0
    def tearDown(self):
        """New Maya scene, unload plugin, reset data."""

        cmds.file(force=True, new=True)
        cmds.unloadPlugin("AL_USDMayaPlugin", force=True)

        self._stageA = self.MayaUsdTestData()
        self._stageB = self.MayaUsdTestData()
Exemplo n.º 27
0
def sureReloadPlugin(path):
    cmds.loadPlugin(path)
    cmds.file(new=True, f=True)

    cmds.unloadPlugin(path, f=True)
    #cmds.file(new=True, f=True)
    cmds.loadPlugin(path)
    #cmds.file(new=True, f=True)
Exemplo n.º 28
0
def installPlugin(source, target):
	print("Copying Plugin")
	if cmds.pluginInfo('simplex_maya.mll', loaded=True, query=True):
		cmds.unloadPlugin('simplex_maya.mll')
	if not os.path.isdir(os.path.dirname(target)):
		os.makedirs(os.path.dirname(target))
	shutil.move(source, target)
	cmds.loadPlugin(target)
def run():
    mc.file(newFile=True, force=True)
    mc.unloadPlugin(SETTINGS['plugin_name'])
    mc.loadPlugin(SETTINGS['plugin_path'])
    mc.file(SETTINGS['file'], open=True, force=True)
    mc.select(SETTINGS['selection'])
    prClosestPoint.fromSelection()
    mc.select(SETTINGS['selection'][-1])
Exemplo n.º 30
0
 def loadWeights(self, *args):
     print '\n... loading weights'
     print 'file:', self.directoryLineEdit.text()
     print 'mesh:', self.loadLineEdit.text()
     import maya.mel as mel
     cmds.unloadPlugin('tbLoadSaveWeights.py')
     cmds.loadPlugin('tbLoadSaveWeights.py')
     mel.eval('tbLoadSaveWeights -a "import" -f "%s" -m "%s"'
              % (self.directoryLineEdit.text(), self.skinClusterTransformLineEdit.text()))
Exemplo n.º 31
0
def testNode_create(path, nodeType):
    print('=== NEW SCENE ===')
    mc.file(new=True, f=True)
    mc.unloadPlugin(nodeType, f=True)
    print('=== LOAD PLUGIN ===')
    mc.loadPlugin(path)
    print('=== CREATE NODE ===')
    newNode = mc.createNode(nodeType)
    return newNode
Exemplo n.º 32
0
    def tearDown(self):
        """Unload plugin, new Maya scene, reset class member variables."""

        cmds.file(force=True, new=True)
        cmds.unloadPlugin("AL_USDMayaPlugin", force=True)

        self._stage = None
        self._sphere = None
        self._proxyName = None
Exemplo n.º 33
0
def initializePlugin(mobject):
    """ Initialize the plug-in when Maya loads it. """
    mplugin = OpenMayaMPx.MFnPlugin(mobject, "cg@penn", "1.0", "2020")
    try:
        mplugin.registerCommand(kPluginCmdName, cmdCreator, syntaxCreator)
    except:
        sys.stderr.write('Failed to register command: ' + kPluginCmdName)
    cmds.unloadPlugin(mplugin.loadPath() + '/VoxelPreviewNode.py')
    cmds.loadPlugin(mplugin.loadPath() + '/VoxelPreviewNode.py')
    mel.eval('source "' + mplugin.loadPath() + '/VoxelizeMenu.mel";')
Exemplo n.º 34
0
    def fix(self):
        """Remove all "unsupported" plugin nodes and unload plugins."""

        cmds.lockNode(self.errorNodes, l=False)
        cmds.delete(self.errorNodes)
        cmds.flushUndo()
        for plugin in self.errorPlugins:
            cmds.unloadPlugin(plugin)

        self.run()
Exemplo n.º 35
0
 def loadWeights(self, *args):
     print '\n... loading weights'
     print 'file:', self.directoryLineEdit.text()
     print 'mesh:', self.loadLineEdit.text()
     import maya.mel as mel
     cmds.unloadPlugin('tbLoadSaveWeights.py')
     cmds.loadPlugin('tbLoadSaveWeights.py')
     mel.eval('tbLoadSaveWeights -a "import" -f "%s" -m "%s"' %
              (self.directoryLineEdit.text(),
               self.skinClusterTransformLineEdit.text()))
Exemplo n.º 36
0
def uninstall():
    """Undo `install()`
    This unregisters the associated plug-in.
    """

    # Plug-in may exist in undo queue and
    # therefore cannot be unloaded until flushed.
    cmds.flushUndo()

    cmds.unloadPlugin(os.path.basename(__file__.replace('.pyc', '.py')))
Exemplo n.º 37
0
def uninitializePlugin(mobject):
    """ Uninitialize the plug-in when Maya un-loads it. """
    mplugin = OpenMayaMPx.MFnPlugin(mobject)
    try:
        mplugin.deregisterCommand(kPluginCmdName)
    except:
        sys.stderr.write('Failed to unregister command: ' + kPluginCmdName)
    mel.eval(
        "global string $myMenuMain; if (`menu -exists $myMenuMain`) deleteUI $myMenuMain;"
    )
    cmds.unloadPlugin(mplugin.loadPath() + '/VoxelPreviewNode.py')
Exemplo n.º 38
0
def reloadPlugin(pluginName, **keywords):
	"""
	Quickly reload a plug-in during testing
	@param reload Specifies whether or not to close and reopen the current file
	"""
	file = cmds.file(q=True, sn=True)
	if keywords.setdefault('reload') == True: cmds.file(f=True, new=True)
	cmds.flushUndo()
	cmds.unloadPlugin(pluginName)
	cmds.loadPlugin(pluginName)
	if keywords.setdefault('reload') == True: cmds.file(file, o=True)
Exemplo n.º 39
0
 def loadPlugin(self, mll, *args):
     pluginState = cmds.pluginInfo(mll, q=True, loaded=True)
     if pluginState:
         cmds.unloadPlugin(mll)
         self.setColour(mll)
     else:
         try:
             cmds.loadPlugin(mll)
             self.setColour(mll)
         except:
             self.setColour(mll)
Exemplo n.º 40
0
def flush():

	pluginPaths = map( Path, api.mel.eval( 'getenv MAYA_PLUG_IN_PATH' ).split( ';' ) )  #NOTE: os.environ is different from the getenv call, and getenv isn't available via python...  yay!

	#before we do anything we need to see if there are any plugins in use that are python scripts - if there are, we need to ask the user to close the scene
	#now as you might expect maya is a bit broken here - querying the plugins in use doesn't return reliable information - instead we ask for all loaded
	#plugins, to which maya returns a list of extension-less plugin names.  We then have to map those names back to disk by searching the plugin path and
	#determining whether the plugins are binary or scripted plugins, THEN we need to see which the scripted ones are unloadable.
	loadedPluginNames = cmd.pluginInfo( q=True, ls=True ) or []
	loadedScriptedPlugins = []
	for pluginName in loadedPluginNames:
		for p in pluginPaths:
			possiblePluginPath = (p / pluginName).setExtension( 'py' )
			if possiblePluginPath.exists():
				loadedScriptedPlugins.append( possiblePluginPath[-1] )

	initialScene = None
	for plugin in loadedScriptedPlugins:
		if not cmd.pluginInfo( plugin, q=True, uo=True ):
			BUTTONS = YES, NO = 'Yes', 'NO'
			ret = cmd.confirmDialog( t='Plugins in Use!', m="Your scene has python plugins in use - these need to be unloaded to properly flush.\n\nIs it cool if I close the current scene?  I'll prompt to save your scene...\n\nNOTE: No flushing has happened yet!", b=BUTTONS, db=NO )
			if ret == NO:
				print "!! FLUSH ABORTED !!"
				return

			initialScene = cmd.file( q=True, sn=True )

			#prompt to make new scene if there are unsaved changes...
			api.mel.saveChanges( 'file -f -new' )

			break

	#now unload all scripted plugins
	for plugin in loadedScriptedPlugins:
		cmd.unloadPlugin( plugin )  #we need to unload the plugin so that it gets reloaded (it was flushed) - it *may* be nessecary to handle the plugin reload here, but we'll see how things go for now

	#lastly, close all windows managed by baseMelUI - otherwise callbacks may fail...
	for melUI in baseMelUI.BaseMelWindow.IterInstances():
		melUI.delete()

	#determine the location of maya lib files - we don't want to flush them either
	mayaLibPath = Path( maya.__file__ ).up( 2 )

	#flush all modules
	dependencies.flush( [ mayaLibPath ] )

	if initialScene and not cmd.file( q=True, sn=True ):
		if Path( initialScene ).exists():
			cmd.file( initialScene, o=True )

	print "WARNING: You'll need to close and re-open any python based tools that are currently open..."
Exemplo n.º 41
0
def turtleClear( *args ):
    cmds.unloadPlugin( 'Turtle.mll', f=1 )

    if cmds.objExists("TurtleDefaultBakeLayer") :
        cmds.lockNode( "TurtleDefaultBakeLayer" , l = False)
        cmds.delete( 'TurtleDefaultBakeLayer' )
    if cmds.objExists("TurtleBakeLayerManager") :
        cmds.lockNode( "TurtleBakeLayerManager" , l = False)
        cmds.delete( 'TurtleBakeLayerManager' )
    if cmds.objExists("TurtleRenderOptions") :
        cmds.lockNode( "TurtleRenderOptions" , l = False)
        cmds.delete( 'TurtleRenderOptions' )
    if cmds.objExists("TurtleUIOptions") :
        cmds.lockNode( "TurtleUIOptions" , l = False)
        cmds.delete( 'TurtleUIOptions' )
Exemplo n.º 42
0
def reload_plugin(plugin_name):
    '''
    Safely reloading a plug-in without restarting Maya
    '''
    # clear the scene
    cmds.file(f=True, new=True)
    
    # Clear the undo queueW
    cmds.flushUndo()
    
    # Unload the plug-in
    cmds.unloadPlugin(plugin_name)
    
    # Reload the plug-in
    cmds.loadPlugin(plugin_name)
Exemplo n.º 43
0
def removeTurtle():
	'''
	Delete nodes and unload plgin related to the Turtle Renderer.
	'''
	# Remove Turtle Nodes
	turtleNode = 'TurtleDefaultBakeLayer'
	if mc.objExists(turtleNode):
		print('Removing Turtle nodes...')
		mc.lockNode(turtleNode,l=False)
		mc.delete(turtleNode)
	
	# Unload Plugin
	if mc.pluginInfo('Turtle',q=True,loaded=True):
		print('Unloading Turtle plugin...')
		try: mc.unloadPlugin('Turtle',f=True)
		except: print('Error unloading Turtle plugin!')
Exemplo n.º 44
0
    def buttonExportAnimatedClicked(self):
        if self.ui.exportCharacter.isChecked() or self.ui.exportAnimation.isChecked():
            cmds.loadPlugin(os.getenv('MAYA_SCRIPT_PATH').split(';')[2] + "/Exporter.mll")
            
            path = cmds.fileDialog2(fm=2, startingDirectory="../../Tron3k/Tron3k/Debug/GameFiles/CharacterFiles/")
            if path:
                perspective = 0;
                if self.ui.exportThird.isChecked():
                    perspective = 1;

                cmds.DataHandler(1, path[0], self.ui.exportCharacter.isChecked(), self.ui.exportAnimation.isChecked(), self.ui.classList.currentRow(), perspective)
            else:
                cmds.confirmDialog(title="Exporter", message="Path not found...       ", button="Ok", defaultButton="Ok", ma="Center")
                
            cmds.unloadPlugin("Exporter.mll");
        else:
            cmds.confirmDialog(title="Exporter", message="Select at least one item to export...       ", button="Ok", defaultButton="Ok", ma="Center")
Exemplo n.º 45
0
 def __update_plugin(self):
     """ this method updates the plugin """
     #--- open a new file
     cmds.file(new=True, force=True)
     #--- check if the plugin was specified
     assert self.plugin, check.error(self, 10)
     #--- compose the plugin path
     path = None
     if self.suffix == 'so':
         path = self.base_path + self.plugin + '/' + self.plugin + '.so'
     else:
         path = self.base_path + self.plugin + '.py'
     #--- reload plugin
     if cmds.pluginInfo(self.plugin + '.' + self.suffix, query=True, loaded=True):
         cmds.unloadPlugin(self.plugin + '.' + self.suffix)
     cmds.loadPlugin(path)
     if self.info:
         print 'Successfully reloaded plugin: ' + self.plugin + '.' + self.suffix
Exemplo n.º 46
0
 def reloadOnly( self, *args ):
     
     codePath = cmds.textField( self.fld_codePath, q=1, tx=1 )
     plugPath = cmds.textField( self.fld_plugPath, q=1, tx=1 )
     srcName  = cmds.textField( self.fld_srcName,  q=1, tx=1 )
     dstName  = cmds.textField( self.fld_dstName,  q=1, tx=1 )
     
     srcPath = ( codePath + '/' + srcName ).replace( '\\', '/' )
     dstPath = ( plugPath + '/' + dstName ).replace( '\\', '/' )
     
     cmds.unloadPlugin( dstName )
     
     shutil.copy2( srcPath, dstPath )
     
     print "Copy From : ", srcPath
     print "Past To   : ", dstPath
     
     cmds.loadPlugin( dstName )
     
     self.textFieldSaveCommand()
    def testBatching_DelegateRemoved(self):
        """Tests removing the diagnostic delegate when the batch context is
        still open."""
        self._StartRecording()
        with UsdMaya.DiagnosticBatchContext():
            Tf.Warn("this warning won't be lost")
            Tf.Status("this status won't be lost")

            cmds.unloadPlugin('pxrUsd', force=True)

            for i in xrange(5):
                Tf.Status("no delegate, this will be lost %d" % i)
        log = self._StopRecording()

        # Note: we use assertItemsEqual because coalescing may re-order the
        # diagnostic messages.
        self.assertItemsEqual(log, [
            ("this warning won't be lost", OM.MCommandMessage.kWarning),
            ("this status won't be lost", OM.MCommandMessage.kInfo),
        ])
    def testUnloadReload(self):
        self.assertEqual(cmds.loadPlugin('pxrUsd'), ['pxrUsd'])

        # Exporting a file with a mesh should trigger pxrUsdTranslators to load.
        file1 = os.path.abspath('test1.usda')
        cmds.polyCube()
        cmds.usdExport(file=file1)
        self.assertTrue(
                cmds.pluginInfo('pxrUsdTranslators', q=True, loaded=True))

        # Force unload the plugin.
        cmds.unloadPlugin('pxrUsdTranslators')
        self.assertFalse(
                cmds.pluginInfo('pxrUsdTranslators', q=True, loaded=True))

        # Re-exporting the file should trigger the plugin to load again.
        # Hopefully it doesn't crash.
        file2 = os.path.abspath('test2.usda')
        cmds.usdExport(file=file2)
        self.assertTrue(
                cmds.pluginInfo('pxrUsdTranslators', q=True, loaded=True))
Exemplo n.º 49
0
 def buttonExportStaticClicked(self):
     if self.ui.exportMap.isChecked():
         cmds.loadPlugin(os.getenv('MAYA_SCRIPT_PATH').split(';')[2] + "/Exporter.mll")
     
         path = cmds.fileDialog2(fm=2, startingDirectory="../../Tron3k/Tron3k/Debug/GameFiles/CharacterFiles/")
         if path:
             cmds.DataHandler(0, path[0])
         else:
             cmds.confirmDialog(title="Exporter", message="Path not found...       ", button="Ok", defaultButton="Ok", ma="Center")
         
         cmds.unloadPlugin("Exporter.mll");
         
     else:
         cmds.loadPlugin(os.getenv('MAYA_SCRIPT_PATH').split(';')[2] + "/Exporter.mll")
                 
         path = cmds.fileDialog2(fm=0, startingDirectory="../../Tron3k/Tron3k/Debug/GameFiles/CharacterFiles/", ff="*.bin")
         if path:
             cmds.DataHandler(2, path[0])
         else:
             cmds.confirmDialog(title="Exporter", message="Path not found...       ", button="Ok", defaultButton="Ok", ma="Center")           
     
         cmds.unloadPlugin("Exporter.mll");
Exemplo n.º 50
0
	def __unload_plugin(self):
		hadan_file_name = self.__get_hadan_filename()
		# make sure to fail if the file doesn't exist
		if None == hadan_file_name:
			cmds.warning('Could not find hadan plugin.')

		# unload found plugin
		if cmds.pluginInfo(hadan_file_name, l=True, q=True):
			if None == cmds.unloadPlugin(hadan_file_name, f=True):
				cmds.warning('Failed to unload hadan plugin.')
				return False
			cmds.warning('Successfully unloaded plugin: ' + hadan_file_name)
		else:
			cmds.warning('Skipped unloading plugin: ' + hadan_file_name)
		return True
Exemplo n.º 51
0
    def set_session(self):

        # Grab data
        name, plugin, scene, script = self._get_current_script_data()

        # New scene, force unload
        cmds.file(new=1, f=1)
        cmds.unloadPlugin(os.path.basename(plugin), f=1)

        # Try to clean listener
        try:
            mel.eval('cmdScrollFieldReporter -e -clear $gCommandReporter;')
        except RuntimeError:
            pass

        # Load plugin and scene, set layout
        cmds.loadPlugin(plugin)
        if os.path.isfile(scene):
            cmds.file(scene, open=True, f=True)
        mel.eval('setNamedPanelLayout "Script Editor/Persp"')

        # Run script
        if script:
            cmds.python(script)
Exemplo n.º 52
0
Arquivo: util.py Projeto: Byron/bsuite
	def tearDownAll(cls):
		mrv.maya.Scene.new(force=True)
		if cmds.pluginInfo(cls.test_plugin_path, q=1, loaded=1):
			cmds.unloadPlugin(cls.test_plugin_path)
Exemplo n.º 53
0
def removePlugin():
    pluginLoaded = cmds.pluginInfo( pluginFilePath, query=True, loaded=True )
    pluginUnloadOk = cmds.pluginInfo( pluginFilePath, query=True, unloadOk=True )
    if pluginLoaded and not pluginUnloadOk:
        cmds.file(f=True,new=True)
    cmds.unloadPlugin(pluginFileName)
Exemplo n.º 54
0
def pipeIdleStartup():
    # force auto-load of these plugins at startup!
    plugs=[
        'slumMayaPlugin.py', 
        'ieCore.so', 
        '3delight_for_maya%s' % os.environ['MAYA_VERSION_MAJOR'],
    ]
    if plugs:
        for each in plugs:
            print '='*80
            print 'PIPE: auto-loading %s plugin...\n' % each
            try:
                m.loadPlugin( each )
            except:
                pass
        print '='*80
    
    
    # re-initialize cortex menu to filter out admin ops!
    try:
        import IECore, IECoreMaya
    except: 
        IECore=None
        IECoreMaya=None
    
    if IECore:
        def __createOp( className ) :
            fnOH = IECoreMaya.FnOpHolder.create( os.path.basename( className ), className )
            maya.cmds.select( fnOH.fullPathName() )
                
        def filteredOpCreationMenuDefinition() :
            menu = IECore.MenuDefinition()
            loader = IECore.ClassLoader.defaultOpLoader()
            for className in loader.classNames() :
                if not filter( lambda x: x in className, ['admin/'] ):
                    menu.append(
                        "/" + className,	
                        {
                            "command" : IECore.curry( __createOp, className ),
                        }
                    )
            return menu

        menu = IECore.MenuDefinition()
        menu.append(
            "/Create Procedural",
            {
                "subMenu" : IECoreMaya.Menus.proceduralCreationMenuDefinition,
            }
        )
        
        menu.append(
            "/Create Op",
            {
                "subMenu" : filteredOpCreationMenuDefinition,
            }
        )
        
        #delete default cortex menu!
        for each in filter( lambda x: m.menu( x, q=1, l=1)=='Cortex', m.window( "MayaWindow", query=True, menuArray=True ) ):
            m.deleteUI( each, menu=True )
            
        #create our custom one!
        global __cortexMenu
        __cortexMenu = IECoreMaya.createMenu( menu, "MayaWindow", "Cortex" )
    
    
    # force unload of Alembic plugins!!
    m.unloadPlugin('AbcExport')
    m.unloadPlugin('AbcImport')
    try:
        mel.eval('jumpToNamedShelf("{0}");'.format(shelf))
    except:
        continue
#all shelves loaded -> save them
mel.eval('saveAllShelves $gShelfTopLevel;')
#time to delete them
shelfTopLevel = mel.eval('$tempMelVar=$gShelfTopLevel') + '|'
for shelf in shelvesDict:
    shelfLayout = shelvesDict[shelf].split('.mel')[0]
    if cmds.shelfLayout(shelfTopLevel + shelfLayout, q=True, ex=True):
        cmds.deleteUI(shelfTopLevel+shelfLayout, layout=True)
#mark them as deleted to avoid startup loading
shelfDir = os.path.join(envDir,'prefs','shelves')
for shelf in shelvesDict:
    shelfName = os.path.join(shelfDir,'shelf_' + shelvesDict[shelf])
    deletedShelfName = shelfName + '.deleted'
    if os.path.isfile(shelfName):
        #make sure the deleted file doesn't already exist
        if os.path.isfile(deletedShelfName):
            os.remove(shelfName)
            continue
        os.rename(shelfName,deletedShelfName)

#unload unnecessary plugins
plugins = prefs.unnecessaryPluginsForAnim
for plugin in plugins:
    if (cmds.pluginInfo(plugin, loaded=True, q=True)):
        cmds.unloadPlugin(plugin)
        cmds.pluginInfo(plugin, autoload=False, e=True)
Exemplo n.º 56
0
 def teardown(self):
     cmds.file(newFile=True, force=True)
     cmds.unloadPlugin("test_void_input")
     cmds.unloadPlugin("test_void_output")
Exemplo n.º 57
0
def autoLoadPlugin( pluginName ):
    import maya.mel as mel
    import maya.cmds as cmds
    def displayMessage( message, messageOn = False ):
        if messageOn:
            print message
        
    pluginPaths = []
    for path in mel.eval( 'getenv MAYA_PLUG_IN_PATH' ).split( ';' ):
        if not path: continue
        pluginPaths.append( path )
    pluginList = cmds.pluginInfo( q=1, listPlugins=1 )
    
    loadPluginPaths = []
    for path in pluginPaths:
        loadPluginPaths += glob.glob( "%s/%s*.mll" %( path, pluginName ) )
    
    targetPlugList = []
    paths = []
    for pluginPath in loadPluginPaths:
        path, plugin = pluginPath.split( '\\' )
       
        digit = plugin[ len( pluginName ): -4].replace( '_', '' )
        if not digit:
            targetPlugList.append( plugin[:-4] )
            if not len( paths ) : paths.append( path )
            if not path in paths: paths.append( path )
        elif digit.isdigit():
            targetPlugList.append( plugin[:-4] )
            if not len( paths ) : paths.append( path )
            if not path in paths: paths.append( path )

    targetPlugList.sort()
    if not targetPlugList: 
        displayMessage( '"%s" is not existing in plug-in path' % pluginName )
        return None
         
    if len( paths ) > 1:
        displayMessage( "\nTarget Plug-in exist in multiple paths" )
        displayMessage( "------------------------------------------------------" )
        for path in paths:
            displayMessage( path )
        displayMessage( "------------------------------------------------------\n" )
        displayMessage( "Target Plug-in exist in multiple paths" )
        return None
    
    if pluginList:
        if targetPlugList[-1] in pluginList:
            displayMessage( "%s is already loaded" % targetPlugList[-1] )
            return None
        for targetPlug in targetPlugList:
            if targetPlug in pluginList:
                try:
                    cmds.unloadPlugin( targetPlug )
                    displayMessage( '"%s" is unloaded' % targetPlug )
                except: 
                    displayMessage( "UnloadPlugin Failed : %s" % targetPlug )
                    return None
    else:
        for targetPlug in targetPlugList:
            try: 
                cmds.unloadPlugin( targetPlug )
                displayMessage( '"%s" is unloaded' % targetPlug )
            except: 
                displayMessage( "UnloadPlugin Failed : %s" % targetPlug )
                return None

    cmds.loadPlugin( targetPlugList[-1] )
    displayMessage( '"%s" is loaded' % targetPlugList[-1] )
Exemplo n.º 58
0
def annihilateTurtle_callback(*args):
    result = '[CALLBACK] "kBeforeNew"'
    if MC.pluginInfo('Turtle', query=True, loaded=True):
        MC.unloadPlugin('Turtle', force=True)
        result += ': Turtle annihilated:)'
    print result    
Exemplo n.º 59
0
def _unloadTurtlePlugin(*args):
    pluginName = 'Turtle'
    cmds.unloadPlugin(pluginName,f=True)
    return 0
Exemplo n.º 60
0
    def buttonExitClicked(self):
	cmds.unloadPlugin("OnImportSettings.mll")
        self.ui.close()