Python maya.cmds 模块,pluginInfo() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用maya.cmds.pluginInfo()

项目:deltaMushToSkinCluster    作者:jeanim    | 项目源码 | 文件源码
def enableaPlugin(filename):
    extDict = {'win64':'mll','mac':'bundle','linux':'so','linux64':'so'}
    os = cmds.about(os=True)
    ext = extDict[os]
    version = cmds.about(v=True)[:4]
    pluginName = 'deltaMushToSkinCluster_%s' % version
    fileFullName = '%s.%s' % (pluginName,ext)
    rootPath = getParentPath(currentFileDirectory())
    pluginsPath = rootPath+'/plug-ins/'
    pluginFilePath = pluginsPath+fileFullName
    pluginStr = mel.eval('getenv "MAYA_PLUG_IN_PATH";')+';'+pluginsPath
    mel.eval('putenv "MAYA_PLUG_IN_PATH" "%s";' % pluginStr)
    with open(filename,'a+') as f:
        state = True
        for line in f.readlines():
            if re.findall(fileFullName,line):
                state = False
        if state:
            f.write(r'evalDeferred("autoLoadPlugin(\"\", \"%s\", \"%s\")");' % (fileFullName,pluginName))

    if not cmds.pluginInfo( pluginFilePath, query=True, autoload=True):
        cmds.pluginInfo( pluginFilePath, edit=True, autoload=True)

    if not cmds.pluginInfo(pluginFilePath,query=True,loaded=True):
        cmds.loadPlugin(pluginFilePath)
项目:mayakit    作者:danbradham    | 项目源码 | 文件源码
def is_loaded(plugin):
    '''Is plugin loaded?'''

    return cmds.pluginInfo(plugin, q=True, loaded=True)
项目:mayakit    作者:danbradham    | 项目源码 | 文件源码
def toggle_burnin(value):
    '''Toggle default viewport burnin'''

    viewport_burnin = get_viewport_burnin()
    if viewport_burnin:
        cmds.setAttr(viewport_burnin + '.v', value)
        return

    if not value:
        return

    if not cmds.pluginInfo(burnin.type_name, q=True, loaded=True):
        cmds.loadPlugin(burnin.type_name)

    viewport_burnin = cmds.createNode('burnin')
    cmds.addAttr(viewport_burnin, ln='viewport_burnin', at='bool', dv=True)
    cmds.setAttr(viewport_burnin + '.fontSize', 16)
    cmds.setAttr(viewport_burnin + '.fontWeight', 75)
    cmds.setAttr(viewport_burnin + '.fontAlpha', 0.75)

    t0 = viewport_burnin + '.textArray[0]'
    cmds.setAttr(t0 + '.textString', '{frame:0>3d}\n{camera}', type='string')
    cmds.setAttr(t0 + '.textColor', 1, 1, 1)
    cmds.setAttr(t0 + '.textAlign', 7)

    t1 = viewport_burnin + '.textArray[1]'
    cmds.setAttr(t1 + '.textString', '{user}\n{scene}', type='string')
    cmds.setAttr(t1 + '.textColor', 1, 1, 1)
    cmds.setAttr(t1 + '.textAlign', 6)
项目:Modular_Rigging_Thesis    作者:LoganKelly    | 项目源码 | 文件源码
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)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def plugin_load(plugin, *args):
    """
    checks whether plugin is loaded. Loads it if not
    """
    loaded = cmds.pluginInfo(plugin, q=True, loaded=True)
    if not loaded:
        cmds.loadPlugin(plugin)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def load_check(*args):
    """checks whether anim imp/exp plugin is loaded. Loads it if not"""
    loaded = cmds.pluginInfo("animImportExport", q=True, loaded=True)
    if not loaded:
        cmds.loadPlugin("animImportExport")
项目:SceneExplorer    作者:mochio326    | 项目源码 | 文件源码
def scene_open(path, set_project):
    '''
    ??????
    :return:
    '''

    def new_open():
        if set_project is True:
            cmds.workspace(project_path, openWorkspace=True)
        io.open(path, file_type, 1)
        add_rectnt_project(project_path)
        add_rectnt_file(path, file_type)

    types = {'.ma': 'mayaAscii', '.mb': 'mayaBinary', '.fbx': 'FBX', '.obj': 'OBJ'}
    if path == '':
        return None
    head, tail = os.path.split(path)
    name, ex = os.path.splitext(path)
    if ex not in types.keys():
        return None
    file_type = types[ex]
    project_path = get_project_dir(path)
    io = om.MFileIO()
    if cmds.file(q=1,sceneName=True) == '':
        new_open()
    else:
        result = cmds.confirmDialog(t='File Open', m='New Scene Open or Import Scene?',
                                    b=['New Scene', 'Import Scene', 'Cancel'],
                                    db='New Scene', cb='Cancel', ds='Cancel')
        if result == 'Cancel':
            return None
        elif result == 'New Scene':
            new_open()
        elif result == 'Import Scene':
            fbx_plugin = 'fbxmaya'
            cmds.loadPlugin('{0:}.mll'.format(fbx_plugin), qt=1)
            if fbx_plugin not in cmds.pluginInfo(q=1, ls=1):
                om.MGlobal.displayError('{0} Plugin in not loaded'.format(fbx_plugin))
                return None
            io.importFile(path, file_type, 1, str(tail.replace('.', '_')))

    # ??????????
    #ls = cmds.ls(typ='file', type='mentalrayTexture')
    #[cmds.setAttr(x + '.ftn', cmds.getAttr(x + '.ftn'), type='string') for x in ls]
    return 0
项目:3D_Software_and_Python    作者:p4vv37    | 项目源码 | 文件源码
def prepare_scene(path):
    """
    The function sets the basic parameters of the scene: time range and render settings.

    :param path: string - The directory with necessary files
    """

    cmds.playbackOptions(min=0, max=260)  # Set the animation range

    cmds.autoKeyframe(state=False)  # Make sure, that the AutoKey button is disabled

    plugins_dirs = mel.getenv("MAYA_PLUG_IN_PATH") # Mental Ray plugin is necessaryfor this script to run propperly.
    # Next lines check if the plugin is avaible and installs it or displays an allert window.
    # The plugins are accualy files placed in "MAYA_PLUG_IN_PATH" directories, so this script gets those paths
    # and checks if there is a mental ray plugin file.

    for plugins_dir in plugins_dirs.split(';'):
        for filename in glob.glob(plugins_dir + '/*'): # For every filename in every directory of MAYA_PLUG_IN_PATH
            if 'Mayatomr.mll' in filename: # if there is a mental ray plugin file then make sure it is loaded
                if not cmds.pluginInfo('Mayatomr', query=True, loaded=True):
                    cmds.loadPlugin('Mayatomr', quiet=True)
                cmds.setAttr('defaultRenderGlobals.ren', 'mentalRay', type='string') # Set the render engine to MR
                # Next lines are a workaround for some bugs. The first one is that the render settings window has to be
                # opened before setting attributes of the render. If it would not be, thhen Maya would display an error
                # saying that such options do not exist.
                # The second bug is that after running this scrpt the window was blank and it was impossible to set
                # parameters. This is a common bug and it can be repaired by closing this window with
                # cmds.deleteUI('unifiedRenderGlobalsWindow') command

                cmds.RenderGlobalsWindow()
                cmds.refresh(f=True)
                cmds.deleteUI('unifiedRenderGlobalsWindow')
                cmds.setAttr('miDefaultOptions.finalGather', 1)
                cmds.setAttr('miDefaultOptions.miSamplesQualityR', 1)
                cmds.setAttr('miDefaultOptions.lightImportanceSamplingQuality', 2)
                cmds.setAttr('miDefaultOptions.finalGather', 1)
                break
        else:
            continue
        break
    else:
        print("Mental Ray plugin is not avaible. It can be found on the Autodesk website: ",
              "https://knowledge.autodesk.com/support/maya/downloads/caas/downloads/content/",
              "mental-ray-plugin-for-maya-2016.html")
        alert_box =  QtGui.QMessageBox()
        alert_box.setText("Mental Ray plugin is not avaible. It can be found on the Autodesk website: " +
              "https://knowledge.autodesk.com/support/maya/downloads/caas/downloads/content/" +
              "mental-ray-plugin-for-maya-2016.html")
        alert_box.exec_()

    cam = cmds.camera(name="RenderCamera", focusDistance=35, position=[-224.354, 79.508, 3.569],
                      rotation=[-19.999,-90,0])  # create camera to set background (imageplane)
    # Set Image Plane for camera background
    cmds.imagePlane(camera=cmds.ls(cam)[1], fileName=(path.replace("\\", "/") + '/bg.bmp'))
    cmds.setAttr("imagePlaneShape1.depth", 400)
    cmds.setAttr("imagePlaneShape1.fit", 4)