1. 贴图色彩空间被锁定的情况,解锁所有节点贴图的贴图色彩空间选项:

    import maya.cmds as cmds
    for i in cmds.ls(type='file'):
        cmds.connectAttr(":defaultColorMgtGlobals.cme",i+".cme",f=1)
  2. 脚本切换渲染器:

    cmds.setAttr("defaultRenderGlobals.currentRenderer", "arnold", type="string")
  3. 获取当前视图快照拍屏:

    ws = cmds.workspace(q = True, fullName = True)
    wsp = ws + "/" + "images"
    imageSnapshot = wsp + "/" + "endSnapshot.jpg"
    cmds.refresh(cv=True, fe = "jpg", fn = imageSnapshot)
  4. 脚本设置渲染设置的输出序列图选项:

    mc.setAttr("defaultRenderGlobals.animation", True)  # 开启动画帧序列
    mc.setAttr("defaultRenderGlobals.animationRange",1)  # 开启动画帧的范围
    mc.setAttr("defaultRenderGlobals.outFormatControl", 1)  # 设置帧格式
    mc.setAttr("defaultRenderGlobals.putFrameBeforeExt", 1) # 设置图片格式在数字后面(name.#.ext)
  5. 创建多相机渲染:

    • 选择相机>AtteibutsEdit>OutputSettings>Renderable(勾选)
    • RenderSetting>RednderableCamera>Add RenderableCamera
  6. Arnold开关运动模糊要同时设置运动模糊可见性:

    mc.setAttr("defaultRenderGlobals.motionBlur", 0) #关闭运动模糊(针对于Arnold)
    mc.setAttr("defaultArnoldRenderOptions.motion_blur_enable", 0) #关闭运动模糊可见性
    mc.setAttr("defaultRenderGlobals.motionBlur", 1) #开启运动模糊
    mc.setAttr("defaultArnoldRenderOptions.motion_blur_enable", 1) #开启运动模糊可见性
  7. 脚本打印部分渲染节点属性名称和值的方式:

    import maya.cmds as cmds 
    render_glob = "defaultRenderGlobals"
    list_Attr = cmds.listAttr(render_glob, r=True, s=True)
    for attr in list_Attr:
        get_attr_name = "%s.%s"%(render_glob, attr)
        print "setAttr %s %s"%(get_attr_name, cmds.getAttr(get_attr_name))
  8. mtoa 创建和访问AOV:

    import mtoa.aovs as aovs
    # 添加aov
    aovs.AOVInterface().addAOV('aov名称', aovType='float')
    # 列出活动状态的aovs
    aovs.AOVInterface().getAOVs()
  9. Arnold代码加载arnold渲染器并创建默认节点:

    import maya.cmds as mc
    import mtoa.core
    mc.setAttr("defaultRenderGlobals.currentRenderer","arnold",typ="string")
    mtoa.core.createOptions()  # 创建ar默认节点网络
  10. 查看 mel 函数帮助:
    使用 “whatIs ‘mel命令’;” 可以查看mel函数帮助。

  11. 设置maya视图窗口为非显卡(不使用显卡)支持的窗口模式:

    import maya.cmds as mc
    def switch_preview():
        all_model_panel = mc.getPanel(typ="modelPanel")
        for each in all_model_panel:
            mc.modelEditor(each,e=True,rnm="base_OpenGL_Renderer")  # 查询可用的渲染器名称 mc.modelEditor(each,q=True,rendererList=True) 
  12. Xgen相关:

    import xgenm.xmaya.xgmExternalAPI as xgenmExternalAPI
    import xgenm as xg
    palettes = xg.palettes()  # 获取Xgen 所有描述
    if not (xgenmExternalAPI.xgg.DescriptionEditor is None):
        xgenmExternalAPI.xgg.DescriptionEditor.refresh("Full")  # 刷新所有Xgen面板
  13. 开启软件时关闭材质刷新

    cmds.scriptJob(event=('SceneOpened','cmds.renderThumbnailUpdate(False)'))
  14. 添加回调

    import maya.OpenMaya as OpenMaya
    OpenMaya.MSceneMessage().addCallback(37, funcName)
  15. 清除进程任务

    import pymel.core.language as pcl
    _jobs =pcl.scriptJob(lj=1)
    #.清除内存任务 if._jobs:
    for _job in _jobs:
        job_id = int(_job.split(':')[0])
        print(u'清除进程任务:%s' % _job) 
        try:
            pcl.scriptJob(kill=job_id, force=True)
        except:
            pass
  16. 快速烘焙动画
    进行动画烘培(Bake Simu ation)的时候,Mava跳过逐帧跑一谝时间滑块。

    import maya.cmds as cmds
    start =int(cmds.playbackOptions(q=True, minTime=True))
    end = int(cmds.playbackOptions(q=True, maxTime=True))
    cmds.bakeResults(simulation=False, t=(start, end))
  17. 12代 Intel cpu 不兼容py插件问题:
    添加环境变量不要py中ssl相关的东西

    变量名:OPENSSL_ia32cap
    变量值:~0x200000200000000