def verifyPlugin(pluginName, requiredBy): """ Verify that a particular plug-in is loaded and attempt to load it if it cannot be found. @param pluginName Name of the plugin without extension @param requiredBy __file__ member of the caller """ try: ampy.indexOf(pluginName, __allPlugins__) except: try: cmds.loadPlugin('%s.py'%pluginName) cmds.pluginInfo('%s.py'%pluginName, e=True, autoload=True) except: sys.stderr.write('Error: Could not locate the %s plug-in. It is required for the %s module.\nPlease ensure that %s.py is located somewhere in your plug-in path.\n' %(pluginName, os.path.basename(requiredBy), pluginName))
def verifyPlugin(pluginName, requiredBy): """ Verify that a particular plug-in is loaded and attempt to load it if it cannot be found. @param pluginName Name of the plugin without extension @param requiredBy __file__ member of the caller """ try: ampy.indexOf(pluginName, __allPlugins__) except: try: cmds.loadPlugin('%s.py' % pluginName) cmds.pluginInfo('%s.py' % pluginName, e=True, autoload=True) except: sys.stderr.write( 'Error: Could not locate the %s plug-in. It is required for the %s module.\nPlease ensure that %s.py is located somewhere in your plug-in path.\n' % (pluginName, os.path.basename(requiredBy), pluginName))
def verifyNode(nodeName): """Verify the existence of a DG node, primarily for validating user input.""" allObjects = cmds.ls() if ampy.indexOf(nodeName, allObjects) == None: # if nodeName is a DAG node then we need to test further possibilities # if nodeName exists but is not unique, then a full path must be provided msg = None for node in allObjects: if node.find('|%s'%nodeName) > -1: raiseExceptionWithMessage('%s is not a unique object name. Please specify the complete DAG path.'%nodeName, 1) # see if nodeName is a full path for a unique object, in which case it won't look the same as that returned by cmds.ls for node in allObjects: if nodeName[nodeName.rfind(node):nodeName.rfind(node)+len(node)] == node: return True raiseExceptionWithMessage('%s is not a valid object name. Please ensure that you have entered it correctly.'%nodeName, 1)