def QAUnloadPlugin(plugin): if pm.pluginInfo(plugin, q=True, r = True): if pm.pluginInfo(plugin, q=True, loaded=True): # si está cargado pm.pluginInfo( plugin, edit=True, autoload=False ) # quitarle el autoload primero pm.unloadPlugin( plugin ) else: # no esta registrado print 'ANTARUXA WARNING!!! No existe el plugin: ' + plugin
def SCENE_kill_turtle_plugin(): ''' removes turtle maya plugin from scene ''' import pymel.core as pm try: pm.lockNode('TurtleDefaultBakeLayer', lock=False) pm.delete('TurtleDefaultBakeLayer') except RuntimeError: pass try: pm.lockNode('TurtleBakeLayerManager', lock=False) pm.delete('TurtleBakeLayerManager') except RuntimeError: pass try: pm.lockNode('TurtleRenderOptions', lock=False) pm.delete('TurtleRenderOptions') except RuntimeError: pass try: pm.lockNode('TurtleUIOptions', lock=False) pm.delete('TurtleUIOptions') except RuntimeError: pass try: pm.unloadPlugin("Turtle.mll") except ValueError: msg, status = 'Unable to unload Turtle', 0 msg, status = 'Turtle Killed', 1 return msg, status
def removeTurtle(): # 터틀 노드 제거 pm.unloadPlugin( 'Turtle.mll', f=True ) turtleNodes = pm.ls('Turtle*') for node in turtleNodes: node.unlock() pm.delete( node ) print u'"%s" 제거 성공' % node
def deleteUnknowPlugin(): oldplugins = pm.unknownPlugin(q=True, list=True) if oldplugins: log.info('Found {} unknown plugins'.format(len(oldplugins))) for plugin in oldplugins: try: pm.unknownPlugin(plugin, remove=True) log.info('%s removed succesfully' % plugin) except: log.info('Cannot remove %s' % plugin) pm.unloadPlugin('Turtle.mll')
def unloadAndUnregister(): if pm.pluginInfo('mayatomantra', q = True, l=True): pm.unloadPlugin('mayatomantra', force = True) if pm.renderer(RENDERERNAME, q = True, exists = True): pm.renderer(RENDERERNAME, unregisterRenderer = True) pm.loadPlugin( 'mayatomantra' ) if len(pm.ls(type = GLOBALSNAME)) == 0: pm.createNode(GLOBALSNAME, name = GLOBALSNAME) else: log.info("mayaToMantraGlobals node exists, using old one")
def unload(plugin): """ Unloads given plugin Args: plugin (string): plugin to unload """ if pm.pluginInfo(plugin, q=True, loaded=True): pm.pluginInfo(plugin, e=True, autoload=False) try: pm.unloadPlugin(plugin) except RuntimeError: pm.warning(plugin + ' could not be unloaded!')
def importFbx(path=None, update=False, dir=None): """ Imports the given fbx file. Args: path(str): An fbx file path. update(bool): Whether to update scene nodes instead of adding. dir(str): An optional directory to start in. Returns: list: A list of imported nodes. """ path = path or loadFbxDialog(dir=dir) if not str(path).endswith('.fbx'): raise FbxException('"%s" is not an fbx file.' % path) if not os.path.exists(path): raise FbxException('Path "%s" does not exist' % path) mObjects = [] def addNode(mObject, *args): """ A function that stores all added nodes. """ mObjects.append(mObject) # Create a callback to listen for new nodes. callback = om2.MDGMessage.addNodeAddedCallback(addNode, 'dependNode') try: # Import the file pmc.unloadPlugin('fbxmaya') pmc.loadPlugin('fbxmaya') pmc.mel.eval('FBXImportMode -v %s' % ('exmerge' if update else 'add')) pmc.mel.eval('FBXImport -f "%s"' % path.replace('\\', '/')) finally: # Always remove the callback om2.MMessage.removeCallback(callback) # Convert mObjects to node names nodes = set() for mObject in mObjects: if mObject.isNull(): continue if mObject.hasFn(om2.MFn.kDagNode): name = om2.MFnDagNode(mObject).fullPathName() else: name = om2.MFnDependencyNode(mObject).name() if pmc.objExists(name): nodes.add(pmc.PyNode(name)) return list(nodes)
def deleteUnknowPlugin(): oldplugins = pm.unknownPlugin(q=True, list=True) if oldplugins: for plugin in oldplugins: print plugin try: pm.unknownPlugin(plugin, remove=True) print '%s removed succesfully' % plugin except: print 'Cannot remove %s' % plugin try: pm.delete("*BaseAnimation*") except: pass pm.unloadPlugin('Turtle')
def checkPlugins(plugins): """Ensure plugins are either enabled or disabled. Args: - plugins: list of (plugin (string), state (bool)) tuples.""" unknown = [] for p, compatible in plugins: loaded = pmc.pluginInfo(p, q=True, l=True) if compatible and not loaded: try: pmc.loadPlugin(p) except: pmc.warning("Unknown plugin: ", p) unknown.append(p) elif loaded and not compatible: pmc.unloadPlugin(p) return unknown
def clean_turtle_node(): """Remove all presistant turtle node from the scene then unload turtle plugin.""" turtle_nodes = [ 'TurtleDefaultBakeLayer', 'TurtleBakeLayerManager', 'TurtleRenderOptions', 'TurtleUIOptions' ] for each_node in turtle_nodes: if pm.objExists(each_node): turtle_node = pm.PyNode(each_node) turtle_node.unlock() pm.delete(turtle_node) pm.mel.ilrDynamicAttributes(0) try: pm.pluginInfo('Turtle.mll', edit=True, autoload=False) pm.unloadPlugin('Turtle.mll', force=True) except Exception as e: pass
def unloadPlugin(self): if self.isRunning == 1: pm.unloadPlugin('DoremiEditor') self.isRunning = 0 self.ui.checkBoxDebug.setCheckState(Qt.Unchecked) self.ui.checkBoxDebug.setEnabled(False) self.ui.unloadPluginButton.setEnabled(False) self.ui.loadSceneButton.setEnabled(False) self.ui.unloadSceneButton.setEnabled(False) self.ui.resetMsgButton.setEnabled(False) self.ui.actionPluginLocation.setEnabled(False) self.ui.runFilemapButton.setEnabled(False) self.ui.stopFilemapsButton.setEnabled(False) self.ui.acceptFileNameButton.setEnabled(False) else: print 'Plugin is not running!'
def initialize(plugin): """Re-initialize specified plug in. @param plugin <string> Specify the plug-in name. """ cmds.file(new=True, force=True) repo_path = os.path.abspath(__file__).split('Maya')[0] print repo_path path = os.path.join(repo_path, 'Maya', 'plug-ins') if sys.platform == 'win32' or sys.platform == 'cygwin': plugin = '%s.mll' % plugin elif sys.platform == 'linux' or sys.platform == 'linux2': plugin = '%s.so' % plugin elif sys.platform == 'darwin' or sys.platform == 'os2': plugin = '%s.dmg' % plugin # end if get full plug in name if pm.pluginInfo(plugin, query=True, loaded=True): pm.unloadPlugin(plugin) # end if plug in is loaded unload it pm.loadPlugin(os.path.join(path, plugin))
def test_lateNodeCreation(self): # makes sure that we can still access a node from pymel.core.nodetypes, # even if it's created outside of a plugin initialization # # This isn't just a hypothetical / academic possibility = ie, mtoa # creates nodes outside of it's initialize, due to it's plugin system allNodes = set(pm.allNodeTypes()) self.assertNotIn('initialNode', allNodes) self.assertNotIn('myLateCreatedNode', allNodes) self.assertFalse(hasattr(pm.nt, 'InitialNode')) self.assertFalse(hasattr(pm.nt, 'MyLateCreatedNode')) pm.loadPlugin(pluginPath) try: # first, check that the "initialNode" was created allNodes = set(pm.allNodeTypes()) self.assertIn('initialNode', allNodes) self.assertNotIn('myLateCreatedNode', allNodes) self.assertTrue(hasattr(pm.nt, 'InitialNode')) self.assertFalse(hasattr(pm.nt, 'MyLateCreatedNode')) myInitialNode = pm.nt.InitialNode() myInitialNode.attr('aFloat').set(5) self.assertEqual(pm.getAttr('{}.aFloat'.format(myInitialNode)), 5) pm.addDynamicNode('myLateCreatedNode') allNodes = set(pm.allNodeTypes()) self.assertIn('initialNode', allNodes) self.assertIn('myLateCreatedNode', allNodes) self.assertTrue(hasattr(pm.nt, 'InitialNode')) self.assertTrue(hasattr(pm.nt, 'MyLateCreatedNode')) myLateNode = pm.nt.MyLateCreatedNode() myLateNode.attr('aFloat').set(8) self.assertEqual(pm.getAttr('{}.aFloat'.format(myLateNode)), 8) finally: pm.newFile(f=1) pm.unloadPlugin(pluginName) allNodes = set(pm.allNodeTypes()) self.assertNotIn('initialNode', allNodes) self.assertNotIn('myLateCreatedNode', allNodes) self.assertFalse(hasattr(pm.nt, 'InitialNode')) self.assertFalse(hasattr(pm.nt, 'MyLateCreatedNode'))
import pymel.core as pm import os MAYA_APP_DIR = mel.eval('getenv ("MAYA_APP_DIR")') pluginName = "dsRoll" pm.newFile(f=1) pm.unloadPlugin(pluginName) pm.loadPlugin( os.path.join(MAYA_APP_DIR, "scripts\dsNodes\dsRoll\plugins\{0}.py".format(pluginName))) pm.openFile(os.path.join(MAYA_APP_DIR, "scripts\dsNodes\dsRoll\\tests\\testScene.ma"), f=1) #### TEST #### dsRollNode = pm.createNode("dsRoll") pm.connectAttr(dsRollNode + ".rotation", "wheel_PLY.ry") pm.connectAttr("wheel_PLY.ty", dsRollNode + ".radius") pm.connectAttr("wheel_PLY.tz", dsRollNode + ".distance")
def tearDown(self): map(self.delete, list(self.nodes)) pmc.flushUndo() pmc.unloadPlugin(self.pluginname)
#Vars #----------------------------------------- verbose = True plugin_name = 'ocio_maya.mll' source_dir = 'C:/symlinks/paper_sketch/OpenColorIO_tools/ocio_maya_build/x64/msvc10/maya2014x64/Release' target_dir = 'C:/symlinks/maya/maya2014x64_plugins' texture_name = 'base_color_test_image.png' #'enzo_v0001_tw.png' texture_dir = 'C:/symlinks/temp' #Unload plugin #----------------------------------------- #open new file cmds.file(new=True, f=True) #unload pm.unloadPlugin(plugin_name) if (verbose): print('Unloaded plugin: {0}'.format(plugin_name)) #Copy plugin #----------------------------------------- try: shutil.copy2(source_dir + '/' + plugin_name, target_dir) if (verbose): print('Copied plugin from {0} to {1}'.format( source_dir + '/' + plugin_name, target_dir)) except: if (verbose): print('Error copying plugin from {0} to {1}'.format( source_dir + '/' + plugin_name, target_dir))
#twClothSolverIOPaperBlockout Test Fixture #------------------------------------------------------------------------------------- import pymel.core as pm #reload plugin #---------------------------------- try: #load new scene without saving pm.mel.eval('file -f -new;') #if plugin is loaded unload and reload it, else reload if(pm.pluginInfo( 'twClothSolverBlockoutPlugins.py', query=True, loaded=True )): pm.unloadPlugin( 'twClothSolverBlockoutPlugins.py' ) pm.loadPlugin( 'twClothSolverBlockoutPlugins.py' ) print('Successfully reloaded plugin') else: pm.loadPlugin( 'twClothSolverBlockoutPlugins.py' ) print('Successfully loaded plugin') except: print('Error Reloading Plugin') #TwClothSolverIOPaperBlockout #---------------------------------- #----------------------------------
def unload_mtm_plugin(): pm.newFile(force=True) if pm.pluginInfo("mayatomantra.mll", query=True, loaded=True): pm.unloadPlugin("mayatomantra.mll") pm.newFile(force=True)
def unload_plugin(): pm.newFile(force=True) if pm.pluginInfo("mayatoappleseed.mll", query=True, loaded=True): pm.unloadPlugin("mayatoappleseed.mll") pm.newFile(force=True)
def _dropped_install(): # -- current folder where the installer resides current_folder = os.path.dirname(__file__) # -- folder of all conents of mgear resides mgear_folder = os.path.normpath(os.path.join(current_folder, "release")) custom_path = False # -- default modules folder to install to install_path = os.path.normpath(os.path.join( os.environ['MAYA_APP_DIR'], "modules")) # -- mesage for the main installer dialog window message = ( "mGear will be installed here:\n" "{}\n" "\n" "Make sure to SAVE your scene before continuing.\n" "\n" "NOTE: Installing to a custom directory will require a restart.\n" "\n" "Would you like to continue?".format(install_path) ) # -- installer dialog window input = pm.confirmDialog(title="Installation Path", message=message, icon="question", button=["OK", "Cancel", "No, Custom Path"], cancelButton="Cancel", dismissString="Cancel") if input == "Cancel": pm.displayError("mGear installation has been cancelled.") return elif input == "No, Custom Path": install_path = None # -- custom path will be set here if install_path is None: install_path = pm.fileDialog2( fileMode=3, okCaption="Install here", caption="Please choose a folder to install mGear...")[0] custom_path = True # -- if install path is still None, exit if not install_path: return # -- flush the undo que in case there is anything that might disrupt # the install pm.flushUndo() # -- create a fresh scene incase there are any solvers still # loaded in memory pm.newFile(force=True) # -- mgear install path mgear_install_path = os.path.join(install_path, "mgear") # -- make sure the the mgear folder does not exist if os.path.exists(mgear_install_path): shutil.rmtree(mgear_install_path) # -- copy to a folder because tge copytree gives issues with # existing folders shutil.copytree(mgear_folder, mgear_install_path) # -- look in install directory for files of same name search_names = ["platforms", "mGear.mod", "scripts"] # -- construct path names full_path = [os.path.join(install_path, x) for x in search_names] # -- files of the same name found = files_exist(full_path) if found: # -- message if same files are found message = ("mGear files already exist in the install location.\n" "\n" "Would you like to overrite them?") # -- same files dialog window input = pm.confirmDialog(title="Delete existing files", message=message, icon="warning", button=["OK", "Cancel"], cancelButton="Cancel", dismissString="Cancel") if input == "Cancel": # -- delete the temp folder shutil.rmtree(mgear_install_path) pm.displayError("mGear installation has been cancelled.") return # -- iterate over folders and remove them for item in os.listdir(mgear_install_path): if os.path.exists(os.path.join(install_path, item)): # -- unload plugins incase there is a faulty install try: pm.unloadPlugin("mgear_solvers.mll", force=True) pm.unloadPlugin("weightDriver.mll", force=True) except: pass # -- delete file and folders if os.path.isfile(os.path.join(install_path, item)): os.remove(os.path.join(install_path, item)) elif os.path.isdir(os.path.join(install_path, item)): shutil.rmtree(os.path.join(install_path, item)) # -- move the folder to the install path shutil.move(os.path.join(install_path, "mgear", item), install_path) # -- delete the temp folder shutil.rmtree(mgear_install_path) # -- now let's get mgear up and running # -- add to the system path if not os.path.join(install_path, "scripts") in sys.path: sys.path.append(os.path.join(install_path, "scripts")) if custom_path: # -- we look for the Maya.env file and write the path to it env_file = os.path.normpath(os.path.join( os.environ["MAYA_APP_DIR"], pm.about(version=True), "Maya.env")) if os.path.exists(env_file): f = open(env_file, "w") f.write("MAYA_MODULE_PATH={0}".format(install_path)) f.close() # -- custom install dialog message message = ("A re-start of Maya will be required after this setup.") # -- custom install dialog window input = pm.confirmDialog(title="Custom Install Path Restart", message=message, icon="information", button=["OK"]) # -- if not a custom install we can load in the module else: # -- allows for not having to restart maya pm.loadModule(scan=True) pm.loadModule(allModules=True) # -- reload user setup files basic.executeUserSetup() # -- force load the plugins just incase it does not happen try: pm.loadPlugin("mgear_solvers.mll") pm.loadPlugin("weightDriver.mll") except: pass # -- installation message message = ("Installation Complete!") # -- installation dialog window input = pm.confirmDialog(title="Installation", message=message, icon="information", button=["OK"]) pm.displayInfo("Installation Complete")
#variables sourcePath = 'H:/scripts/c++/twClothSolver/x64/maya_2012_release' sourceName = 'twClothSolver.mll' destinationPath = 'H:/scripts/temp/mayaPluginsTest' #procedure import pymel.core as pm import shutil #force restart of maya and unload plugin #---------------------------------- try: #load new scene without saving pm.mel.eval('file -f -new;') #if plugin is loaded unload it if(pm.pluginInfo( sourceName, query=True, loaded=True )):pm.unloadPlugin( sourceName ) except: print('Error unloading Plugin') #copy plugin #---------------------------------- try: shutil.copy2(sourcePath +'/' +sourceName, destinationPath) except: print('Error copying files') #reload plugin #---------------------------------- try:
#Setup Script #------------------------------------------------------------------------------------- import pymel.core as pm try: #load new scene without saving pm.mel.eval('file -f -new;') #if plugin is loaded unload and reload it, else reload if(pm.pluginInfo( 'rbRoll.py', query=True, loaded=True )): pm.unloadPlugin( 'rbRoll.py' ) pm.loadPlugin( 'rbRoll.py' ) else: pm.loadPlugin( 'rbRoll.py' ) except: print('Error Reloading Plugin') try: #Create Sphere sphereTrans = pm.polySphere(ch = False, r = 1)[0] pm.select(cl = True) sphereShape = sphereTrans.getShape() pm.select(cl = True) #Create root_j and root_j_grp root_j = pm.joint(a = True, p = (0.0,0.0,0.0), n = 'root_j')
def __pluginUnloader(pluginName): if not pm.pluginInfo(pluginName, q=1, loaded=1): pm.unloadPlugin(pluginName)
def unload_plugins(cls): for plugin in cls.plugins_loaded: pm.unloadPlugin(plugin) cls.plugins_loaded = set()
plugin_fn.registerNode(CarpetRoll.TYPE_NAME, CarpetRoll.TYPE_ID, CarpetRoll.creator, CarpetRoll.initialize, ommpx.MPxNode.kDeformerNode) except: pm.displayError("Failed to register node {0}".format( CarpetRoll.TYPE_NAME)) def uninitializePlugin(plugin): plugin_fn = ommpx.MFnPlugin(plugin) try: plugin_fn.deregisterNode(CarpetRoll.TYPE_ID) except: pm.displayError("Failed to deregister node {0}".format( CarpetRoll.TYPE_NAME)) if __name__ == "__main__": pm.newFile(f=1) plugin_name = "E:/Maya/MayaAPI/Deforner/CarpetRoll.py" if pm.pluginInfo(plugin_name, q=1, loaded=True): pm.unloadPlugin(os.path.basename(plugin_name), f=True) pm.loadPlugin(plugin_name) pplane_transform, pplane_shape = pm.polyPlane() pplane_shape.subdivisionsWidth.set(20) pplane_shape.subdivisionsHeight.set(20) pm.select(pplane_transform) pm.deformer(type="CarpetRoll")
#Vars #----------------------------------------- verbose = True plugin_name = 'ocio_maya.mll' source_dir = 'C:/symlinks/paper_sketch/OpenColorIO_tools/ocio_maya_build/x64/msvc10/maya2014x64/Release' target_dir = 'C:/symlinks/maya/maya2014x64_plugins' texture_name = 'base_color_test_image.png' #'enzo_v0001_tw.png' texture_dir = 'C:/symlinks/temp' #Unload plugin #----------------------------------------- #open new file cmds.file(new = True, f = True) #unload pm.unloadPlugin(plugin_name) if(verbose): print('Unloaded plugin: {0}'.format(plugin_name)) #Copy plugin #----------------------------------------- try: shutil.copy2(source_dir +'/' +plugin_name, target_dir) if(verbose): print('Copied plugin from {0} to {1}'.format(source_dir +'/' +plugin_name, target_dir)) except: if(verbose): print('Error copying plugin from {0} to {1}'.format(source_dir +'/' +plugin_name, target_dir)) #Reload plugins
def __plugin_unloader(plugin_name): if not pm.pluginInfo(plugin_name, q=1, loaded=1): logprint('unloading %s!' % plugin_name) pm.unloadPlugin(plugin_name) logprint('%s unloaded!' % plugin_name)
sourcePath = "H:/scripts/c++/twClothSolver/x64/maya_2012_release" sourceName = "twClothSolver.mll" destinationPath = "H:/scripts/temp/mayaPluginsTest" # procedure import pymel.core as pm import shutil # force restart of maya and unload plugin # ---------------------------------- try: # load new scene without saving pm.mel.eval("file -f -new;") # if plugin is loaded unload it if pm.pluginInfo(sourceName, query=True, loaded=True): pm.unloadPlugin(sourceName) except: print("Error unloading Plugin") # copy plugin # ---------------------------------- try: shutil.copy2(sourcePath + "/" + sourceName, destinationPath) except: print("Error copying files") # reload plugin # ---------------------------------- try: