def remove_unused_plugins(): """Remove unused plugin from scene This will prevent Maya from saving redundant requires into scene file. (Copied from Maya support page) Maya is not cleaning up requires statements for unused plugins: Issue: When a plugin is used in Maya 2016, it puts a 'requires' statement into the header of the Maya File, akin to: requires "XZY" "1.30" When the plugin is subsequently deleted out of the Maya file and the Maya file is saved, the requires statement is left in the file. Causes: It creates extra lines of garbage code which makes the file larger and more clutter when files are being diagnosed Solution: Autodesk introduced one new command unknownPlugin which could be used to remove the "requires" line from the file if the plug-in is unknown to Maya 2016. """ for plugin in cmds.unknownPlugin(query=True, list=True) or []: cmds.unknownPlugin(plugin, remove=True)
def J_deleteUnknownNode(): cmds.delete(cmds.ls(type="unknown")) cmds.delete(cmds.ls(type="unknownDag")) if not cmds.unknownPlugin(q=True, l=True) == None: for item in cmds.unknownPlugin(q=True, l=True): print item cmds.unknownPlugin(item, r=True)
def cleanUp(look): allPanels = cmds.getPanel(type='modelPanel') for p in allPanels: cmds.modelEditor(p, edit=True, displayAppearance=look) for up in cmds.unknownPlugin(q=True, list=True) or list(): cmds.unknownPlugin(up, remove=True)
def removeUnknownPlugin(): plugins = cmds.unknownPlugin(q=1, list=1) if not plugins: plugins = [] for plugin in plugins: try: cmds.unknownPlugin(plugin, remove=1) except: pass
def auto_solve(self): unknown_plugins = self.get_unknown_plugins() for plugin in unknown_plugins: try: mc.unknownPlugin(plugin, remove=True) except: pass self.pass_check("unknown plugins has been deleted.")
def deleteUnknownPlugins(): """Delete all and unknown plugins referenced and their related nodes Maya 2015 SP6 and up only! """ unknownPlugins = cmds.unknownPlugin(query=True, list=True) or [] for plugin in unknownPlugins: deleteUnknownPluginNodes(plugin) cmds.unknownPlugin(plugin, remove=True) logger.debug('Removed the plugin: {0}'.format(plugin))
def remove_unknown_plugins(): for node in mc.ls(type='unknown'): mc.lockNode(node, lock=False) print('Deleting unknown node "%s"' % node) mc.delete(node) for plugin in mc.unknownPlugin(query=True, list=True): print('Removing unknown plugin "%s"' % plugin) mc.unknownPlugin(plugin, remove=True)
def SCENE_remove_unknown_plugins(): ''' removes missing plugins from ma file ''' if cmds.unknownPlugin(query=1, list=1): for plug in cmds.unknownPlugin(query=1, list=1): try: cmds.unknownPlugin(plug, remove=1) except RuntimeError as e: return 'Error Removing {}'.format(plug) + '\n' + str(e), 0 return 'Unknown Plugins removed', 1
def delete_unknown_plugins(): """ Delete all the unknown plugins present in the scene file :return: """ plugins_list = cmds.unknownPlugin(q=True, l=True) if plugins_list: for plugin in plugins_list: print(plugin) cmds.unknownPlugin(plugin, r=True)
def remove_plugins(): unknownPlugins = mc.unknownPlugin(q=True, list=True) if unknownPlugins: for unknownPlugin in unknownPlugins: mc.unknownPlugin(unknownPlugin, remove=True) logger.info('Remove %s unknownPlugins' % len(unknownPlugins)) return logger.info('No unknownPlugins')
def unknown_plugins(): """ clear unknown plugins """ oldplugins = cmds.unknownPlugin(q=True, list=True) if not oldplugins: return for plugin in oldplugins: try: cmds.unknownPlugin(plugin, remove=True) except: pass
def del_unknown_plugins(): """Delete Unknown Plugins""" unknown_plugins = cmds.unknownPlugin(q=True, list=True) print "Unknown Plugins Found :", unknown_plugins deleted_plugs = [] if unknown_plugins: for plugin in unknown_plugins: try: cmds.unknownPlugin(plugin, remove=True) deleted_plugs.append(plugin) except Exception, e: print '\nEXCEPTION occured:', e continue
def remove_unknown_plugins(): '''Danger...Forcefully removes all unknown plugins from your scene''' from maya import cmds unknown_plugins = cmds.unknownPlugin(query=True, list=True) if not unknown_plugins: _log.debug('No unknown plugins found.') return for plugin in unknown_plugins: _log.debug('Removing unknown plugin %s.' % plugin) remove_plugin_nodes(plugin) remove_unknown_plugin_nodes(plugin) cmds.unknownPlugin(plugin, remove=True)
def renderer_clean(check='Mayatomr', clean=False): """ Hattip: https://forums.autodesk.com/t5/maya-shading-lighting-and/maya-2017-scene-error-warning-about-mental-ray-nodes/td-p/6627874 """ d_rendererNodes = { 'turtle': [ 'TurtleRenderOptions', 'TurtleUIOptions', 'TurtleBakeLayerManager', 'TurtleDefaultBakeLayer' ] } _str_func = 'renderer_clean' log.debug("|{0}| >> [{1}] | clean: {2}...".format(_str_func, check, clean)) if check in ['Mayatomr']: l = mc.ls(type='unknown') log.debug("|{0}| >> unknown nodes: {1}".format(_str_func, len(l))) for n in l: try: _test = mc.unknownNode(n, q=True, p=1) if _test == check: log.debug("|{0}| >> matches: {1}".format(_str_func, n)) if clean: mc.delete(n) except: pass if check in mc.unknownPlugin(q=1, list=1): log.debug("|{0}| >> Found: {1}".format(_str_func, check)) if clean: log.debug("|{0}| >> Removing: {1}".format(_str_func, check)) mc.unknownPlugin(check, remove=1) else: l = d_rendererNodes.get(check.lower()) for n in l: if mc.objExists(n): log.debug("|{0}| >> matches: {1}".format(_str_func, n)) if clean: try: mc.delete(n) except Exception, err: log.debug("|{0}| >> Failed: {1} | {2}".format( _str_func, n, err)) """
def removeUnknownPlugin(): try: oldPlugins = mc.unknownPlugin(q=True, list=True) removes = [] if oldPlugins: for plugin in oldPlugins: mc.unknownPlugin(plugin, remove=True) removes.append(plugin) if not removes: logger.info('Remove 0 plugin') if removes: logger.info('Remove %s plugins' % len(removes)) logger.debug(removes) return removes except Exception as e: logger.debug(e)
def ui_details(self): self.setObjectName("UnloadPlugin_Window") self.setWindowTitle(u'插件卸载器') self.loadedPlugin_L.setText(u"已加载插件") self.unknownPlugin_L.setText(u"未知插件") self.renderPlugin_L.setText(u'渲染插件') self.loadedPlugin_PB.setText(u'全选') self.unknownPlugin_PB.setText(u'') self.renderPlugin_PB.setText(u'全选') self.run_B.setText(u'卸载') self.cancel_B.setText(u'取消') allPluginList = mc.pluginInfo(q=True, ls=True) self.loadedPluginList = self.pluginFilter.getRulesList(allPluginList) self.renderPluginList = self.pluginFilter.getRenderPlugin( allPluginList) self.unknownPluginList = mc.unknownPlugin(q=True, l=True) #if not self.unknownPluginList: # self.unknownPluginList = [] self.loadedPlugin_LW.itemClicked.connect(self.itemClicked) self.unknownPlugin_LW.itemClicked.connect(self.itemClicked) self.renderPlugin_LW.itemClicked.connect(self.itemClicked) otherList = list( set(self.loadedPluginList) - set(self.noUsePluginName)) self.loadedPlugin_PB.clicked.connect(lambda: self.selectAllItem( self.loadedPlugin_LW, self.loadedPlugin_PB, otherList)) #self.unknownPlugin_PB.clicked.connect(lambda:self.selectAllItem(self.unknownPlugin_LW, self.unknownPlugin_PB, self.unknownPluginList)) self.renderPlugin_PB.clicked.connect(lambda: self.selectAllItem( self.renderPlugin_LW, self.renderPlugin_PB, self.renderPluginList)) self.run_B.clicked.connect(self.run_Button) self.cancel_B.clicked.connect(self.close) self.loadedPlugin_Item() self.unknownPlugin_Item() self.renderPlugin_Item()
def get_unknown_plugin(): return mc.unknownPlugin(q=True, l=True)
# © 2020 AnD CGI This work is licensed under a Creative Commons # Attribution-ShareAlike 4.0 International License. '''Clean Unknown Plugins This Script Will Delete Any Unknown Plugins From Maya Scene The List of Deleted Plugins Can Be Seen On Maya Script Editor ''' import maya.cmds as cmds cmds.delete(cmds.ls(type="unknown")) plg_ls = cmds.unknownPlugin(q=True, l=True) if plg_ls: for plugin in plg_ls: print(plugin) cmds.unknownPlugin(plugin, r=True) ''' A Pre-maya 6.5 File That Contains References Is Converted To A Later Version Maya File, A Reference Node Named "_unknown_ref_node_" May Be Created And/or A Special "_unknown_ref_node_" Entry May Be Added To Existing Reference Nodes. This Node Type Was Used To Store Any Edits That Were Made Prior To 6.5 Until Those Edits Could Be Applied. Once All References In The Scene Have Been Loaded, All Edits Should Be Applied And The _unknown_ref_node_ Areas And Nodes Should Disappear. If There Are Any Edits Which Can Not Be Applied (for Example, Nodes In The Original Reference File That Were Renamed Or Deleted), The _unknown_ref_node_ Will Remain In The File. If You Need To Remove These Reference Nodes, You Can Do So By Querying For The _unknown_ref_node_ And Deleting It. That Is, This Specific Node Type Cannot Be Deleted Using The Reference Editor. ''' # Use The Bottom Line Only If You Have "_UNKNOWN_REF_NODE_" cmds.delete("_UNKNOWN_REF_NODE_")
""" Clean Maya File How to delete old unwanted Missing Maya Plug ins? """ import maya.cmds as cmds # delete unknown nodes cmds.delete(cmds.ls(type="unknown")) # delete unknown plugins plugins_list = cmds.unknownPlugin(q=True, l=True) if plugins_list: for plugin in plugins_list: print(plugin) cmds.unknownPlugin(plugin, r=True)
def unknown_remove(self): if self.__pluginName: mc.unknownPlugin(self.__pluginName, r=True)
def k_check_unPlugin(): k_unknownPlugins = unknownPlugin(q=1, l=1) if k_unknownPlugins != None: for k_unknownPlugin in k_unknownPlugins: unknownPlugin(k_unknownPlugin, r=1) return k_unknownPlugins
from maya import cmds plugins = cmds.unknownPlugin(q=1, list=1) if not plugins: plugins = [] for plugin in plugins: cmds.unknownPlugin(plugin, remove=1)
targets = pymel.core.ls( type='nodeGraphEditorInfo' ) pymel.core.delete( targets ) from maya import mel mel.eval( 'hyperShadePanelMenuCommand("hyperShadePanel1", "deleteUnusedNodes");' ) import pymel.core nsList = pymel.core.namespaceInfo( lon=1 ) for ns in nsList: nodes = pymel.core.ls( ns + ':*' ) if not len( nodes ): continue for node in nodes: node.rename( node.replace( ns + ':', '' ) ) pymel.core.namespace( rm=ns ) sels = pymel.core.ls( 'Ctl_*', type='transform' ) for sel in sels: if not sel.getShape(): continue sgCmds.lockParent( sel ) sgCmds.renameShape( sel ) if not sel.getParent().nodeName()[:3] == 'Ctl': sgCmds.renameParent( sel ) from maya import cmds plugins = cmds.unknownPlugin( q=1, list=1 ) if not plugins: plugins = [] for plugin in plugins: cmds.unknownPlugin( plugin, remove=1 )
# Data-Centric rigging 2020 Sample Data # www.studioanima.co.jp from pprint import pprint import maya.cmds as mc unknownPlugins = mc.unknownPlugin(q=True, list=True) or [] for pl in unknownPlugins: # force removal of plugins mc.unknownPlugin(pl, remove=True) print "The following unknown plugins removed!" pprint(unknownPlugins)
def cmd(self): for up in cmds.unknownPlugin(q=True, list=True) or list(): cmds.unknownPlugin(up, remove=True) self.cont = u'清理完成。' return 1