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

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

项目:config    作者:mindbender-studio    | 项目源码 | 文件源码
def process(self, name, namespace, context, data):
        from maya import cmds

        cmds.loadPlugin("AbcImport.mll", quiet=True)

        nodes = cmds.file(
            self.fname,
            namespace=namespace,

            # Prevent identical alembic nodes
            # from being shared.
            sharedReferenceFile=False,

            groupReference=True,
            groupName=namespace + ":" + name,
            reference=True,
            returnNewNodes=True
        )

        self[:] = nodes
项目:maya_rotationDriver    作者:ryusas    | 项目源码 | 文件源码
def doit(radius=5., num=36):
    cmds.loadPlugin('rotationDriver', qt=True)
    node = cmds.createNode('composeRotate')
    node_or = node + '.outRotate'
    node_h = node + '.bendH'
    node_v = node + '.bendV'

    shiftX = radius * 1.25

    top0 = _plotBendHV(node_or, node_h, node_v, 'plotStereoProj', radius, num)
    cmds.setAttr(top0 + '.tx', -shiftX)

    cmds.setAttr(node + '.method', 1)
    top1 = _plotBendHV(node_or, node_h, node_v, 'plotExpmap', radius, num)
    cmds.setAttr(top1 + '.tx', shiftX)

    cmds.delete(node)

    cmds.select([top0, top1])
项目:maya_greenCageDeformer    作者:ryusas    | 项目源码 | 文件源码
def doit(cage_tgt=None):
    if not cage_tgt:
        cage_tgt = cmds.ls(sl=True, o=True)
    cage = cage_tgt[0]
    tgt = cage_tgt[1:]

    cmds.loadPlugin('greenCageDeformer.py', qt=True)
    deformer = cmds.deformer(tgt, type='greenCageDeformer')[0]

    freezer = cmds.createNode('transformGeometry')
    cmds.connectAttr(cage + '.o', freezer + '.ig')
    cmds.connectAttr(cage + '.wm', freezer + '.txf')
    cmds.connectAttr(freezer + '.og', deformer + '.bc')
    cmds.disconnectAttr(freezer + '.og', deformer + '.bc')
    cmds.delete(freezer)

    cmds.connectAttr(cage + '.w', deformer + '.ic')
    cmds.dgeval(cmds.listConnections(deformer + '.og', s=False, d=True, sh=True, p=True))


#doit([cmds.polyCube(w=2.5, d=2.5, h=2.5)[0], cmds.polySphere()[0]])
项目: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)
项目:config    作者:mindbender-studio    | 项目源码 | 文件源码
def on_new(_):
    avalon.logger.info("Running callback on new..")

    # Load dependencies
    cmds.loadPlugin("AbcExport.mll", quiet=True)
    cmds.loadPlugin("AbcImport.mll", quiet=True)

    maya.commands.reset_frame_range()
    maya.commands.reset_resolution()
项目:cmt    作者:chadmv    | 项目源码 | 文件源码
def load_plugin(cls, plugin):
        """Load the given plug-in and saves it to be unloaded when the TestCase is finished.

        @param plugin: Plug-in name.
        """
        cmds.loadPlugin(plugin, qt=True)
        cls.plugins_loaded.add(plugin)
项目:cmt    作者:chadmv    | 项目源码 | 文件源码
def execute(self):
        cmds.loadPlugin('cmt_py', qt=True)
        for container in self.swingtwists:
            driver = container['driver'].value()
            driven = container['driven'].value()
            if not cmds.objExists(driver) or not cmds.objExists(driven):
                logger.warning('{0} or {1} does not exist.'.format(driver, driven))
                continue
            logger.info('Creating swingtwist on {0} from {1}'.format(driven, driver))
            name = container['name'].value()
            twist = container['twist'].value()
            swing = container['swing'].value()
            twist_axis = 'XYZ'.index(container['twist_axis'].value())
            cmds.swingTwist(driver, driven, name=name, twist=twist, swing=swing, twistAxis=twist_axis)
项目:SETools    作者:dtzxporter    | 项目源码 | 文件源码
def ReloadMayaPlugin():
    # Reload us as a plugin, be careful to unregister first!
    cmds.unloadPlugin('SEToolsPlugin.py')
    cmds.loadPlugin('SEToolsPlugin.py')

# Bind the weapon to hands
项目:mayakit    作者:danbradham    | 项目源码 | 文件源码
def safe_load(plugin):
    '''Load plugin'''

    if is_loaded(plugin):
        return

    cmds.loadPlugin(plugin)
项目: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 setPlugin():
    cmds.loadPlugin( pluginFilePath )
项目:pyblish-starter    作者:pyblish    | 项目源码 | 文件源码
def process(self, instance):
        import os
        from maya import cmds
        from pyblish_starter import api, maya

        self.log.debug("Loading plug-in..")
        cmds.loadPlugin("AbcExport.mll", quiet=True)

        self.log.info("Extracting animation..")
        dirname = api.format_staging_dir(
            root=instance.context.data["workspaceDir"],
            name=instance.data["name"])

        try:
            os.makedirs(dirname)
        except OSError:
            pass

        filename = "{name}.abc".format(**instance.data)

        maya.export_alembic(
            nodes=instance,
            file=os.path.join(dirname, filename).replace("\\", "/"),
            frame_range=(cmds.playbackOptions(query=True, ast=True),
                         cmds.playbackOptions(query=True, aet=True)),
            uv_write=True
        )

        # Store reference for integration
        if "files" not in instance.data:
            instance.data["files"] = list()

        instance.data["files"].append(filename)
        instance.data["stagingDir"] = dirname

        self.log.info("Extracted {instance} to {dirname}".format(**locals()))
项目: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
项目:config    作者:mindbender-studio    | 项目源码 | 文件源码
def process(self, instance):
        import os
        import polly
        from maya import cmds
        from avalon import maya

        self.log.debug("Loading plug-in..")
        cmds.loadPlugin("AbcExport.mll", quiet=True)

        self.log.info("Extracting animation..")
        dirname = polly.format_staging_dir(
            root=instance.context.data["workspaceDir"],
            time=instance.context.data["time"],
            name=instance.data["name"])

        try:
            os.makedirs(dirname)
        except OSError:
            pass

        filename = "{name}.abc".format(**instance.data)

        out_set = next((
            node for node in instance
            if node.endswith("out_SET")
        ), None)

        if out_set:
            nodes = cmds.sets(out_set, query=True)
        else:
            # Backwards compatibility
            nodes = list(instance)

        self.log.info("nodes: %s" % str(nodes))
        with maya.suspended_refresh():
            maya.export_alembic(
                nodes=nodes,
                file=os.path.join(dirname, filename).replace("\\", "/"),

                frame_range=(instance.data["startFrame"],
                             instance.data["endFrame"]),

                # Include UVs
                write_uv=True,

                # Include Visibility
                write_visibility=True,

                # Include all attributes prefixed with this
                attribute_prefix="mb"
            )

        # Store reference for integration
        if "files" not in instance.data:
            instance.data["files"] = list()

        instance.data["files"].append(filename)
        instance.data["stagingDir"] = dirname

        self.log.info("Extracted {instance} to {dirname}".format(**locals()))
项目: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)